CyberDefender: Flare-on 3 Lab Challenge Writeup

CyberDefender: Flare-on 3 Lab Challenge Writeup

2023-11-050xDEAD10 min
👋🌍

Description: Analyze and reverse engineer complex malicious challenges using static and dynamic analysis tools to uncover hidden functionality and extract IOCs.

Level: Insane

Category: Malware Analysis

Link: https://cyberdefenders.org/blueteam-ctf-challenges/flare-on-3/

Tactics: Privilege Escalation, Defense Evasion, Command and Control

Tools: IDA Pro, x64dbg, OllyDbg, FlareVM, WinDbg, CFF Explorer, Hex Workshop, ilspy

Scenario

Instructions:

  1. Uncompress the lab (pass: cyberdefenders.org), analyze samples and find the key. Each key looks like an email address and ends with @flare-on.com.
  2. The first challenge is a self-extracting zip file that requires you to accept the EULA before continuing.
  3. Fire-Eye pleased to announce the conclusion of the third Flare-On challenge. This year they had fantastic participation with a total of 2,063 players!
  4. WARNING! Some of these challenges may be malicious. Exercise extreme caution when executing unknown code. Be safe and perform the analysis inside of a virtual machine.

Questions

Q1. Challenge 1 - challenge1.exe key?

Solution: shooting_phish_in_a_barrel@flare-on.com

Step 1: Open the challenge1.exe file in a disassembler like IDA Pro or IDA Free.

Q1

Step 2: Analyze the functions \_main and sub_401260.

Q1

Q1

Q1

Step 3: Find the base64 encoded string: x2dtJEOmyjacxDemx2eczT5cVS9fVUGvWTuZWjuexjRqy24rV29q.

Q1

Step 4: Create a Python program to decode the string.

Q1

Q1

Step 5: Test the decoded string shooting_phish_in_a_barrel@flare-on.com as the password, which is successful.

Q1

Q2. Challenge 2 - DudeLocker.exe key?

Solution: close_t3h_file_On_th1s_One@flare-on.com

Step 1: Check for a Briefcasedirectory at %USER%\Desktop.

Step 2: The program checks if the disk serial number is 0x7DAB1D35 by calling GetVolumeInformationA.

Step 3: A set of AES-256 keys is generated with fixed content sha1("thosefilesreallytiedthefoldertogether").

Step 4: All files in the Briefcase directory are encrypted using AES-256.

Step 5: The wallpaper is changed to ve_vant_ze_money.jpg to inform the user of the RSA-4096 encryption.

Q2

Step 6: The solution is to patch the binary to replace CryptEncrypt with CryptDecrypt and modify the return value of GetVolumeInformationA to 0x7DAB1D35. The key is then revealed as

Q2

Q2

close_t3h_file_On_th1s_One@flare-on.com.

Q3. Challenge 3 - unknown key?

Solution: Ohs0pec1alpwd@flare-on.com

Step 1: Opening the file in IDA provides a clue about the symbol filename C:\extraspecial.pdb.

Q3

Step 2: Analyze the file in the IDA debugger.

Q3

Step 3: Create a Python script to decrypt the hex code.

Q3

Step 4: Run the script import2.py to generate the key, which is Ohs0pec1alpwd@flare-on.com.

Q3

Q4. Challenge 4 - flareon2016challenge.dll key?

Solution: follow_t3h_3xp0rts@flare-on.com

Step 1: Open the file flareon2016challenge.dll in an IDA debugger.

Q4

Step 2: Analyze the file in the IDA debugger.

Q4

Step 3: After dumping the executable from memory, a secret melody that provides parameters for the export is found.

Q4

Step 4: Create a Python script that decrypts the hex codes.

Q4

Step 5: Run the Python file ch4.py to generate the key, which is follow_t3h_3xperts@flare-on.com.

Q4

Q5. Challenge 5 - smokestack.exe key?

Solution: A*pop_pu$H*&_a_Jmp@flare-on.com

Step 1: Open smokestack.exe in the IDA debugger and analyze the code.

Q5

Step 2: Analyze the function sub_401610.

Q5

Step 3: The program calls sub_401540 inside a loop, which uses an index of functions to perform operations.

Q5

Step 4: A Python script bruteforce.py is used to bruteforce the key and Result of running bruteforce.py. File Link:https://github.com/kiinji/FLARE-On-2016/tree/master/challenge_5

Q5

Q5

Step 5: A second Python script is created to find the key by iterating through characters.

Q5

Step 6: Running the Python script generates the key.

Q5

Step 7: The key is then tested on the executable, and it works.

Q5

Q6. Challenge 6 - khaki.exe key?

Solution: 1mp0rt3d_pygu3ss3r@flare-on.com

Step 1: Run the khaki.exe file.

Q6

Step 2: Open the file in the IDA debugger.

Q6

Q6

Q6

Step 3: The file is unpacked using the unpy2exe tool.

Q6

Step 4: Run a Python program file.

Q6

Step 5: Run another Python program that provides the key.

Q6

Q6

Q7. Challenge 7 - hashes.exe key?

Solution: h4sh3d_th3_h4sh3s@flare-on.com

Step 1: Open the hashes.exe file in the IDA debugger.

Q7

Step 2: Analyze the file in IDA.

Q7

Step 3: Create a Python program that combines all the cracked pieces to find the key.

Q7

Q8. Challenge 8 - CHIMERA.EXE key?

Solution: retr0_hack1ng@flare-on.com

Step 1: Open the CHIMERA.EXE file in the IDA debugger and analyze it.

Q8

Step 2: A Python script is used to replicate the decryption routine.

Q8

Step 3: The decrypted code shows up in IDA.

Q8

Step 4: The instructions are redefined as code in IDA to fix the jumps.

Q8

Step 5: A DOSBox debugger is used to validate the findings.

Step 6: A Python script reverses the encoding to find the flag.

Q8

Q8

Step 7: Running the Python script target.py gives the key retro_hacking@flare-on.com.

Q9. Challenge 9 - GUI.exe key?

Solution: Shamir_1s_Confused@flare-on.com

Step 1: Open the GUI.exe file.

Q9

Step 2: The file is opened in dnSpy and found to be obfuscated with ConfuserEx 1.0.

Q9

Step 3: The button click handler function is analyzed.

Q9

Step 4: The deDot tool is used to deobfuscate the code.

Q9

Step 5: The program dynamically decrypts and loads Layer1.dll, and its code is dumped and deobfuscated.

Q9

Step 6: Now, the programs decrypts and loads Layer2.dll. Similarly, Layer2 checks for VM usage with a WMI query select \* from win32_videocontroller.

Step 7: The getKey function looks for a registry key secret under HKEY_CURRENT_USER.After creating the key in the registry, we proceed to Layer3.

Step 8: The third layer checks for the existence of the user shamir.

Q9

Step 9: The flag is found by combining 6 shares using ssss-combine.exe, with the shares dumped from memory and the 6th share from a decoded PNG.

Q9

Q10. Challenge 10 - flava.pcap key?

Solution: angl3rcan7ev3nprim3@flare-on.com

Step 1: Open flava.pcap in Wireshark and filter for tcp.stream == 233. It contains obfuscated JavaScript.

Q10

Step 2: The code is inside a try/catch block, which suppresses faulty decoding.

Q10

Step 3: After fixing the checks, the second layer is decoded.

Q10

Step 4: After bypassing checks for Kaspersky, the third layer is decoded.

Q10

Step 5: A function sends an HTTP POST request that is RC4 encrypted with the key flareon_is_so_cute and base64 encoded.

Q10

Step 6: A Python script is used to reverse the RC4 encryption and decode the dictionary value.

Q10

Q10

Step 7: Plugging in our values into the program then we get.

Q10

Step 8: The key is used to decode the received payload.

Q10

Step 9: The flash file is extracted from the pcap, and after decompiling, a loader function is found.

Q10

Q10

Step 10: The loaded flash file is dumped and deobfuscated.

Q10

Step 11: The code references an image at http://imgur.com/vnUziJP.

Q10

Step 12: There are two encrypted blobs of data and an image that is the decryption of one of them. By XOR-ing them, the flag can be found.

Q10

Step 13: A Python script can decode the flag character by character from the trace.Combining all the arg 0 values, we get the flag.

Q10

Conclusion

The solutions to the Flare-on 3 Blue Team Challenge showcase a comprehensive range of reverse engineering and malware analysis techniques. Each challenge required a different approach, from static analysis and debugging to network forensics and deobfuscation.

Key Takeaways

Diverse Skillset: The challenge required a diverse skillset, including proficiency with tools like IDA Pro, Wireshark, dnSpy, and various scripting languages (primarily Python). This highlights the need for a multi-faceted approach to dealing with sophisticated malware.

Obfuscation and Anti-Analysis Techniques: The challenges progressively introduced more advanced techniques, such as Base64 encoding (Challenge 1), anti-debugging and anti-virtual machine checks (Challenge 2, Challenge 10), and code obfuscation (Challenge 9). Analysts must be prepared to bypass these mechanisms to uncover the true functionality of the malware.

Layered Payloads: Several challenges, notably Challenge 9 and 10, involved a multi-stage payload delivery. The initial file was a loader that decrypted and executed subsequent stages, often involving dynamic loading of DLLs, encrypted blobs, or remote files. This is a common tactic used by modern malware to evade detection.

Importance of Context: The solutions often relied on clues from the environment (e.g., registry keys, disk serial numbers, external URLs), which highlights the importance of analyzing malware in a controlled, instrumented environment that can simulate these conditions.

Scripting for Automation: The recurring use of Python scripts in the solutions for tasks like decoding, decryption, and brute-forcing demonstrates the necessity of automation in malware analysis. Manual analysis alone would be too time-consuming for these complex challenges.

Network Traffic as a Source of Information: Challenge 10 specifically showcased how network forensics can be an integral part of malware analysis. The pcap file contained not only the malware payload but also critical information about its communication and decryption keys.

In conclusion, the Flare-on 3 challenges were designed to test an analyst's ability to navigate and overcome a wide variety of security obstacles. The solutions provide an excellent reference for common reverse engineering methodologies, underscoring that a combination of static analysis, dynamic analysis, and creative problem-solving is essential for success in malware analysis.

© 2025 Radheshyam Janwa. All rights reserved