Locpick2.0
Scenario
We've been hit by Ransomware again, but this time the threat actor seems to have upped their skillset. Once again a they've managed to encrypt a large set of our files. It is our policy NOT to negotiate with criminals. Please recover the files they have encrypted - we have no other option! Unfortunately our CEO is on a no-tech retreat and so can't be reached.
The sherlock archive contains the following:
- A directory (
share
) with three files:countdown.txt
expanding-horizons.pdf.24bes
takeover.docx.24bes
- A
.zip
archive (malware.zip
) with a single file namedupdate
.
When unzipped, the file appears to be an ELF executable:
Binary Analysis
It's likely that the provided files were encrypted by the provided update
binary, which means the binary needs to be analyzed to determine how the files were encrypted.
A good first step in analyzing any binary to run strings
on it to look for any plain-text strings. In this case, it appears it has been packed with UPX:
Binaries packed with UPX can be unpacked using the same upx
tool that is used for packing them:
Once unpacked, strings
returns a lot more plain text strings, including:
- A list of extensions (
.txt
,.pdf
,.sql
,.docx
,.xlsx
,.pptx
,.zip
,.tar
,.tar.gz
), which are likely the file types that the malware targets. - A URL to a pastebin (
https://pastes.io/raw/foiawsmlsk
) containing the ransom note. - The string
b7894532snsmajuys6
. - The string
%s.24bes
used for naming the encrypted files. - Multiple calls to cURL libraries.
- Calls to OpenSSL library functions.
- One call is to
EVP_aes_256_cbc@OPENSSL_3.0.0
, suggesting that the malware uses AES256 encryption in CBC mode.
- One call is to
- General status and error messages.
Given the above, it's likely that the binary interacts with the network and uses cURL to retrieve files.
Static Analysis
Analyzing the binary statically is siginificantly more involved as the URLs used for retrieving content aren't stored as plain text inside the binary, but rather as encrypted strings.
Loading the malware binary into Ghidra and stepping through main()
, there is a call to get_key_from_url()
early on:
The get_key_from_url()
function appears to act as a self-updater. Inside it, there is a call to another function named xor_cipher()
:
It's not immediately clear what the parameter local_98
above is used for, but the two other parameters point to what appears to be a key and a cipher.
K1
:
Note
Ghidra fails to detect the data type used, which can make it tricky to spot that the undefined
values are part of the same data structure.
HESB
:
Using HESB
as the key and K1
as the cipher produces an URL:
Decryption
The URL is a direct link to a file hosted on Dropbox:
The downloaded file is tiny (48 bytes). At two characters per byte, it's 96 chraracters long. From the context it most likely has something to do with the encryption process carried out by the malware.
The file only contains raw data:
Written out as a plain hex string, the file contents become:
Assuming the malware encrypts files in AES256 CBC mode, a 32 byte key and 16 byte initialization vector (IV) is needed to decrypt them. Taking the first 32 bytes (32 * 2 = 64 characters) as the key leaves 32 characters (16 bytes) for the IV:
Using the above as decryption parameters, the two documents in the share
directory can be decrypted:
Note
While the PDF file decrypts fine, the Word document appears to be somewhat corruped after decryption and won't open in LibreOffice Write. This is likely repairable, but the file contents can still be read by giving the file a .zip
extension, extracting it and opening word/document.xml
.
Tasks
What type of encryption has been utilised to encrypt the files provided?
This is listed in the strings
output from the unpacked binary, as well as when analyzing the binary in a disassembler.
The encryption used is AES.
Which market is our CEO planning on expanding into? (Please answer with the wording utilised in the PDF)
Mentioned on the second page of the expanding-horizons.pdf
file:
Please confirm the name of the bank our CEO would like to takeover?
This is mentioned in the takeover.docx
document:
I am writing to inform you that Forela Group is interested in acquiring Notionwide Bank. Our company is a well-established financial institution with a strong track record of success, and we believe that the acquisition of Notionwide Bank would be a strategic move for us.
The bank's name is Notionwide.
What is the file name of the key utlised by the attacker?
The file retrieved from Dropbox by the malware is named updater
.
What is the file hash of the key utilised by the attacker?
What is the BTC wallet address the TA is asking for payment to?
The address is listed in the ransom note (share/countdown.txt
):
...\ Send payment to our wallet deep,\ BTC Address: 1BvBMSEYstWetqTFn5Au4m4GFg7xJaNVN2,\ To verify and make us weep.\ ...
How much is the TA asking for?
This is also mentioned in the ransom note:
...\ A million pounds in Bitcoin bright,\ Shall bring your data back to light.\ ...
They are demaning £1000000.
What was used to pack the malware?
As mentioned above, the malware was packed with UPX.