Sample Analysis: Salary-Lure JS Loader to a JPEG Carrying Remcos
TL;DR:
A JavaScript file posing as a Japanese "Spreadsheet about salary increases from December" decodes two XOR layers, drops a PowerShell script, and launches it hidden through WMI. That script loads a .NET loader straight into memory, which pulls a JPEG fromii-sen[.]irwith Remcos appended after the image's end-of-image marker. I unpacked every stage statically except the in-memory .NET loader, matched the dropped PowerShell to Triage's copy byte for byte, carved Remcos out of the JPEG, and decrypted its config. C2:winne[.]mynetav[.]net:2734.
Summary
The sample is a JavaScript file tagged Remcos on MalwareBazaar. Only 1 of 61 engines flagged it on VirusTotal during the time of this writing.
-
Outer JS (WSH) a hex blob padded with Unicode
junk, XOR-decoded with the plaintext key
j3eevZqDRSH5I1. -
Stage 2 dropper: a second XOR blob (key
GsNSDQHMEC1ccZ) written to%TEMP%\rad*.tmp.ps1and launched through WMI - Stage 3 PowerShell: downloads a .NET loader from a Cloudflare Workers URL and loads it in memory
- Stage 4 .NET loader: never touches disk, and the one stage I didn't recover
-
JPEG with a passenger: a real photo with Remcos
appended after the
FF D9end-of-image marker -
Remcos: native x64 RAT, injected into
CasPol.exeper Joe Sandbox
I ran it through ANY.RUN and Triage first so I knew what normal
looked like, then worked the JS layers statically with
grep, CyberChef, and a few Python
decoders. My own sandbox runs stopped at the .NET download, so I
picked up the rest of the chain from Joe Sandbox and a sister sample
on ANY.RUN, carved Remcos out of the JPEG, and decrypted its config.
Every key step got checked against an independent source.
Sample identifiers
| Field | Value |
|---|---|
| SHA256 |
38fef8dc1fab96cb08a27bebc4e85a022308371e15c7a131e27b491cd679dc90
|
| File type | JavaScript (.js), UTF-16LE, Windows Script Host |
| Size | 28,431,838 bytes, 28.4 MB (inflated by padding) |
| Original name | 12月からの昇給に関するスプレッドシート.js |
| Source | MalwareBazaar, tagged as Remcos |
| Family | Remcos RAT |
| VT detections | 1 / 61 at time of analysis |
| C2 | winne[.]mynetav[.]net:2734 |
1. The lure
Joe Sandbox shows the original filename in an escaped format:
12#U6708#U304b#U3089#U306e#U6607#U7d66#U306b#U95a2#U3059#U308b#U30b9#U30d7#U30ec#U30c3#U30c9#U30b7#U30fc#U30c8.js
Each #UXXXX is a Unicode code point
written in hex. Joe swaps non-ASCII characters out for that
notation. Two CyberChef operations turn it back into text:
-
Find / Replace:
#U→\u - Unescape string
That gives you 12月からの昇給に関するスプレッドシート.js, a JavaScript file pretending to be a salary spreadsheet.
2. Sandbox runs first
Before going static, I ran it in ANY.RUN and Triage so I'd know what normal looks like for this thing. That way, when I'm buried in code later, I can match what I'm reading to behavior I've actually seen.
ANY.RUN said nope
Initially, I attempted to upload the unzipped file, but the free
tier caps uploads at 16 MB, and this file is 28.4
MB.
I had to upload it zipped. The zip came in way under the
limit, ANY.RUN extracted it inside the VM, and I double-clicked the
.js from there.
Process tree
-
wscript.exeruns the JS (Windows' default handler for.jsfiles) -
powershell.exeshows up, but its parent iswmiprvse.exe, notwscript.exe. Section 4 shows exactly why.
powershell.exe -WindowStyle Hidden -ExecutionPolicy Bypass -Command "& 'C:\Users\admin\AppData\Local\Temp\rad8E7D9.tmp.ps1'; Remove-Item -LiteralPath 'C:\Users\admin\AppData\Local\Temp\rad8E7D9.tmp.ps1' -Force -ErrorAction SilentlyContinue"
It runs a .ps1 out of
%TEMP% with a hidden window, then
deletes that file right after.
wmiprvse.exe, not
wscript.exe.
Triage
Triage scored it 10/10 and pulled a deobfuscated
PowerShell snippet into its config section. Network-wise, it only
shows a DNS lookup and a GET to
hxxps://royal-wood-3c0d[.]julianosilvasantospiresrosa[.]workers[.]dev/prxyb
from powershell.exe, plus requests
to c[.]pki[.]goog for certificate
revocation lists (Windows checking certs during TLS).
It also captured the dropped script:
SHA256
b94b3efa333e41c846b01a0a65a0c72a5e756e3b44bed78179ae2a577f1ec47d.
ANY.RUN's TLS details show the cert for that workers[.]dev domain was issued by Let's Encrypt on 2026-11-06.
What neither sandbox showed: a Remcos process. Both
runs stop after the /prxyb request,
and without HTTPS interception I couldn't see what that response
contained.
3. Stage 1: the outer JS
All static work from here on happened in REMnux on an isolated network. First, the basic "what am I looking at" commands:
sha256sum 38fef8dc1fab96cb08a27bebc4e85a022308371e15c7a131e27b491cd679dc90.js
file 38fef8dc1fab96cb08a27bebc4e85a022308371e15c7a131e27b491cd679dc90.js
wc -c -l 38fef8dc1fab96cb08a27bebc4e85a022308371e15c7a131e27b491cd679dc90.js
head -c 1500 38fef8dc1fab96cb08a27bebc4e85a022308371e15c7a131e27b491cd679dc90.js; echo
tail -c 1500 38fef8dc1fab96cb08a27bebc4e85a022308371e15c7a131e27b491cd679dc90.js; echo
-
filesays UTF-16, little-endian, CRLF line endings. Most characters take 2 bytes, so the 28,431,838-byte file is roughly 14 million characters of text. - A whopping 2,999 lines for 28.4 MB. The lines in head and tail were short, so some lines had to be massive.
-
Head and tail are junk code. Random variable
names, pointless math, and
.length > 0checks whose results are never used.
Converting it and hunting for the real code
iconv -f UTF-16 -t UTF-8 38fef8dc*.js > s.js
wc -c -l s.js
# Top 10 longest lines (length, line number)
awk '{print length($0), NR}' s.js | sort -rn | head -10
# Look for the interesting goopy stuff
grep -n -E 'eval|Function\(|ActiveXObject|WScript|GetObject|winmgmts|Win32_Process|GetTempName|fromCharCode|\.Run|Create\(|ps1|powershell' s.js | cut -c1-250
Using -f UTF-16 instead of
UTF-16LE lets
iconv read the Byte Order Mark
(BOM) and drop it. Always pipe through
cut -c1-250 or
head on a sample like this. Some
lines are over 230,000 characters, and dumping one to your terminal
will lock it up. Ask me how I know.
The output laid out the whole structure:
- Lines 1261 to 1310: 50 enormous lines, each around 237,000 characters. That's the encoded payload.
-
Line 1315:
abiturient += String.fromCharCode(emplotments ^ cupules);decodes it one byte at a time with XOR. -
Line 1319:
eval(abiturient);runs whatever got decoded. -
Line 1323:
WScript.Quit();exits right after. Nothing below line 1323 ever runs.
Below the quit there's code that queries printers over WMI and
echoes things like DeviceID,
ShareName, and
PrintProcessor, with every
identifier renamed to a random English word (costella, hieland,
locomutation). It never executes.
Reading the decoder without running it
sed -n '1250,1260p;1301,1323p' s.js | cut -c1-300
Things I was looking for
- What the blob is: a number array, a string, or something else
-
Where
pyrolater(the XOR key variable) comes from: a single byte, a key string, or computed - How the loop walks the blob
While I'm sure everything was "randomized," these authors literally
kept the decoder function named
outmaneuver like it wasn't going to
raise a red flag lol. Oh, the irony.
What I found
-
falangais a hex string with a 15-character junk separator stuck after every single hex character. The separator mixes characters from all over Unicode, which is why it renders as garbage. -
falanga.split("<separator>").join("")cuts the string apart at every separator and glues it back with nothing in between. That's the classic JS way to say "delete every copy of X". What's left is pure hex. -
The loop walks the hex 2 characters at a time.
emplotmentsis the current byte,cupulesis the matching character of the keypyrolater = "j3eevZqDRSH5I1", and% pyrolater.lengthwraps back to the start after 14 bytes. That makes it a repeating-key XOR. -
eval(abiturient)runs the result, thenWScript.Quit().
Cooking it in CyberChef
First, pull every falanga line into
its own txt file.
grep -E 'falanga \+?= "' s.js > falanga.txt
Load the txt file into CyberChef with the open file button, then:
-
Find / Replace (regex):
^(var )?falanga \+?= "|"→ nothing -
Find / Replace (regex):
[^0-9A-Fa-f]→ nothing - From Hex
-
XOR: key
j3eevZqDRSH5I1, key format UTF8, scheme Standard
Gotchas I hit, so you don't have to:
-
The first chunk is a
var falanga = "...", not a+=. Miss it and the XOR key is out of line from byte 0, so everything turns to garbage. -
Step 1 strips
varon purpose. Theainvarand thef/ainfalangaare valid hex. - CyberChef's XOR key defaults to HEX. Switch it to UTF8.
- Don't run "Escape Unicode Characters" recipe before the regex. It turns the separator into escapes full of hex digits that the regex keeps.
4. Stage 2: the dropper
wc -c -l stage2.js
awk '{print length($0), NR}' stage2.js | sort -rn | head -10
grep -n -E 'eval|Function\(|ActiveXObject|GetObject|winmgmts|Win32_Process|GetTempName|fromCharCode|\.Run|Create\(|ps1|powershell|Write|SaveToFile|split\(' stage2.js | cut -c1-250
Stage 2 is the saved output of the first decoded stage. Stage 2 is 370,195 bytes across 2,827 lines, padded with more junk code.
This time the APIs observed from the sandboxes show up in plain
text, bunched together from around line 979. The real logic lives in
a function called main(), which
gets called at line 969 before it's even defined at 974. That works
because JavaScript hoists function declarations.
Stage 2 main function:
-
Second XOR key:
fruendal = "GsNSDQHMEC1ccZ"(line 977) -
Second blob:
intaker, same separator, samesplit().join(""), same XOR loop, decoded intoalternations(lines 979 to 998) -
Drop path:
%TEMP%\+GetTempName()+.ps1. That's where theradXXXXX.tmp.ps1names in the sandboxes come from. -
PowerShell path in pieces:
"C:","\\","Windows","System32","WindowsPowerShell\\v1.0","powershell.exe", glued together at runtime -
Command line: separator-padded character by
character, stripped into
kingdom -
WMI:
SWbemLocator→ConnectServer(".", "root\\cimv2")→Win32_Processand itsCreatemethod, plusWin32_ProcessStartup -
Hidden window:
ShowWindow = 0, thenCommandLine = kingdom -
Write:
CreateTextFile(path, true)→Write(alternations)→Close() -
Launch:
ExecMethod_("Create", ...) - Quit
Step 9 is why PowerShell's parent was
wmiprvse.exe in both sandboxes. The
JS asks WMI to start the process, so WMI's own process becomes the
parent.
The builder left its comments in, in Portuguese
-
//naomodificar("não modificar" = "do not modify") on lines 975 and 1036, wrapping the malicious block -
Right after
WScript.Quit(): "O restante do script original só é executado se a flag continuar True" = "The rest of the original script only runs if the flag stays True," above anif (executarResto === true)check - Line 962: "Le valor do dicionario; retorna "" se a chave nao existir" = "Reads the dictionary value; returns "" if the key doesn't exist"
5. Stage 3: the PowerShell
Decoding it
Same recipe, new key:
GsNSDQHMEC1ccZ.
sed -n '977p' stage2.js | cat -A
sed -n '979,990p' stage2.js > intaker.txt
The first attempt decoded a few clean characters, then garbage. Instead of guessing, I counted every printable ASCII character in the blob lines:
sed -n '979,990p' stage2.js | grep -o '[ -~]' | sort | uniq -c | sort -rn
After the hex digits, the leftovers were 20 quotes, 8 commas, the
letters for var intaker, and
c, c, o, n, t, a plus
.,
(,
),
;. That spells
.concat(:
var intaker = "chunk1".concat("chunk2", "chunk3", ..., "chunk10");
c,
c, and
a are valid hex. My "delete
everything that isn't hex" regex kept them, injected 3 fake hex
characters, and shifted every byte after them. Fix: strip
.concat( first. The first Find /
Replace becomes
var intaker =|\.concat\(. Lesson:
when you're cleaning hex out of code, the code's own keywords can
pass as hex.
Proving the decode is right
Triage captured the file the dropper actually wrote, so I had something to check against. This decoder mirrors the JS exactly and writes raw bytes:
#!/usr/bin/env python3
# Decode a separator-padded hex blob with repeating-key XOR. Writes raw bytes.
# usage: decode_blob.py <file> <start_line> <end_line> <split_line> <key> <out>
import re
import sys
src, start, end, split_ln, key, out = sys.argv[1:7]
start, end, split_ln = int(start), int(end), int(split_ln)
key = key.encode()
with open(src, encoding="utf-8") as f:
lines = f.read().split("\n")
sep = re.search(r'\.split\("(.*?)"\)', lines[split_ln - 1]).group(1)
block = "\n".join(lines[start - 1:end])
blob = "".join(re.findall(r'"(.*?)"', block)).replace(sep, "")
bad = sorted(set(c for c in blob if c not in "0123456789abcdefABCDEF"))
print(f"[*] separator: {len(sep)} chars, hex digits: {len(blob)}")
if bad:
sys.exit(f"[!] non-hex characters remain: {bad[:20]}")
data = bytes(int(blob[i:i + 2], 16) ^ key[(i // 2) % len(key)]
for i in range(0, len(blob) - 1, 2))
with open(out, "wb") as f:
f.write(data)
print(f"[+] wrote {len(data)} bytes to {out}")
python3 -I ~/scripts/decode_blob.py stage2.js 979 990 992 GsNSDQHMEC1ccZ stage3.ps1
sha256sum stage3.ps1 radD50AF.tmp.ps1
4,510 hex digits → 2,255 bytes, SHA256
b94b3efa333e41c846b01a0a65a0c72a5e756e3b44bed78179ae2a577f1ec47d. Byte for byte the same as Triage's
radD50AF.tmp.ps1.
Building iex without typing it
. ( $ENv:comspec[4,26,25]-JoIN'') ( '<script>'.Replace(...) )
$env:comspec normally holds
C:\Windows\system32\cmd.exe.
Counting from 0, positions 4, 26, and 25 are
i,
e, and
x: iex, short for
Invoke-Expression. The script runs
its own body without the word ever appearing in the file.
Placeholders
| Placeholder | Becomes | How it's built |
|---|---|---|
7Od |
$ |
.rePLACe('7Od','$') |
SLH |
| |
[CHAr]83+[CHAr]76+[CHAr]72 = "SLH" |
Dh4 |
' |
[CHAr]68+[CHAr]104+[CHAr]52 = "Dh4" →
[CHAr]39
|
On top of that, strings are chopped into concatenated pieces like
'7Odeluvia'+'tions'.
The loader logic
-
Sets the URL
hxxps://royal-wood-3c0d[.]julianosilvasantospiresrosa[.]workers[.]dev/prxyb -
Creates a WebClient with
[activator]::createInstance([net.webclient])and sets a Chrome 120 User-Agent -
Downloads the response with
DownloadString() -
If it contains
-INICIO-(.*?)-FIM-, keeps only what's between the markers ("início" and "fim" are Portuguese for "start" and "end") -
Reverses the string, replaces every
*withA, and base64-decodes it -
Loads the bytes as a .NET assembly with
[System.AppDomain]::CurrentDomain.Load(), straight from memory -
Finds a method named
vtand calls it with 19 arguments: 12 base64 strings and 7 empty strings
I couldn't decode those encrypted base64 arguments, so I'm not going to guess what they hold.
6. Picking up the trail
My sandbox runs stopped at /prxyb,
so I went back to Joe Sandbox, which ran this hash on
2026-11-13 while the infrastructure was still
serving.
What Joe saw after stage 3
-
powershell.exespawnsCasPol.exe(a legit .NET Framework binary) and injects a PE into it at0x140000000 -
Remcos YARA hits in PowerShell's memory and on the unpacked image
inside
CasPol.exe -
A second download:
hxxps://ii-sen[.]ir/nv/payload_113212[.]png→103.215.222[.]13:443, matched by Joe's "Remcos - Steganography payload download" rule -
CasPol.exeinjects intochrome.exeand launches headlessmsedge.exewith--remote-debugging-port=9222 -
Joe's dropped PowerShell was
radEAD54.tmp.ps1, the same pattern again
Rookie trap I almost fell into: the only file in Joe's dropped files
is %TEMP%\THB768.tmp, a
108,144-byte .NET file. Its MD5 (C91C5994E9C0F1690C296B57DFCD2EDF) is identical to CasPol.exe's MD5
in the process tree, and
CasPol.exe is what wrote it. It's a
copy of CasPol, not the missing loader. Always compare hashes before
you chase a dropped file.
A sister sample on ANY.RUN
Searching ANY.RUN's public submissions turned up another task from
2026-11-13 01:32: "Таблица с информацией о повышении заработной
платы с декабря .pdf.zip", Russian for
"Table with information about salary increases from
December".
SHA256
906b78d823d1dc2b3283672e86ba5eb68e1b9c8c75dfe2a0b9d14579f9e52302.
-
The same
/prxybandii-sen[.]irURLs, and a connection to103.215.222[.]13 -
DNS for
winne[.]mynetav[.]net -
wmiprvse.exe→ hidden PowerShell runningradC61FA.tmp.ps1, then deleting it -
caspol.exetagged #REMCOS
That task saved the file from
ii-sen[.]ir in its Files tab. I
briefly switched REMnux to the internet-connected network,
downloaded it, checked the hash, and went straight back to isolated:
7z x <download>.zip -o./png_payload # password: infected
sha256sum ./png_payload/*
SHA256
9912ca6dce79a65c49eb55f751759d426ded522f93d33358f2228f2c6270b321. VT: 6/61, 3.12 MB, and VT calls it a
JPEG despite the
.png name.
ii-sen[.]ir is an Iranian domain,
and Joe geolocates
103.215.222[.]13 to Iran (AS48551).
That's where the file was hosted, not indicative of who's actually
running the campaign.
7. The JPEG with a passenger
file ii-sen.ir
exiftool ii-sen.ir
xxd ii-sen.ir | head -5
xxd ii-sen.ir | tail -5
strings -n 8 ii-sen.ir | grep -i -E 'INICIO|FIM|MZ|TVqQ'
The image itself is real: a valid JPEG, 3840x2160, made in Photoshop CC 2019, with metadata dates from 2021 and 2022. It even has a text layer that reads "RULE THEM ALL, ONE BOARD TO." However, the end of the file is not an image:
0031f750: 2323 2323 2323 2323 2323 2323 2323 2323 ################
0031f760: 2323 2323 2323 674c 2323 2323 2323 382f ######gL######8/
0031f770: 2f23 2323 2323 2323 2323 2323 2345 2323 /############E##
0031f780: 2323 2323 2323 2323 2323 4d23 2323 2323 ##########M#####
0031f790: 2351 7156 5446 494d #QqVTFIM
grep -obUa 'INICIO' ii-sen.ir
xxd -s $((2074229 - 16)) -l 32 ii-sen.ir
001fa665: dd7b dfba f75e f7ee bdd7 bdfb af75 ffd9 .{...^.......u..
001fa675: 494e 4943 494f 3d3d 2323 2323 2323 2323 INICIO==########
FF D9 is the JPEG end-of-image
marker, and INICIO starts right
after it. Image viewers stop reading at
FF D9, so the picture opens like
any normal photo while about 1.2 million characters ride along
behind it. Joe calls it "steganography," but strictly speaking it's
data appended after the end of the image.
The last characters before FIM are
QqVT. Reversed, that's
TVqQ, which is how a base64-encoded
MZ header starts. Reversed base64
of a Windows executable.
First try: close, but wrong
Stage 3 swapped * for
A, so I guessed
# →
A. That gave 900,306 bytes starting
with MZ, and the DOS stub text was
even there. But file only said
"MS-DOS executable," and the header was mangled:
| Normal PE | My first decode | |
|---|---|---|
| Byte 0x04 | 03 |
03 shows up at 0x07 |
| Byte 0x08 | 04 |
04 shows up at 0x11 |
| e_lfanew (0x3C) | offset to PE\0\0 |
00 00 00 00 |
| DOS stub | starts at 0x40 | starts at 0xAC |
The right bytes were there, spread apart by extra zeros. In base64,
every A is 6 zero bits, so too many
As means too many zeros. Lesson: an
MZ at the start doesn't mean you
decoded a PE correctly. Check for
PE\0\0 at the offset stored at
0x3C.
Letting the PE header decide
Instead of guessing again, I used Claude to write a small script
that tries every likely substitution for
# and keeps whichever one produces
a real PE header. A correct decode has to have
PE\0\0 at the offset stored at
0x3C, so the header settles it.
#!/usr/bin/env python3
# Try candidate decodings of the INICIO...FIM blob; report which one yields a valid PE.
# usage: test_jpg_decode.py <image>
import base64
import collections
import re
import struct
import sys
raw = open(sys.argv[1], "rb").read()
s, e = raw.find(b"INICIO"), raw.rfind(b"FIM")
blob = raw[s + len(b"INICIO"):e].strip()[::-1] # reversed
cnt = collections.Counter(blob)
print(f"[*] chars: {len(blob)}, '#': {cnt[ord('#')]}, 'A': {cnt[ord('A')]}")
runs = collections.Counter(len(m) for m in re.findall(rb"#+", blob))
print(f"[*] '#' run lengths (length: count), top 10: {runs.most_common(10)}")
def check(name, b64):
try:
data = base64.b64decode(b64, validate=True)
except Exception as ex:
print(f"[-] {name}: base64 failed ({ex})")
return
valid = "no"
if data[:2] == b"MZ" and len(data) > 0x40:
off = struct.unpack_from("<I", data, 0x3C)[0]
if off + 4 <= len(data) and data[off:off + 4] == b"PE\0\0":
valid = f"yes, PE header at 0x{off:x}"
with open("stage5.bin", "wb") as f:
f.write(data)
print(f"[+] {name}: {len(data)} bytes, MZ={data[:2] == b'MZ'}, valid PE: {valid}")
cands = {"hash_to_A": blob.replace(b"#", b"A"),
"hash_removed": blob.replace(b"#", b"")}
for n in (2, 3, 4):
cands[f"{n}hash_to_A"] = blob.replace(b"#" * n, b"A")
for name, b in cands.items():
check(name, b)
[*] chars: 1200410, '#': 480675, 'A': 0
[*] '#' run lengths (length: count), top 10: [(3, 39804), (6, 11556), (9, 6002), (12, 5500), (18, 1278), (27, 1099), (24, 664), (15, 660), (21, 350), (30, 172)]
[+] hash_to_A: 900306 bytes, MZ=True, valid PE: no
[-] hash_removed: base64 failed (Invalid base64-encoded string: number of data characters (719733) cannot be 1 more than a multiple of 4)
[-] 2hash_to_A: base64 failed (Only base64 data is allowed)
[+] 3hash_to_A: 659968 bytes, MZ=True, valid PE: yes, PE header at 0x108
[-] 4hash_to_A: base64 failed (Only base64 data is allowed)
-
Zero literal
A's in the blob -
480,675
#characters, which divides evenly by 3 - Every common run length is a multiple of 3 (3, 6, 9, ... 30)
-
Only
###→Aproduces a valid PE: 659,968 bytes,PE\0\0at0x108
The encoding:
reverse the string, and write every
A as
###.
8. Finally: Remcos
file stage5.bin
sha256sum stage5.bin
diec stage5.bin
strings -n 8 stage5.bin | grep -i -E 'remcos|rmc-|watchdog|keylog|settings' | head -20
stage5.bin: PE32+ executable (GUI) x86-64, for MS Windows, 6 sections
2afde2e56560a21ce3f4646081e638b55cd43aa3189cbd8ea515a9e13d8b0dca stage5.bin
PE64
Linker: Microsoft Linker(14.16.27054)
Compiler: Microsoft Visual C/C++(19.16.27054)[LTCG/C++]
Tool: Microsoft Visual Studio(2017, 15.9)
Offline Keylogger Started
Online Keylogger Started
Remcos Agent initialized (
Remcos restarted by watchdog!
Watchdog module activated
SETTINGS
Remcos v
- 64-bit Windows GUI executable, built with Visual Studio 2017. Native C++, not .NET.
-
Remcos strings everywhere, including
Remcos restarted by watchdog!, the exact string Joe's YARA rule matched on the PE injected intoCasPol.exe -
SHA256
2afde2e56560a21ce3f4646081e638b55cd43aa3189cbd8ea515a9e13d8b0dcahad no detections or public submissions on VirusTotal or ANY.RUN at the time of writing. Only the JPEG travels over the network, and the PE only exists once it's decoded.
Side note: in the broken first decode,
strings showed lines like
WATAUAVAWH and
A_A^A]A\_. Those are x64 machine
code: 57 41 54 41 55 41 56 41 57 is
push rdi; push r12; push r13; push r14; push r15, a function prologue, and the
A_A^... lines are the matching
pops. That was the first hint of
native code before diec confirmed
it.
Pulling the config
SETTINGS is the name of a resource
inside the binary. Public Remcos research describes it as
RC4-encrypted, with the first byte giving the key length and the key
right after. REMnux didn't have
pefile, and I wasn't reconnecting
the box to install it, so I parsed the resource table by hand (and
by I, I mean Claude made the python script):
#!/usr/bin/env python3
# Dependency-free: find the SETTINGS resource in a PE, then try RC4 with a key-length-prefixed key.
# usage: remcos_cfg.py <pe>
import struct
import sys
data = open(sys.argv[1], "rb").read()
def u16(o):
return struct.unpack_from("<H", data, o)[0]
def u32(o):
return struct.unpack_from("<I", data, o)[0]
# PE headers
pe = u32(0x3C)
if data[pe:pe + 4] != b"PE\0\0":
sys.exit("[!] no PE header")
nsec = u16(pe + 6)
opt_size = u16(pe + 20)
opt = pe + 24
magic = u16(opt)
dd = opt + (112 if magic == 0x20B else 96) # data directories (PE32+ vs PE32)
res_rva = u32(dd + 2 * 8) # directory index 2 = resources
# Section table, for RVA -> file offset
secs = []
for i in range(nsec):
s = opt + opt_size + i * 40
vsize, va, rsize, rptr = u32(s + 8), u32(s + 12), u32(s + 16), u32(s + 20)
secs.append((va, max(vsize, rsize), rptr))
def rva2off(rva):
for va, size, rptr in secs:
if va <= rva < va + size:
return rva - va + rptr
sys.exit(f"[!] RVA 0x{rva:x} not in any section")
base = rva2off(res_rva)
def entries(off):
n = u16(off + 12) + u16(off + 14) # named + ID entries
for i in range(n):
e = off + 16 + i * 8
yield u32(e), u32(e + 4)
def name_of(nid):
if nid & 0x80000000: # high bit set = name string
o = base + (nid & 0x7FFFFFFF)
ln = u16(o)
return data[o + 2:o + 2 + ln * 2].decode("utf-16-le")
return nid
# Walk type -> name -> language
found = None
for t_id, t_off in entries(base):
if not t_off & 0x80000000:
continue
for n_id, n_off in entries(base + (t_off & 0x7FFFFFFF)):
if name_of(n_id) != "SETTINGS" or not n_off & 0x80000000:
continue
for l_id, l_off in entries(base + (n_off & 0x7FFFFFFF)):
d = base + (l_off & 0x7FFFFFFF)
rva, size = u32(d), u32(d + 4)
off = rva2off(rva)
found = data[off:off + size]
print(f"[*] SETTINGS: resource type {name_of(t_id)}, lang {l_id}, {size} bytes")
if found is None:
sys.exit("[!] SETTINGS resource not found")
def rc4(key, buf):
s = list(range(256))
j = 0
for i in range(256):
j = (j + s[i] + key[i % len(key)]) % 256
s[i], s[j] = s[j], s[i]
i = j = 0
out = bytearray()
for b in buf:
i = (i + 1) % 256
j = (j + s[i]) % 256
s[i], s[j] = s[j], s[i]
out.append(b ^ s[(s[i] + s[j]) % 256])
return bytes(out)
klen = found[0]
key = found[1:1 + klen]
print(f"[*] key length byte: {klen}, key (hex): {key.hex()}")
cfg = rc4(key, found[1 + klen:])
print(f"[*] decrypted (first 400 bytes, repr):\n{cfg[:400]!r}")
with open("remcos_config.bin", "wb") as f:
f.write(cfg)
print("[+] full output written to remcos_config.bin")
python3 -I ~/scripts/remcos_cfg.py stage5.bin
[*] SETTINGS: resource type 10, lang 0, 570 bytes
[*] key length byte: 71, key (hex): 821c16ad1f55eae02106e49e0d5c8b37...
[*] decrypted (first 400 bytes, repr):
b'winne[.]mynetav[.]net:2734:0\x1e|\x1e\x1e\x1f|winto|\x1e\x1e\x1f|1|...|Rmc-SUNBKC|...'
Resource type 10 is RT_RCDATA, the
standard Windows type for raw data. The key is 71 bytes, and the
fields are separated by
|\x1e\x1e\x1f|. Rather than trust
the method blindly, I checked the output against the config Joe
pulled from memory during its live run:
| Joe field | Value | In my decrypt |
|---|---|---|
| Host:Port:Password | winne[.]mynetav[.]net:2734:0 |
Yes, first field |
| Assigned name | winto |
Yes |
| Copy file | remcos.exe |
Yes (UTF-16) |
| Mutex | Rmc-SUNBKC |
Yes |
| Keylog file | logs.dat |
Yes (UTF-16) |
| Screenshot file | Screenshots |
Yes |
| Audio folder | MicRecords |
Yes |
I only mapped fields that match Joe's strings one to one.
What's still open
-
The .NET loader from
/prxyb. It only ever exists in memory, and unfortunately none of the reports I had included it. -
The 12 base64
vtarguments. Without the loader, anything I said about them would be a guess.
IOCs
| Type | Value | Note |
|---|---|---|
| C2 | winne[.]mynetav[.]net:2734 |
From the decrypted config |
| Mutex | Rmc-SUNBKC |
From the decrypted config |
| SHA256 (JS lure) |
38fef8dc1fab96cb08a27bebc4e85a022308371e15c7a131e27b491cd679dc90
|
Japanese salary lure |
| SHA256 (sister sample) |
906b78d823d1dc2b3283672e86ba5eb68e1b9c8c75dfe2a0b9d14579f9e52302
|
Russian salary lure, .pdf.zip |
| SHA256 (dropped PowerShell) |
b94b3efa333e41c846b01a0a65a0c72a5e756e3b44bed78179ae2a577f1ec47d
|
Stage 3, verified against Triage |
| SHA256 (JPEG) |
9912ca6dce79a65c49eb55f751759d426ded522f93d33358f2228f2c6270b321
|
Remcos appended after FF D9 |
| SHA256 (Remcos, carved) |
2afde2e56560a21ce3f4646081e638b55cd43aa3189cbd8ea515a9e13d8b0dca
|
Memory only in the wild |
| URL |
hxxps://royal-wood-3c0d[.]julianosilvasantospiresrosa[.]workers[.]dev/prxyb
|
.NET loader download |
| URL |
hxxps://ii-sen[.]ir/nv/payload_113212[.]png
|
JPEG download |
| IP | 103.215.222[.]13 |
Hosts ii-sen[.]ir (AS48551) |
| Drop path | %TEMP%\rad*.tmp.ps1 |
Written by stage 2, deleted after launch |
| Behavior |
powershell.exe -WindowStyle Hidden -ExecutionPolicy
Bypass
with parent wmiprvse.exe
|
WMI launch from stage 2 |
| String | j3eevZqDRSH5I1 |
Layer 1 XOR key |
| String | GsNSDQHMEC1ccZ |
Stage 2 XOR key |
| String | -INICIO- / -FIM- |
Markers in the /prxyb response |
| String | INICIO / FIM |
Markers in the JPEG |
| String | vt |
.NET method invoked by stage 3 |
Detection ideas
-
wscript.execreating%TEMP%\rad*.tmp.ps1 -
wmiprvse.exespawningpowershell.exewith-WindowStyle Hidden -ExecutionPolicy Bypass -
A PowerShell command line that runs a script and then
Remove-Items that same script -
powershell.exemaking requests to*.workers[.]dev, or downloading an image fromii-sen[.]ir -
powershell.exespawningCasPol.exe(per Joe's process tree) -
DNS lookups for
winne[.]mynetav[.]net - The mutex
Rmc-SUNBKC -
A JPEG with
INICIOright after itsFF D9end-of-image marker (easy YARA territory)
Overall purpose
This is a multi-stage Remcos delivery chain behind a salary-themed
lure, seen in Japanese and Russian versions on the same
infrastructure. A padded JavaScript file XOR-decodes a dropper,
which writes a PowerShell loader to
%TEMP% and launches it hidden
through WMI. The loader pulls a .NET assembly from a Cloudflare
Workers URL into memory, and per Joe Sandbox, that stage fetches a
JPEG from ii-sen[.]ir and injects
the Remcos binary appended to it into
CasPol.exe. Remcos then reports to
winne[.]mynetav[.]net:2734.
Key takeaways
- Static work recovered every stage except the in-memory .NET loader, and each one was checked against an independent source or a structural check: Triage's dropped file, a PE structure check, and Joe's config.
- When your own sandbox run stalls, other people's runs of the same infrastructure can fill the gap. The JPEG came from someone else's ANY.RUN task.
-
An
MZat the start doesn't mean a correct decode. Check the PE header. -
When cleaning hex out of code, the code's own keywords (
var,concat) can pass as hex. - Hosting location isn't attribution. The payload sat on an Iranian domain, and the builder comments are in Portuguese.