ctf-malware
ljagiello/ctf-skills
Malware analysis and C2 traffic techniques for CTF challenges.
What is ctf-malware?
Provides tools and techniques for analyzing obfuscated scripts, malicious binaries, custom crypto protocols, and network traffic in CTF challenges. Use when reverse-engineering malware, extracting C2 indicators, decrypting communications, analyzing PE/.NET binaries, or detecting anti-analysis techniques.
- Analyze obfuscated scripts (JavaScript, PowerShell, bash) and extract hidden payloads
- Perform static and dynamic analysis on PE and .NET malware with peframe, dnSpy, and AsmResolver
- Detect and decrypt custom crypto protocols (RC4, AES, ChaCha20, TEA/XTEA) in network traffic
- Extract malware configurations, C2 domains, and indicators of compromise from binaries
- Analyze PCAP files and identify C2 beaconing, DNS tunneling, and encoded payloads
- Detect anti-analysis techniques (VM detection, API hashing, process injection, timing evasion)
How to install ctf-malware
npx skills add https://github.com/ljagiello/ctf-skills --skill ctf-malware- Python 3 with packages: yara-python, pefile, capstone, oletools, unicorn, pycryptodome, volatility3, dissect.cobaltstrike
- Linux: strace, ltrace, tshark, binwalk, binutils; or macOS: wireshark, binwalk, binutils, ghidra
- dnSpy for .NET decompilation (Windows) or ILSpy/AsmResolver as alternatives
- Filesystem-based agent (Claude Code or similar) with bash and internet access for tool installation
How to use ctf-malware
- 1.Install Python packages and system tools listed in prerequisites for your platform
- 2.Use file, strings, and xxd for initial static analysis of suspicious samples
- 3.Run peframe or pe-sieve on PE binaries to identify imports, sections, and suspicious behavior
- 4.Deobfuscate scripts by replacing eval with echo/console.log and decoding base64/hex payloads
- 5.Extract network indicators (IPs, domains, URLs) using strings and grep patterns
- 6.Analyze PCAP files with tshark to isolate C2 traffic streams and identify encryption algorithms
- 7.Use YARA rules to scan for known malware patterns and custom signatures
- 8.Decrypt C2 communications by identifying encryption type (AES S-box, ChaCha20 constants, RC4 keystream)
Use cases
- Decode obfuscated malware scripts and extract base64/hex payloads to identify malicious behavior
- Analyze RC4-encrypted WebSocket C2 traffic by extracting keys from binaries and decrypting PCAP streams
- Identify AES-CBC encryption in malware by locating hardcoded keys and IVs in PE sections
- Detect process injection and sandbox evasion techniques in Windows malware samples
- Extract Telegram bot tokens and recover C2 communications from trojanized plugins
- CTF competitors solving malware analysis and reverse engineering challenges
- Security researchers analyzing suspicious binaries and network traffic
- Incident responders extracting indicators of compromise and C2 infrastructure
- Forensics analysts performing memory and disk artifact recovery on infected systems
ctf-malware FAQ
Use ctf-malware for analyzing malicious behavior, C2 protocols, and malware-specific techniques. Switch to ctf-reverse if the sample is a normal crackme or packed binary without malware behavior. Use ctf-forensics for disk carving, memory recovery, or host artifact analysis.
Look for algorithm-specific constants: AES uses 0x637c777b S-box, ChaCha20 has 'expand 32-byte k', TEA/XTEA use 0x9E3779B9, RC4 has sequential S-box initialization. Check PE sections and strings for hardcoded keys and IVs.
Replace eval/IEX with echo/console.log to print underlying code. Decode -enc base64 in PowerShell and unescape()/atob()/String.fromCharCode() in JavaScript. Extract and analyze base64/hex blobs with file command.
Use strings to find IPs, domains, and URLs. Analyze PCAP with tshark to isolate traffic streams. Identify encryption keys in PE sections or hardcoded strings. Decrypt payloads to reveal C2 domains and commands.
Yes, but only in an isolated sandbox environment. Use strace -f -s 200 to trace system calls and ltrace to trace library calls. Monitor network activity with tshark simultaneously to capture C2 communications.
Full instructions (SKILL.md)
Source of truth, from ljagiello/ctf-skills.
name: ctf-malware description: Provides malware analysis and network traffic techniques for CTF challenges. Use when analyzing obfuscated scripts, malicious packages, custom crypto protocols, C2 traffic, PE/.NET binaries, RC4/AES encrypted communications, YARA rules, shellcode analysis, memory forensics for malware (Volatility malfind, process injection detection), anti-analysis techniques (VM/sandbox detection, timing evasion, API hashing, process injection, environment checks), or extracting malware configurations and indicators of compromise. license: MIT compatibility: Requires filesystem-based agent (Claude Code or similar) with bash, Python 3, and internet access for tool installation. allowed-tools: Bash Read Write Edit Glob Grep Task WebFetch WebSearch metadata: user-invocable: "false"
CTF Malware & Network Analysis
Quick reference for malware analysis CTF challenges. Each technique has a one-liner here; see supporting files for full details with code.
Prerequisites
Python packages (all platforms):
pip install yara-python pefile capstone oletools unicorn pycryptodome \
volatility3 dissect.cobaltstrike
Linux (apt):
apt install strace ltrace tshark binwalk binutils
macOS (Homebrew):
brew install wireshark binwalk binutils ghidra
Manual install:
- dnSpy — GitHub, .NET decompiler (Windows)
Additional Resources
- scripts-and-obfuscation.md - JavaScript deobfuscation, PowerShell analysis, eval/base64 decoding, junk code detection, hex payloads, Debian package analysis, dynamic analysis techniques (strace/ltrace, network monitoring, memory string extraction, automated sandbox execution), YARA rules for malware detection, shellcode analysis (Unicorn Engine, Capstone), memory forensics for malware (Volatility 3 malfind, process injection detection), anti-analysis techniques (VM detection, timing evasion, API hashing, process injection), trojanized plugin analysis with custom alphabet C2 decoding
- c2-and-protocols.md - C2 traffic patterns, custom crypto protocols, RC4 WebSocket, DNS-based C2, network indicators, PCAP analysis, AES-CBC, encryption ID, Telegram bot recovery, Poison Ivy RAT Camellia decryption
- pe-and-dotnet.md - PE analysis (peframe, pe-sieve, pestudio), .NET analysis (dnSpy, AsmResolver), LimeRAT extraction, sandbox evasion, malware config extraction, PyInstaller+PyArmor
When to Pivot
- If the sample is really just a normal crackme, packed challenge binary, or custom VM with no malware behavior, switch to
/ctf-reverse. - If the main job is network reconstruction, disk carving, or host artifact recovery, switch to
/ctf-forensics. - If the challenge turns into public attribution or infrastructure tracing, switch to
/ctf-osint.
Quick Start Commands
# Static analysis
file suspicious_file
strings -n 8 suspicious_file | head -50
xxd suspicious_file | head -20
# PE analysis
python3 -c "import pefile; pe=pefile.PE('mal.exe'); print(pe.dump_info())" | head
peframe mal.exe
# Dynamic analysis (sandboxed!)
strace -f -s 200 ./suspicious 2>&1 | head -100
ltrace ./suspicious 2>&1 | head -50
# Network indicators
strings suspicious_file | grep -E '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}'
strings suspicious_file | grep -iE 'http|ftp|ws://'
# YARA scan
yara -r rules.yar suspicious_file
Obfuscated Scripts
- Replace
eval/bashwithechoto print underlying code; extract base64/hex blobs and analyze withfile. See scripts-and-obfuscation.md.
JavaScript & PowerShell Deobfuscation
- JS: Replace
evalwithconsole.log, decodeunescape(),atob(),String.fromCharCode(). - PowerShell: Decode
-encbase64, replaceIEXwith output. See scripts-and-obfuscation.md.
Junk Code Detection
- NOP sleds, push/pop pairs, dead writes, unconditional jumps to next instruction. Filter to extract real
calltargets. See scripts-and-obfuscation.md.
PCAP & Network Analysis
tshark -r file.pcap -Y "tcp.stream eq X" -T fields -e tcp.payload
Look for C2 on unusual ports. Extract IPs/domains with strings | grep. See c2-and-protocols.md.
Custom Crypto Protocols
- Stream ciphers share keystream state for both directions; concatenate ALL payloads chronologically.
- ChaCha20 keystream extraction: send nullbytes (0 XOR anything = anything). See c2-and-protocols.md.
C2 Traffic Patterns
- Beaconing, DGA, DNS tunneling, HTTP(S) with custom headers, encoded payloads. See c2-and-protocols.md.
RC4-Encrypted WebSocket C2
- Remap port with
tcprewrite, add RSA key for TLS decryption, find RC4 key in binary. See c2-and-protocols.md.
Identifying Encryption Algorithms
- AES:
0x637c777bS-box; ChaCha20:expand 32-byte k; TEA/XTEA:0x9E3779B9; RC4: sequential S-box init. See c2-and-protocols.md.
AES-CBC in Malware
- Key = MD5/SHA256 of hardcoded string; IV = first 16 bytes of ciphertext. See c2-and-protocols.md.
PE Analysis
peframe malware.exe # Quick triage
pe-sieve # Runtime analysis
pestudio # Static analysis (Windows)
See pe-and-dotnet.md.
.NET Malware Analysis
- Use dnSpy/ILSpy for decompilation; AsmResolver for programmatic analysis. LimeRAT C2: AES-256-ECB with MD5-derived key. See pe-and-dotnet.md.
Malware Configuration Extraction
- Check .data section, PE/.NET resources, registry keys, encrypted config files. See pe-and-dotnet.md.
Sandbox Evasion Checks
- VM detection, debugger detection, timing checks, environment checks, analysis tool detection. See pe-and-dotnet.md.
Anti-Analysis Techniques
VM detection (CPUID, MAC prefix, registry, disk size), timing evasion (sleep/RDTSC sandbox detection), API hashing (ROR13/DJB2/CRC32 + hashdb lookup), process injection (hollowing, APC, CreateRemoteThread), environment checks. See scripts-and-obfuscation.md.
Trojanized Plugin Analysis
Diff malicious plugin against official release to find injected code in try/except blocks. Custom alphabet rotation (C[(C.index(ch) - offset) % len(C)]) decodes C2 domain, XOR decodes endpoint path. See scripts-and-obfuscation.md.
PyInstaller + PyArmor Unpacking
pyinstxtractor.pyto extract, PyArmor-Unpacker for protected code. See pe-and-dotnet.md.
Telegram Bot Evidence Recovery
- Use bot token from malware source to call
getUpdatesandgetFileAPIs. See c2-and-protocols.md.
Debian Package Analysis
ar -x package.deb && tar -xf control.tar.xz # Check postinst scripts
See scripts-and-obfuscation.md.
YARA Rules for Malware Detection
Write YARA rules to match byte patterns, strings, and regex against files or memory dumps. Detect XOR loops ({31 ?? 80 ?? ?? 4? 75}), base64 blobs, encoded PowerShell. Use yarac to compile for faster scanning. See scripts-and-obfuscation.md.
Shellcode Analysis
Disassemble with objdump -b binary -m i386:x86-64, emulate with Unicorn Engine (hook syscalls safely), or use Capstone for programmatic disassembly. Look for XOR decoder stubs. See scripts-and-obfuscation.md.
Memory Forensics for Malware
vol3 windows.malfind detects injected code (PAGE_EXECUTE_READWRITE without mapped file). windows.pstree reveals suspicious parent-child relationships. YARA scan memory with yarascan.YaraScan. See scripts-and-obfuscation.md.
Network Indicators Quick Reference
strings malware | grep -E '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}'
tshark -r capture.pcap -Y "dns.qry.name" -T fields -e dns.qry.name | sort -u
Related skills
More from ljagiello/ctf-skills and the wider catalog.
ctf-reverse
Reverse engineering techniques for CTF challenges: binaries, APKs, WASM, firmware, VMs, and anti-analysis bypasses.
ctf-web
Web exploitation techniques for CTF challenges: XSS, SQLi, SSTI, SSRF, XXE, JWT, auth bypass, and more.
ctf-pwn
Binary exploitation techniques for CTF challenges: buffer overflows, ROP, format strings, heap bugs, and privilege escalation.
ctf-crypto
Cryptography attack techniques for CTF challenges: RSA, AES, ECC, lattices, PRNG, and more.
ctf-osint
Open source intelligence techniques for CTF challenges: OSINT lookups, social media tracking, geolocation, DNS recon, and data identification.
ctf-forensics
Digital forensics and signal analysis for CTF challenges: disk images, memory dumps, network captures, steganography, and hardware signals.