eSentire’s Threat Response Unit (TRU) has uncovered a previously undocumented device-code phishing kit, dubbed “GhostCode,” that abuses Microsoft’s OAuth 2.0 device authorization grant flow to hijack M365 accounts, mint Primary Refresh Tokens (PRTs), and silently enroll rogue devices all within roughly 78 seconds of a victim completing MFA.
GhostCode M365 Tokens
The campaign, first observed in late August 2026, begins with social engineering rather than malware.
Threat actors posed as a procurement officer for BJ’s Wholesale Club and submitted a benign inquiry through a target company’s Salesforce contact form, using a 15-day-old lookalike domain, bjssourcing[.]com.
TRU identified over 30 similar impersonation domains registered in August 2026 targeting distributors, manufacturers, and warehousing firms, suggesting a broader BEC-style campaign.
After the sales team responded, the attackers followed up with an “NDA” pretext and a WeTransfer link to a password-gated HTML file (“3arhCt9c0p.html”) disguised as a “FlipBook” document viewer.
This lure employs three evasion layers: junk padding that inflates file size and defeats similarity hashing; character-level HTML comment injection between every letter to break regex and NLP-based phishing classifiers; and an AES-256-GCM encrypted redirect URL whose decryption key is derived client-side via PBKDF2-HMAC-SHA256 from the attacker-supplied password, keeping the destination hidden from sandboxes and DNS logs until the victim enters it.

According to the threat research published by eSentire, once decrypted, the redirect passes through a JavaScript bot-filtering challenge and a Cloudflare Turnstile gate complete with a user-agent blocklist rejecting strings like “bot,” “curl,” and “python” before reaching an AI-generated device-code phishing page hosted on a compromised chiropractic clinic’s subdomain.
The kit’s backend impersonates Microsoft’s Authentication Broker app (client ID 29d9ed98-a469-4536-ade2-f981bc1d605e), requests a device code from login.microsoftonline.com, and injects the resulting user_code into the phishing page for the victim to enter on Microsoft’s legitimate sign-in portal.
Crucially, the kit also queries a geolocation API and routes traffic through FlashProxy[.]io residential proxies matching the victim’s country, defeating Conditional Access “impossible travel” checks.

Once the victim completes sign-in and MFA, token abuse began just five seconds later. Within 78 seconds, attackers registered three Azure AD devices, enrolled one in Intune, and obtained a Primary Refresh Token granting SSO-equivalent access to the entire M365 tenant for up to 14 days.
Every request rotated through fresh UK residential IPs, with one German IP tied to ASN 12586 (GHOSTnet GmbH), which gave the kit its name alongside the obfuscated HTML code.
TRU notes MFA provides no protection here since the stolen token carries the MFA claim forward, and enrolled Intune devices persist even after token revocation.
Recommended defenses include disabling device-code authentication via Conditional Access for all but essential accounts, enforcing MDM-based device compliance, and monitoring for python-requests user agents combined with rapid, multi-device registrations from a single sign-in session.
eSentire published a KQL hunting query joining device-code sign-ins with subsequent python-requests activity within a 10-minute window to help defenders detect similar intrusions.