./Reverse Engineering

This write up is for RE challenge on UrchinSec CTF 2024. I manage to solve 3 over 4 challenge for RE.

The challenge give a file called "bond". For RE challenge i'm using Windows Flare VM to reverse the file.

  1. Initial step

Identify file type. In windows flare vm, there is a tool called Detect it Easy (DIE). This tools can help to detect file type.

Figure 1.0

Figure 1.0 above shows information for file "bond." The language used for that file is C/C++, and it uses the clang tool to compile the file. Another important information is that this file is from MacOS. So, to decompile it, you need to use suitable tools that support the MacOS file type.

  1. Decompile the binanry

Ghidra supports decompiling macOS file types when compiling files. However, there is an online compiler called "decompiler explorer."

Link: https://dogbolt.org/arrow-up-right

Figure 1.1

Based on Figure 2.0, this is what will happend if using decompiler explore. it gives many types of readable C code from various decompiler tools.

  1. Analyzing the code.

if analyze the code, the interesting part is main() and there is "xor_string" function. Based on the code snippet above, it is initializing the string and decrypt it with some key. These parameter are pass to the xor_string function. to decrypt the encrypted string, we can try to brute force the xor key.

  1. Decrypt the string

For decrypt the string, we can use cyberchef and xor brute force as a recipe.

Figure 1.2

Based on Figure 3.0, this is what it look, when brute force the xor key using cyberchef. Look on "key 03" that string look more readable then the other string. It looks like we need to decyper it again.

Since, we have no clue about the encryption use to decyper that string, we can find cipher identifier.

Link: https://www.dcode.fr/cipher-identifierarrow-up-right

Figure 1.3

Based on figure 4.0, this is what it looks like when using cipher identifier. It will give a few suggestion to decyper it.

Figure 1.4

After trying a few suggestions suggested by the tools, the encrypted string was using "Atbash Cipher" to encrypt the strings. After decrypt it, we get the flag.

Figure 2.0

Given a file name called "vibe".

  1. initial step.

Use DIE to gather information about the file.

Figure 2.1

Based on Figure 3.0, this is the only information that we have on vibe file. "binary"

This information doesnt give us so much insight about the file. After trying a few tools and researching another tool. Found an online tools to identify the file.

Link: https://www.aconvert.com/analyze.htmlarrow-up-right

Figure 2.2

Based on Figure 2.2, the file description is VBscript encoded. After a few research to find tools to decode the encoded vb file, there is a python script that can decode the vb script.

Link: https://github.com/JohnHammond/vbe-decoderarrow-up-right

Figure 2.3

Based on Figure 2.3 above, the flag obtain right away after decode the vb script using the python script. And the funny things is the challenge author for this challenge is the one who develop the vbe decoder script. Nice one !!! Learn a new thing during do this challenge.

Figure 3.0

For the drift challenge, it gives a .pcap file to analyse the network. Figure 3.0 shows that, there is http packet and there is GET method that get drift file.

Figure 3.1

In the wireshark go to File > Export Object > HTTP. Then click save. Let's analyze drift file.

Figure 3.2

Figure 3.2 shows information about the drift file. The file is in C/C++ language and is compiled on the Linux Operating System.

There are few interesting function which are

main()

hash_password()

compare_hashes()

Figure 3.3

When clicking on hash_password(), the MD5 function returns. This means the password will be passed to the MD5 function and encrypted in an MD5 hash.

Figure 3.4

When look around inside the main function, there is predefined_hash.

Figure 3.5

when we click on predefined_hash, it redirects us to the MD5 hash that could contain our flag.

Figure 3.6

Copy the hash and paste it to crackstation and we have the result.

Last updated