Modern cybercrime ecosystems have shifted decisively from crude credential harvesting to automated session hijacking. Commodity information stealers—predominantly Lumma, Stealc, Meduza, and RedLine—target pre-authenticated session tokens, authentication cookies, and desktop communication state files. By capturing these cryptographic artifacts directly from local storage, adversaries circumvent multi-factor authentication (MFA), hardware security keys (FIDO2/WebAuthn), and password complexity policies without triggering typical login anomaly detection alerts.
Among the highest-value targets on developer and enterprise workstations are desktop messaging clients—specifically Telegram Desktop and Discord—alongside Chromium-based browser credential vaults. Once executed on an endpoint, an infostealer completes its discovery, extraction, and Command-and-Control (C2) exfiltration cycle in less than twenty seconds. Neutralizing this threat requires looking beyond host-based antivirus scanners toward strict egress network confinement and transport-layer firewall isolation.
+-------------------------------------------------------------------------------+
| INFOSTEALER ATTACK & EXFILTRATION CHAIN |
| |
| Target Endpoint Workstation |
| +------------------------------------+ +------------------------------+ |
| | Telegram Desktop | | Discord App / Chromium | |
| | %APPDATA%\Telegram Desktop\tdata | | leveldb Session Tokens | |
| +-----------------+------------------+ +--------------+---------------+ |
| | | |
| +------------------+------------------+ |
| | Memory Read / File Copy |
| v |
| +---------------------------------+ |
| | Infostealer Process (Lumma/etc) | |
| | In-Memory AES Archive Packaging | |
| +----------------+----------------+ |
| | |
| +---------------------------+---------------------------+ |
| | Unchecked Outbound Flow | Blocked |
| v v |
| +----------------------------------+ +-----------------------+ |
| | Raw Physical Interface (wlan/eth)| | RiceGuard L3 Firewall | |
| | Direct HTTPS POST to C2 Domain | | Drops Rogue Egress | |
| +----------------+-----------------+ +-----------+-----------+ |
| | | |
| v v |
| Adversary C2 Server / Dropper Exfiltration Neutralized |
+-------------------------------------------------------------------------------+
Anatomy of Desktop Session Extraction
Unlike web browsers that isolate state within origin-bound sandbox boundaries, desktop messaging applications prioritize low-latency access and persistent offline state. Infostealers exploit these storage paradigms through programmatic scraping of well-known directory structures.
1. Telegram Desktop tdata Directory Hijacking
Telegram Desktop maintains its entire session state inside the %APPDATA%\Telegram Desktop\tdata folder on Windows (or ~/.local/share/TelegramDesktop/tdata on Linux). This folder contains:
- Map Files (
D87FBAC6010684EDprefix): Binary configuration maps storing encrypted references to active user accounts. - Key Data Files: Encrypted local database files storing the user's
auth_key(the 2048-bit shared secret established with Telegram MTProto data centers). - Session Cache: Cached server configurations, peer information, and local media indices.
When an infostealer infects a host, it does not attempt to decrypt the user's master passcode in memory. Instead, it copies the specific D87FBAC6010684ED map files along with active session subdirectories (user_data and numbered session caches).
Once these raw binary files are transferred to the adversary's machine, the threat actor places them into a clean Telegram Desktop installation. The desktop client parses the valid auth_key directly from disk and opens the target account instantly, granting the attacker complete access to private communications, administrative channels, and active bot authorization tokens without triggering an SMS or secondary push notification.
2. Discord Token Extraction from LevelDB Datastores
Discord's desktop client is built on the Electron framework, storing user state within Chromium-derived LevelDB key-value stores located at %APPDATA%\discord\Local Storage\leveldb.
Infostealers target .ldb and .log files in this directory, executing regex matching patterns designed to extract base64-encoded user tokens:
# Conceptual representation of token regex extraction pattern
DISCORD_TOKEN_REGEX = r"[\w-]{24}\.[\w-]{6}\.[\w-]{27}|mfa\.[\w-]{84}"
In newer Discord desktop versions, tokens are encrypted using Windows Data Protection API (DPAPI) and stored alongside a master key in %APPDATA%\discord\Local State. Infostealers invoke CryptUnprotectData via local process execution, decrypt the AES-GCM master key, and decipher stored session tokens. The exfiltrated token allows immediate authentication against Discord's REST API (https://discord.com/api/v9/users/@me) via automated HTTP header injection:
GET /api/v9/users/@me HTTP/1.1
Host: discord.com
Authorization: <EXTRACTED_SESSION_TOKEN>
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64)
The Network Exfiltration Layer: Command-and-Control (C2)
Once credentials, session files, and browser cookies are harvested, the malware bundles the files into an in-memory ZIP or RAR archive. The critical phase of the attack lifecycle is egress transmission across the network perimeter.
+-----------------------------------------------------------------------------+
| COMMON C2 EXFILTRATION PATHWAYS |
| |
| Harvested Host Data |
| [Tokens, Cookies, tdata] |
| | |
| | Pathway A: Direct HTTPS POST to Bulletproof C2 Hosts |
| +----------------------------------------------------> [Rogue IP] |
| | High-frequency DNS queries for fast-flux domains | TCP/443 |
| | |
| | Pathway B: Abusing Legitimate API Webhooks |
| +----------------------------------------------------> [Discord API]|
| | POST https://discord.com/api/webhooks/... | Webhook URL |
| | |
| | Pathway C: Telegram Bot API Exfiltration |
| +----------------------------------------------------> [Telegram C2]|
| POST https://api.telegram.org/bot<token>/sendDocument |
| |
+-----------------------------------------------------------------------------+
Fast-Flux Domains and Cloud Infrastructure Abuse
Infostealers utilize diverse network techniques to ensure payload delivery reaches operators before host defenses intervene:
- Bulletproof Web Hosting & Fast-Flux IP Rotation: Malware families like Lumma utilize Domain Generation Algorithms (DGA) or query public blockchain smart contracts (e.g., Binance Smart Chain or TON) to retrieve active C2 IP endpoints, frustrating static IP blacklists.
- Legitimate Webhook Exploitation: Threat actors frequently leverage Discord webhooks or Telegram Bot API endpoints (
sendDocument) to exfiltrate compressed archives. Because traffic routes to legitimate cloud domains (discord.comortelegram.org), generic enterprise egress filters often permit the connection without inspection. - Encrypted TLS Payload Masquerading: Exfiltration payloads are transmitted inside standard TLS sessions, frequently utilizing custom HTTP headers or appended junk bytes to defeat basic signature matching in deep packet inspection appliances.
Architectural Defense: Egress Containment with RiceGuard Layer 3
Endpoint detection and response (EDR) software often experiences telemetry latency or evasion when malware executes via dynamic in-memory loading. An uncompromised network boundary provides a deterministic defensive choke point: if the infostealer cannot establish outbound network egress to its C2 receiver, the session theft fails completely.
+-------------------------------------------------------------------------------+
| RICEGUARD NETWORK EGRESS DEFENSE |
| |
| Host Operating System Applications |
| +-------------------+ +--------------------+ +------------------------+ |
| | Desktop Messengers| | Infostealer Task | | Authorized Browsers | |
| +---------+---------+ +---------+----------+ +-----------+------------+ |
| | | | |
| | Socket Request | Socket Request | Socket Request |
| v v v |
| Kernel Netfilter / Egress Policy Table |
| +-----------------------------------------------------------------------+ |
| | 1. Interface Confinement: All traffic bound to virtual tun0 | |
| | 2. Threat Intelligence DNS Sinkhole: Null-route known C2 DGAs | |
| | 3. Outbound Rate Limiting: Trap sudden bulk binary exfiltration bursts| |
| | 4. Strict Port Isolation: Block unencapsulated direct IP egress | |
| +-----------------------------------+-----------------------------------+ |
| | |
| v |
| +-------------------------------+ |
| | Encrypted Virtual Tunnel tun0 | |
| +---------------+---------------+ |
| | ChaCha20-Poly1305 |
| v |
| +-------------------------------+ |
| | Secure VPN Gateway Perimeter | |
| +-------------------------------+ |
| | |
| +--------------+--------------+ |
| | | |
| v v |
| Verified Legitimate Services Blocked C2 Exfiltration Burst |
+-------------------------------------------------------------------------------+
1. Mandatory Tunnel Binding and Direct Interface Blocking
The most effective barrier against infostealer exfiltration is stripping applications of the ability to communicate directly over unmonitored physical network adapters. By establishing a default-drop policy on physical interfaces (eth0, wlan0) for non-VPN processes, any rogue executable attempting direct socket connections to raw C2 IP addresses is blocked at the kernel packet scheduler:
# Example Linux iptables egress lockdown rule set
# Allow traffic only through virtual tunnel interface tun0 and local loopback
iptables -A OUTPUT -o lo -j ACCEPT
iptables -A OUTPUT -o tun0 -j ACCEPT
# Allow tunnel handshake packets to reach designated VPN gateway endpoints only
iptables -A OUTPUT -p udp -d 198.51.100.10 --dport 51820 -o eth0 -j ACCEPT
# Reject all other outbound traffic on physical interfaces
iptables -A OUTPUT -o eth0 -j REJECT --reject-with icmp-admin-prohibited
iptables -A OUTPUT -o wlan0 -j REJECT --reject-with icmp-admin-prohibited
When an infostealer attempts to connect to dynamic C2 servers or resolve rogue hostnames directly through local network gateways, the operating system drops the SYN packet, rendering the malware inert.
2. DNS-over-HTTPS Threat Intelligence Filtering
Because infostealers rely heavily on rapid DNS resolution to locate active staging servers, routing DNS traffic through an authenticated, threat-aware resolver operating over DNS-over-HTTPS (DoH) inside the RiceGuard tunnel halts exfiltration before transport sockets open:
- DGA and Fast-Flux Neutralization: Malicious domains flagged by real-time threat feeds are sinkholed to
0.0.0.0, depriving the stealer of a valid IP destination. - Anti-Webhook Inspection: Enterprise gateway policies can selectively restrict outbound API calls targeting
/api/webhooks/endpoints to authorized service accounts, preventing generic webhook exfiltration.
Verifying Egress Security and Session Protection
Security practitioners can assess workstation vulnerability to session harvesting through targeted auditing procedures.
Testing Outbound Socket Leakage
To verify whether local processes can establish unencapsulated outbound connections to external hosts, run an egress test against an external listener while monitoring physical adapters:
# Attempt direct TCP connection outside the VPN tunnel interface
curl --interface eth0 --connect-timeout 5 https://1.1.1.1
A properly configured workstation enforcing zero-leak isolation will return an immediate route unreachable or connection timeout error, confirming that non-tunneled traffic cannot egress the machine.
Defensive Posture Comparison
| Attack Vector | Unprotected Workstation | Standard Consumer VPN | RiceGuard L3 Egress Firewall |
|---|---|---|---|
Telegram tdata Theft |
Harvested & Exfiltrated | Harvested & Exfiltrated | Exfiltration Path Blocked |
| Discord Token Scraping | Harvested & Exfiltrated | Harvested & Exfiltrated | C2 Egress Dropped by Kernel |
| Fast-Flux C2 Contact | Successful Connection | Routed Through Tunnel | DNS Sinkholed at Gateway |
| Direct Physical Egress | Permitted by OS | Often Leaks During Drops | Denied by Default-Drop Rules |
| Encrypted Webhook Abuse | Allowed Outbound | Allowed Outbound | Inspected & Filtered |
Practical Hardening Recommendations
- Activate Telegram Two-Step Verification (Cloud Password): Enforce a master cloud password on Telegram accounts. While local session theft grants immediate access to existing chats, critical administrative actions and session terminations require the cloud password.
- Apply Operating System Token Protection: On Windows workstations, utilize updated Chromium versions supporting App-Bound Encryption, which binds cryptographic cookie keys to service identities rather than standard user-space tokens.
- Deploy Strict Egress Firewall Policies: Bind desktop client traffic strictly to secure virtual tunnel adapters, ensuring that unapproved background binaries cannot establish out-of-band network connections.
- Audit Active Desktop Sessions Regularly: In Telegram (
Settings > Devices) and Discord (User Settings > Authorized Apps / Devices), review active sessions weekly and terminate unrecognized endpoints immediately.
Session hijacking infostealers represent a sophisticated evolution in threat actor tactics. Combining application-layer credential safeguards with kernel-enforced egress firewall routing ensures that even if malicious code executes locally, sensitive communication state remains firmly contained within your defense perimeter.



