Post

How Crypto Mining Malware Hijacks Your Resources: A Reversing Perspective

How Crypto Mining Malware Hijacks Your Resources: A Reversing Perspective

Introduction

Cryptocurrency mining malware is one of the most stealthy and profitable threats in the wild. Unlike ransomware, it doesn’t announce its presence—it silently hijacks your CPU/GPU cycles, drains resources, and lines the pockets of its operators. In this post, I’ll walk you through how these miners operate from a reverse engineer’s perspective, leveraging tools like x64dbg, IDA Pro, Process Monitor, and Regshot to reveal what’s happening under the hood.


How Mining Malware Works

Crypto mining malware usually doesn’t reinvent the wheel—it often relies on legitimate open-source tools like xmrig, but modified to run covertly on infected machines.

Common Traits:

  • Silent execution in the background without user interaction.
  • High CPU usage, often throttled or delayed to avoid suspicion.
  • Persistence mechanisms to ensure re-execution after reboot.
  • Communication with mining pools (often over stratum+tcp).

Key Indicators to Look For

Strings & Signatures

Using tools like Strings64, one of the first indicators you’ll notice are hardcoded mining algorithms (e.g., cryptonight, rx/0, argon2, etc.) or pool URLs.

Example:

1
2
3
4
5
6
cryptonight
randomx
cn-lite
cn-heavy
stratum+tcp://pool.hashvault.pro:80
rig-id

These signatures are a dead giveaway if you catch them early in the binary.

Configuration Files

Most mining malware leverages JSON configuration files.

Look for:

1
2
3
4
5
6
7
8
9
10
11
12
{
  "algo": "rx/0",
  "pools": [
    {
      "url": "pool.hashvault.pro:80",
      "user": "8BGU1iynUuB9EQ2p9UmVvF8hmA8BG76T4iUuL3FTAJHkUeJW2WcPswabnfc1FmwDw52KWEqDX2foHNcqdBVvXAxnVcihF9D",
      "pass": "PbOD",
      "keepalive": true
    }
  ],
  "mode": "fast"
}

Paths tried:

  • C:\Users\Student\.config\xmrig.json
  • C:\Users\Student\.xmrig.json

How It Persists and Hides

Persistence Mechanisms

Using Regshot or Process Monitor, you’ll often find:

  • Registry keys added to HKCU\Software\Microsoft\Windows\CurrentVersion\Run
  • BAM (Background Activity Moderator) edits
  • Suppressed crash reporting
1
reg add "HKCU\...\Run" /v svchost /t REG_SZ /d "C:\Users\Public\miner.exe"

Obfuscation Techniques

  • Packed with UPX
  • Dynamic import resolution via LoadLibraryA, GetProcAddress
  • TLS Callbacks
  • DLLs used: ADVAPI32.dll, CRYPT32.dll, IPHLPAPI.dll, ole32.dll, WS2_32.dll

Runtime Behavior & Network Communication

Process Monitor + x64dbg

  • Connects to: pool.hashvault.pro, IPs 142.202.242.43, 142.202.242.45
  • Port: 80
  • Behavior:
    • JSON config attempts
    • DNS + TTL communication
    • Receives jobs, allocates memory

Example:

call    dword ptr [eax+InternetOpenUrlA]
mov     ecx, offset aXmrig_6221_dev ; "XMRig/6.22.1-dev"

Profiling Behavior

  • High CPU usage (1000 threads, 2048KB scratchpad)
  • Allocated ~2336 MB for RandomX dataset

Defensive Techniques: Detecting & Responding to Mining Malware

Memory & API Behavior Monitoring

  • Alert on non-standard use of VirtualAlloc/VirtualProtect: Configure EDR to flag memory pages transitioning from RW to RX by untrusted or unsigned processes.
  • Enable Sysmon with Event ID 10: Tracks process access to memory, ideal for catching miners dynamically allocating for execution.

Manual PE Mapping Detection

Real-Time Response

  • Correlate process activity with network traffic: Monitor outbound traffic to common mining pools and pair with high CPU time processes.
  • Snapshot suspicious processes: If a miner is detected, dump memory, enumerate loaded DLLs, and capture network sockets for forensic review.
  • Sysmon with custom configuration rules
  • EDR solutions with memory anomaly detection
  • PE-sieve, Process Hacker, HollowsHunter, Wireshark, and ELK stack for visibility and hunting

Conclusion

Crypto mining malware doesn’t encrypt or delete—it silently profits. With the right tools, you can uncover and dissect its behavior quickly.

Reverse engineers—look for:

  • UPX-packed executables
  • Hardcoded mining strings
  • TLS callbacks
  • Suspicious persistence methods

Defenders—deploy:

  • Memory monitoring
  • PE mapping detection
  • Event correlation between CPU spikes and outbound traffic

Stay tuned for more malware analysis posts. Reach out on GitHub or LinkedIn for feedback or questions.

This post is licensed under CC BY 4.0 by the author.