Lockpick
Scenario
Forela needs your help! A whole portion of our UNIX servers have been hit with what we think is ransomware. We are refusing to pay the attackers and need you to find a way to recover the files provided.
The sherlock archive contains the following:
- A
.zip
file,bescript.zip
, containingbescrypt3.2
(the actual malware) - A
forela_criticaldata/
directory containing samples of encrypted files and ransom notes- Encrypted files have a
.24bes
extension.
- Encrypted files have a
Tasks
Please confirm the encryption key string utilised for the encryption of the files provided?
- Loading the
bescrypt3.2
malware into Ghidra revealed that it the program was invoking aprocess_directory
function directly frommain
:
We have recently recieved an email from
wbevansn1@cocolog-nifty.com
demanding to know the first and last name we have him registered as. They believe they made a mistake in the application process. Please confirm the first and last name of this applicant.
There is a co2_London
CSV file in forela_criticaldata/
which has avoided getting encrypted as it's missing the .csv
extension. The file appears to contain customer info, though there are no entries for wbevansn1@cocolog-nifty.com
. It's likely that the entry in question is in one of the encrypted files.
Disassembling bescrypt3.2
in Ghidra revealed the logic behind the encrypt_file
function used for encrypting files:
for
loop in encrypt_file
is responsible for actually encrypting a file by reading the source one character at a time, then XORing it with a character in the key. The position of the character in the key is found by calculating the modulus of the key length and current position in the file. This ensures that the index in key
is a valid number.
The above can be confirmed by having bescrypt3.2
encrypt the unencrypted co2_London
file and comparing the first few bytes with the source file:
Before encryption:
After encryption:
For the first byte (0x20
), i = 0
and uVar1 = 0
. This gives key[uVar1 % keylen] = key[0 % 18] = key[0]
. Calculating the XOR of 0x20
and key[0]
produces the expected result:
Wrote the following Go program for decrypting an encrypted file passed as an argument using the method above:
- Found the email in question in
forela_uk_applicants.sql
after decrypting it:
What is the MAC address and serial number of the laptop assigned to Hart Manifould?
This information is likely found in it_assets.xml
, though searching through the file proved difficult as it's a 6.6 MB file on a single line. Most text editors crashed when attempting to load the file, though vim
was able to load and search in it.
Alternatively, grep
can also search the file and print a specified number of characters before and after a match:
After cleaning up the output above, the actual record
entry is:
What is the email address of the attacker?
From the ransom notes: bes24@protonmail.com
City of London Police have suspiciouns of some insider trading taking part within our trading organisation. Please confirm the email address of the person with the highest profit percentage in a single trade alongside the profit percentage.
This data is found in trading-firebase_bkup.json
. Used the following Python script to load the data and sort it by profit margin:
The json
module does some rounding on float values. Got the correct value by looking up the email address found by the script (fmosedale17a@bizjournals.com
) corresponding to the highest profit margin.
Our E-Discovery team would like to confirm the IP address detailed in the Sales Forecast log for a user who is suspected of sharing their account with a colleague. Please confirm the IP address for Karylin O'Hederscoll.
- Found in
sales_forecast.xslx
Which of the following file extensions is not targeted by the malware?
.txt
,.sql
,.ppt
,.docx
,.xlsx
,.csv
,.json
,.xml
From the process_directory
function in bescrypt3.2
:
.ppt
is not in the list of extensions that gets encrypted.