b4c2.ai

One Inject, Fifty Shops: Hunting a Magecart-Style VM Kit by Its Packer, Not Its C2

·b4c2 Research·5 min read
#Magecart#Web Skimmer#Threat Hunting#JavaScript VM

Why chasing the domain would have left us one rotation behind.

It started with one C2. A compromised site, which we’ll call the victim, was serving an inline <script> next to its normal content. Nothing fancy on the surface: about 90 KB of packed JavaScript. No readable domain, no obvious “skimmer” strings. If you grepped it for a C2, there was nothing.

That’s intentional. The script is a small virtual machine. The real logic sits inside encoded blobs and is only decoded at runtime, so the network address you’d most want to block isn’t in the file at all.

This post covers how we went from that single file to a campaign spanning more than fifty online shops, and why the most useful thing we found wasn’t a domain.

First Clue: The Network, Not the Code

Because the C2 wasn’t in the source, we went to the traffic instead. The urlscan HTTP log for the victim page showed the browser pulling a second-stage script from b8t[.]shop, named after the victim itself.

So we had one C2. The obvious move was to block it, write it up, and close the ticket.

But C2 domains are the cheapest thing an attacker owns. They rotate them all the time. If all we tracked was b8t[.]shop, we’d catch this victim and miss everything that came next.

Second Clue: The Packer Never Changes

So we turned back to the code and asked a different question. Instead of “where does it phone home?”, we asked “what does this script always look like before it decodes anything?”

The answer was right at the start of the script:

let vml =
    typeof globalThis !== 'undefined'
      ? globalThis
      : typeof window !== 'undefined'
        ? window
        : global,
  vmb_824a8b = vml['vmb_824a8b'] || (vml['vmb_824a8b'] = {});
const vmp_740442 = (function () {
  /* ... */
})();

Further down were seven encoded blobs, all starting with the same prefix, WsF5..., plus a short key blob, RNNZTGQGOjw=. At the end of the file, wrappers hooked fetch and document. Those two are exactly what you’d grab if you wanted to watch a checkout page.

Then there was the fingerprint function:

function ms() {
  var vo = 0x3f438e17;
  vo ^= Array.prototype.slice.length << 0x18;
  /* ... */
  Math.imul(vo, 0xf389a8a7);
  Math.imul(vo, 0xaf1ed7f3);
}

That bootstrap, plus a few other quirks, stays stable across builds. We found a namespace object shaped like vm?_xxxxxx (the letters rotate, the pattern doesn’t), a fingerprint based on Array.prototype.slice.length, Object.defineProperty wraps around fetch and document, and a new.target entry point at the tail. The encoded blobs also start with a fixed prefix that works like a compiler version stamp.

None of these is a C2, and all of them survive a C2 rotation. That’s what we hunted on.

Here is how the pivot played out:

Pivot from Wave A to Wave B using shared packer structure

Constant bootstrap markers across waves: globalThis check, vm?_xxxxxx namespace, and defineProperty wraps

Another researcher asked: “OK, I get that the adventure for you is preparing the search, but the real question is where to search.”

Our answer: be creative. Google dorks are your friends, but so is urlscan. Most people treat urlscan as use-and-forget, so going back through what others have already scanned is a real treasure trove.

Collaborating researchers went further into source-code indexers like PublicWWW and infrastructure search engines like FOFA, uncovering additional confirmed victims that had not been identified before.

What the Skimmer Actually Does

Once the VM boots on a checkout page, it plays the classic Magecart game quietly:

  1. It checks it’s running in a real browser, using native function lengths and a few math constants to spot rewritten or headless environments.
  2. It wraps fetch, document, and (in Wave B) FormData, so checkout traffic passes through its hands.
  3. It waits for payment-form events.
  4. When one fires, it collects name, card number, expiry, CVV, and billing details, then posts them to the C2.

The purchase still goes through, and nothing on the page changes. The kit even disguises its wrappers, so a quick look at fetch in the console still reports it as native code.

The Catch: Not Everything With This Packer Is Malware

This is the part we think matters most for other hunters. The bootstrap is a shared JavaScript VM packer, not a malware signature. Our hunt also caught plenty of harmless or merely odd uses of it: packed storefront apps, map widgets, teaching quizzes hosted on Netlify, Google Apps Script glue, and a Tencent Cloud loader that we’re still tracking separately.

That noise isn’t wasted. It tells us what the skimmer is trying to blend in with, and it helps us tune our scoring. We ended up with a simple ladder:

Scoring ladder separating benign VM-packed scripts from Magecart skimmer payloads

The packer gets you into the right neighborhood. The payload markers tell you which house.

Here is the scoring example from scanning the two additional victims found via code search:

Scoring breakdown matching all 15 markers to confirm Wave B skimmer injection

Both matched all markers at the maximum score of 15, confirming Wave B injection.

Takeaways

If we had tracked b8t[.]shop, we would have missed Wave B completely. If we only track js-static[.]com now, we’ll miss the next rotation. The attacker can change the C2 in minutes. Their tooling is much harder to change, and that’s where the lasting signal lives.

So when you find a skimmer, save the raw inject before you decode anything, and ask what about it is boring and repeatable. Hunt on that.

Indicators of Compromise (IOCs)

  • hxxps://js-static[.]com/rbm — Wave B exfil / second stage
  • hxxps://b8t[.]shop/<victim> — Wave A second stage
  • Wave A markers: vmb_824a8b, vmp_740442, blob prefix WsF5
  • Wave B markers: vmw_4751ac, vmm_695618, blob prefix 5JGejk17

This pivot contributed to the broader investigation published at Gambit Security.