Confusing Javascript


Reference


Solution

Given a javascript file.

eb925a1589f0c98b5550d3f176a141386bd8285cab874b5ed650535d4a1c0f16.js: JavaScript source, Unicode text, UTF-8 text, with very long lines (766), with CRLF line terminators

Notice that the filename looks like a hash. Initial step taken was putting the filename into VirusTotal.

Link herearrow-up-right

From here, the solution can go faster for this challenge without opening the javascript file.

The link provided by the VirusTotal contains a github repository with a malicious executablearrow-up-right.

Download the taskmanager.exe for further analysis.

Upon analysing the file using strings command suggest that the executable file was built using Python.

Decompile the executable to its source code using pyinstxtractorarrow-up-right .

python3 pyinstxtractor.py taskmanager.exe

There a lot of files in the executable. The most interesting one is PythonTelegramBot.pyc

Extract the pyc file to source code using pycdcarrow-up-right

pycdc PythonTelegramBot.pyc

The source code should be something like below.

Based on the code above, the assumption is that the flag is stored in a chat between the author and the bot.

The specific message stored by the bot needs to be forwarded using the forwardMessage Telegram API call method. With the bot API key and chat ID available, the API request can be constructed once the missing part, which is the message ID, is found

The API request should look like this:

https://api.telegram.org/bot<api_key>/forwardMessage?from_chat_id=<chat_id>&message_id=<message_id>&chat_id=<chat_id>

Create a python script to brute force the message id.

Then, message ID number 173 was received, and the request now appears as follows:

The flag will be shown in a json format as below


Flag

ihack24{fr0m_J4V45Cr1p7_2_73L39r4m}

Last updated