Our SOC detected an emerging RAT variant delivered via malicious file execution in its early stages, triggering an alert before C2 communication was fully established. Rapid containment prevented further exfiltration or post-exploitation activities. A full forensic triage was conducted to analyze persistence mechanisms and C2 infrastructure, enabling comprehensive IOC extraction to provide them to our threat intelligence platform for enhanced detection and proactive hunting.
A user on a workstation double-clicked a JScript file from their Downloads folder, and Windows Script Host immediately dropped and ran a batch file. That batch loader is heavily obfuscated with junk variables and chunked base64; it launches PowerShell, which patches the AMSI scan function in memory before decrypting two embedded PE files with AES and gzip. One is a tiny stub that is harmless alone; the other is a .NET loader carrying an AES-encrypted resource that it decrypts and injects into memory as the final RAT, a Mason/Neptune-family client. The same batch file was copied into the user’s Startup folder for persistence. The containment came before the RAT reached its C2, but its configuration was recovered and matched against public threat intel.
Evidence.ad1 → AccessData logical image. Extract it first with ad1extract from the open-source AD1-tools, then point the usual parsers at the extracted treeWindows\Prefetch → PECmd$MFT → MFTECmdRecent\*.lnk → LECmdWindows\System32\winevt\Logs → EvtxECmdTemp and Startup folders inside the image → python3 -I, dnfile, stringsTip: The release build of
ad1extractdouble-frees on this image. A debug/ASAN build extracts the full tree, andad1mountover FUSE is a fallback.
Parse prefetch and look at WSCRIPT.EXE: its last run lines up to the second with a Conf.js.lnk shortcut for Downloads\Conf.js, and the files wscript loaded include Conf.js itself and a TEMP_*.BAT. That is the user opening the script. Prefetch LastRun is the time to submit.
PECmd -d work/root/Windows/Prefetch --csv work/pf -q
LECmd -f Conf.js.lnk
Gotcha: The image also holds January 2025 “Ghost Toolbox” activity (
TOOLBOX.UPDATER). It looks like a good lead but is unrelated noise; the incident is the June 2025Conf.jsrun.
From Q1 the wscript prefetch already names a batch file in its loaded-files list. The MFT confirms it: a temp_*.bat under the Administrator profile’s AppData\Local\Temp, created one second after the script ran.
MFTECmd -f work/root/$MFT --csv work/mft --csvf mft.csv
grep -i 'temp_.*\.bat' work/mft/mft.csv
Filter the MFT for files created in the Startup folder after the Q1 execution. One batch file appears about 14 seconds after the script ran, and the extracted copy is the obfuscated loader analysed in the following questions. The mask asks for a full path starting with the drive letter.
grep -i 'Start Menu\\Programs\\Startup' work/mft/mft.csv
The Startup batch is padded with junk %variable% definitions. Strip those, join the base64 chunks, and expand the long execution line (line 362) to get the PowerShell stage. A separate ::: comment line holds UTF-16 base64; decoded, it is a PowerShell script that writes a byte array over the AMSI function. A mov eax,0 ; ret stub is the classic form of that patch, and the array in the script matches it.
python3 -I work/analysis/deob1.py 5c74.bat
python3 -I work/analysis/deob2.py
python3 -I work/analysis/deob3.py 5c74.bat
Tip: The mask is
****,***,****,****,****,****, so submit the bytes exactly as the script writes them (0xprefixes, comma-separated), not as a contiguous hex string.
The decoded PowerShell stage hardcodes a drop location in the user profile and reads two :: comment blobs from the batch file. Each blob is AES-CBC encrypted and gzip compressed, and decrypting them yields the two PE files. The file name comes from that hardcoded path in the script, not from a filesystem record: no matching file survived in the image to confirm it. This one was reasoned from the script rather than read from an artifact.
python3 -I work/analysis/dec.py 5c74.bat
grep -i 'dwm.bat' work/mft/mft.csv
Of the two PEs from Q4, one is a 4096-byte .NET stub with only a Main method and no payload logic, which fits “not malicious on its own”. Its SHA-256 also appears in vendor IOC lists for this family. The other PE is the real loader (Q6). The pick of the stub is reasoned from its size and contents rather than read from an artifact. Hash both decrypted PEs and take the stub’s SHA-1.
sha1sum work/analysis/stage3_part*
The second PE is a .NET loader. List its manifest resources: a single embedded resource with an oddly repetitive name is the encrypted payload. The loader decrypts it and loads the result in memory. The mask is 28 characters plus .exe.
import dnfile
pe = dnfile.dnPE("stage3_part1.bin")
print([r.name for r in pe.net.resources])
The loader holds the AES key and IV as base64 strings. Pull the strings from the second PE; the pair that decrypts the Q6 resource to a gzip stream, which in turn unpacks to an MZ file, is the right one. Submit key then IV, comma-separated.
strings -n 20 stage3_part1.bin
Decrypt the Q6 resource with the Q7 key and IV, gunzip it, and hash the result. The output is a .NET client whose internal name is MasonClient1.exe, which ties it to the Mason/Neptune RAT family. VirusTotal recognises the hash.
sha1sum payload_dec.bin
The decrypted payload stores its user agents as UTF-16 strings, so plain strings misses them. Dump wide strings and filter for the mobile one.
strings -el payload_dec.bin | grep -i iphone
No .NET decompiler was available, so read the IL directly. Find the Mutex::.ctor call and the stsfld that follows it; the field token it stores to resolves to a row in the Field metadata table, and that row’s name is the variable.
import dnfile
pe = dnfile.dnPE("payload_dec.bin")
print(pe.net.mdtables.Field.rows[12].Name)
The payload config holds a DuckDNS hostname (apostlejob3[.]duckdns[.]org) and port 2468. The IP is not in the evidence: the containment cut the connection before it resolved, and the event logs hold nothing for it. It comes from a public threat report on this Mason/Neptune RAT version, whose IOC list pairs that hostname with an address (Gurucul research).
grep -rla apostlejob work/files
bin/vt 052c0687f023564a3c31fb652bea3405341272cb --json
Tip: Search both UTF-8 and UTF-16 when grepping for the hostname; the config strings are wide.
| Phase | Action |
|---|---|
| Execution | User opens Conf.js from Downloads; wscript runs it |
| Execution | JScript drops and runs temp_993805.bat in the user’s Temp folder |
| Persistence | Obfuscated batch loader copied into the Startup folder as 5c74.bat |
| Defense Evasion | PowerShell stage patches the AMSI function in memory |
| Defense Evasion | AES and gzip blobs in the batch are decrypted into two PE files |
| Defense Evasion | .NET loader decrypts an embedded resource and loads the RAT in memory |
| Command and Control | RAT config points at a DuckDNS host on port 2468; containment stopped the connection |
| Type | Value |
|---|---|
| File | Downloads\Conf.js |
| File | Users\Administrator\AppData\Local\Temp\temp_993805.bat |
| File | C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\5c74.bat |
| Resource name | xxxxxxxxxxxxxxxxxxxxxxxxxxxx.exe |
| AES key | ALWIGeOnxudniHR2K4CNZmnaEZffXt6zKsRFoAM2/mA= |
| AES IV | JXYbOTuuz3cErOl30kAKhw== |
| SHA-1 (decrypted payload) | 052c0687f023564a3c31fb652bea3405341272cb |
| Mutex variable | Territories |
| Domain | apostlejob3[.]duckdns[.]org |
| C2 | 107.172.232[.]84:2468 |
| Technique | ID | Description |
|---|---|---|
| User Execution: Malicious File | T1204.002 | User opens Conf.js from Downloads |
| Command and Scripting Interpreter: JavaScript | T1059.007 | wscript runs the JScript dropper |
| Command and Scripting Interpreter: Windows Command Shell | T1059.003 | Dropped and Startup batch loaders |
| Command and Scripting Interpreter: PowerShell | T1059.001 | Stage that patches AMSI and decrypts the PEs |
| Boot or Logon Autostart Execution: Registry Run Keys / Startup Folder | T1547.001 | 5c74.bat in the Startup folder |
| Impair Defenses: Disable or Modify Tools | T1562.001 | In-memory AMSI patch |
| Obfuscated Files or Information | T1027 | Junk variables, chunked base64, encrypted resource |
| Deobfuscate/Decode Files or Information | T1140 | AES-CBC and gzip decoding at runtime |
| Reflective Code Loading | T1620 | Payload loaded from memory by the .NET loader |
| Dynamic Resolution | T1568 | C2 hostname on a dynamic DNS provider |
Script files in Downloads shouldn’t run under wscript. A .js double-clicked from a user folder spawning a dropped .bat is a short, high-signal chain. Associate .js with a text editor by policy, or block wscript and cscript from user-writable paths with WDAC or AppLocker.
AMSI tampering needs its own detection. The batch stage overwrote an AMSI function in memory before decrypting anything, which blinds script scanning for the rest of the chain. Script block logging and EDR telemetry on VirtualProtect against amsi.dll catch it at the first stage rather than the last.
Startup-folder writes by script interpreters are a clean alert. The loader copied itself into the Startup folder seconds after launch. File-creation monitoring on that path, filtered to non-installer processes, would have flagged it immediately.
Prefetch and the MFT carry the whole timeline. The execution time, the first dropped file and the persistence file all came from PECmd and MFTECmd output on a single image. Make sure both stay enabled and collected on endpoints, since the payload itself only exists encrypted.
Recover C2 config even when containment wins. The connection never completed, yet the payload config gave a hostname and port, and a vendor report completed the IP. Feed config-derived indicators to the threat intel platform, not just observed network traffic.
The RAT never reached its C2, but it had already patched AMSI, decrypted its payload in memory and planted a Startup-folder loader. Every stage hid behind a layer of encryption, so the early signals were the script launch, the dropped batch and the persistence write, all visible in prefetch and the MFT.