Currently working as a Senior Consultant at Netcompany spending my full-time job solving the SharePoint riddles. In the free time I'm expanding my understanding of cybersecurity through hacking activities. Git fanboy.
In the bustling town of Eastmarsh, Garrick Stoneforgeās workshop site once stood as a pinnacle of enchanted lock and toolmaking. But dark whispers now speak of a breach by a clandestine faction, hinting that Garrickās prized designs may have been stolen. Scattered digital remnants cling to the compromised site, awaiting those who dare unravel them. Unmask these cunning adversaries threatening the peace of Eldoria. Investigate the incident, gather evidence, and expose Malakar as the mastermind behind this attack.
Archive contains only capture.pcap - which given its size (over 8.5 MB) it can be expected to contain some binary data exchange.
Investigation
Start wireshark and letās see what we have there.
Brief scrolling through the packets show a lot of TCP packets. Borrowing the presentation technique from the author letās do not infer the conclusions based on the glance of such inferior and unreliable tool like an eye. Statistics > Protocol Hierarchy - yes, majority of traffic is TCP data.
We can go furhter and check Statistics > Conversations:
One route stands out and itās the one that transferred ~9MB of data to the 13.61.7.218 on port 55155. Because weāve already seen the HTTP requests, ports :80 and :443 should not be that suspicious (but only in this CTF scenario, usually :80 is something that should be given special care).
01. What is the IP address responsible for compromising the website?
We have one IP on the radar - but so far we only know that it is where probably exfiltrated data were sent. We still donāt know who initiated the attack. Because question especially asks about the website, letās check all HTTP traffic.
One specific raw stands out - /execute coming from 194.59.6.66. Packet details ultimately points that this indeed was mallicious intent.
Answer: 194.59.6.66
02. What is the name of the endpoint exploited by the attacker?
Already found. Answer: execute
03. What is the name of the obfuscation tool used by the attacker?
Decode the payload sent to the /execute endpoint. Right click on JavaScript Object Notation: application/json, Show Packet Bytes, select Show as JSON and save. Little clean up and we have stage 1, python script:
Python Data Marshalling
Read and writing Python values in a binary format. The format is specific to Python, but independent of machine architecture. The marshal module exists mainly to support reading and writing the āpseudo-compiledā code for Python modules of .pyc files.
We can further analyze the object.
import marshal,lzma,gzip,bz2,binascii,zlib
compressed_data = b'BZh91AY&SY\x8d <<binary data>>'
marshalled_object = bz2.decompress(compressed_data)
code = marshal.loads(marshalled_object)
print(type(code))
# List all attributes and methods of the object
print("Available attributes and methods:", dir(code))
# Filter and show only callable methods
methods = [m for m in dir(code) if callable(getattr(code, m))]
print("Callable methods:", methods)
if hasattr(code, "co_consts"):
print("Constants:", code.co_consts)
else:
print("No constants found")
if hasattr(code, "co_names"):
print("co_names:", code.co_names)
else:
print("No co_names found")
if hasattr(code, "co_varnames"):
print("co_varnames:", code.co_varnames)
else:
print("No co_varnames found")
At this point we can see many references to the Py-Fuscate.
Answer: Py-Fuscate
04. What is the IP address and port used by the malware to establish a connection with the Command and Control (C2) server?
This was already established in initial recon and doubled in the output of previous script.
Answer: 13.61.7.218:55155
05. What encryption key did the attacker use to secure the data?
In the output of previous script we see references to the Crypto.Cipher package and AES - so with great probability we can assume that indeed AES was used to encrypt data. This alghoritm needs two parameters to work - encryption key and IV vector. Usually encryption key is constant and known for the decryptor and IV vector is different for each ciphertext. In the easiest way, IV vector is sent in plain text together with the encrypted data.
š”
We can cheat a bit here (this is what I did) and come back to the PCAP, inspect all trafic that comes to the C&C and discover that two packets follow this template: ec2amaz-bktvi3e\administrator<SEPARATOR>5UUfizsRsP7oOCAq. Iāve blindly typed this as a flag and it passed.
For this and the next question we first have to somehow disassembly the Python bytecode. The most straighforward is to use dis package.