Skip to main content

Lesson 4 of 10

Malware Analysis Fundamentals

Malware analysis is the process of understanding how malicious software works - its capabilities, behavior, C2 communication, and persistence mechanisms. This informs both incident response (scope, IOCs) and threat intelligence.

60 minBy Priygop Editorial TeamUpdated 2026Peer Reviewed & Verified

Static Analysis

Static Analysis
# Static analysis: examining the malware file without executing it
# SAFE - no risk of infection, but malware may be obfuscated/packed

# 1. Basic file inspection
file malware.exe         # File type (PE32 executable, ELF, script)
sha256sum malware.exe    # Hash for VirusTotal lookup

# 2. VirusTotal lookup (never upload if confidential)
curl -s "https://www.virustotal.com/api/v3/files/$(sha256sum malware.exe | cut -d' ' -f1)"     -H "x-apikey: YOUR_API_KEY" | jq '.data.attributes.last_analysis_stats'

# 3. String extraction - reveals hardcoded artifacts
strings malware.exe | grep -E '(https?://|[0-9]{1,3}.[0-9]{1,3}|cmd|powershell)'
# Look for: C2 URLs, IP addresses, registry keys, file paths, suspicious commands

# 4. OLE/macros analysis (malicious Office documents)
pip install oletools
oleid invoice.doc                    # Detect if document contains macros
olevba --decode invoice.doc          # Extract and decode macros
mraptor invoice.doc                  # Detect suspicious macro patterns

# 5. PE header analysis (Windows executables)
pip install pefile
python3 -c "
import pefile
pe = pefile.PE('malware.exe')
print('Sections:', [s.Name.decode().strip() for s in pe.sections])
print('Imports:', [e.dll.decode() for e in pe.DIRECTORY_ENTRY_IMPORT])
print('Timestamp:', pe.FILE_HEADER.TimeDateStamp)
"

# 6. Detect packing/obfuscation
# Packed malware has very high entropy in sections
# Normal code: ~5.0-6.5 entropy | Packed: ~7.5-8.0 entropy
python3 -c "
import math, pefile, sys
pe = pefile.PE('malware.exe')
for section in pe.sections:
    data = section.get_data()
    entropy = -sum(c/len(data)*math.log2(c/len(data)+1e-9) for c in 
                   [data.count(bytes([b])) for b in range(256)] if data.count(bytes([b])) > 0)
    print(f'{section.Name.decode().strip()}: entropy={entropy:.2f}')
"

Dynamic Analysis

Dynamic Analysis
# Dynamic analysis: execute the malware in a controlled sandbox
# Observe actual behavior - bypasses obfuscation
# ALWAYS use an isolated VM that is NEVER connected to production network

# Setup: FlareVM (Windows analysis) or REMnux (Linux analysis)
# Snapshot the clean VM before running any malware

# Tools to run while malware executes:

# Process Monitor (Windows - ProcMon): Observe all:
# - Registry reads/writes (persistence, configuration)
# - File system reads/writes (dropped files, encrypted files)
# - Network connections (C2 communication)

# Wireshark: Capture all network traffic
# - What hosts does it contact?
# - What protocols? DNS? HTTP? Custom?
# - What does it send/receive?

# API Monitor: Log all Windows API calls
# Look for: CreateProcess, WriteFile, RegSetValue, URLDownloadToFile

# Regshot: Before/after registry snapshot
regshot.exe        # Take snapshot BEFORE running malware
# Run malware
# Take second snapshot - diff shows all registry changes

# Automated sandboxes (no setup required):
# Cuckoo Sandbox (self-hosted): cuckoo submit malware.exe
# Any.run: https://any.run (interactive online sandbox)
# Hybrid-Analysis: https://hybrid-analysis.com (free tier available)
# Joe Sandbox: https://joesandbox.com

# Extract IOCs (Indicators of Compromise) from analysis:
# C2 IP/domain, file hashes, registry keys, mutex names, file paths

Common Malware Families & Behaviors

  • Ransomware: Encrypts files using AES key encrypted with attacker's RSA public key. Drops ransom note. Deletes Volume Shadow Copies (vssadmin delete shadows /all). Spreads via SMB (WannaCry) or network shares. IOC: vssadmin process, high filesystem write activity, .enc/.locked extension
  • RAT (Remote Access Trojan): Establishes persistent C2 channel (often HTTPS to legitimate-looking domain). Capabilities: keylogging, screenshot, webcam, file access, remote shell. Common: njRAT, AsyncRAT, QuasarRAT
  • Infostealer: Targets browser credentials, cookies, crypto wallets, email clients. Exfiltrates to C2 immediately. Common: Redline, Raccoon, Vidar
  • Rootkit: Hides its presence by modifying kernel-level visibility. Process, file, and network connection hiding. Requires offline analysis (boot from clean media) to detect

Common Mistakes

  • Analyzing malware on a non-isolated VM with network access - even 'isolated' VMs can escape hypervisors via VM escape exploits; use dedicated physical hardware with no network connectivity for high-risk samples
  • Not reverting VM snapshot after analysis - malware infects the analysis VM; subsequent analyses are contaminated
  • Uploading confidential malware samples to VirusTotal - samples are shared with AV vendors; if malware was used in a targeted attack against your organization, this alerts the attacker

Tip

Tip

Practice Malware Analysis Fundamentals in small, isolated examples before integrating into larger projects. Breaking concepts into small experiments builds genuine understanding faster than reading alone.

Diagram
Loading diagram…

The foundational security model: Confidentiality (privacy), Integrity (trust), and Availability (uptime).

Practice Task

Note

Practice Task - (1) Write a working example of Malware Analysis Fundamentals from scratch without looking at notes. (2) Modify it to handle an edge case (empty input, null value, or error state). (3) Share your solution in the Priygop community for feedback.

Quick Quiz

Common Mistake

Warning

A common mistake with Malware Analysis Fundamentals is skipping edge case testing - empty inputs, null values, and unexpected data types. Always validate boundary conditions to write robust, production-ready cybersecurity code.

Key Takeaways

  • Malware analysis is the process of understanding how malicious software works - its capabilities, behavior, C2 communication, and persistence mechanisms.
  • Ransomware: Encrypts files using AES key encrypted with attacker's RSA public key. Drops ransom note. Deletes Volume Shadow Copies (vssadmin delete shadows /all). Spreads via SMB (WannaCry) or network shares. IOC: vssadmin process, high filesystem write activity, .enc/.locked extension
  • RAT (Remote Access Trojan): Establishes persistent C2 channel (often HTTPS to legitimate-looking domain). Capabilities: keylogging, screenshot, webcam, file access, remote shell. Common: njRAT, AsyncRAT, QuasarRAT
  • Infostealer: Targets browser credentials, cookies, crypto wallets, email clients. Exfiltrates to C2 immediately. Common: Redline, Raccoon, Vidar

Hands-on Practice Tools for this Course

Test what you learn using these free in-browser developer utilities (no signup required).

All 40+ Tools

Topics in This Module

0/10 done