# ctf-malware

Adopt this skill: https://proskills.md/skills/other/ljagiello-ctf-skills-ctf-malware

Page: https://proskills.md/skills/other/ljagiello-ctf-skills-ctf-malware
This document is the public skill bundle for that page. It contains SKILL.md and every helper file the catalog carries. No login is required.

## File: ctf-malware/SKILL.md
size: 8002
upstream: https://github.com/ljagiello/ctf-skills/blob/main/ctf-malware/SKILL.md

````text
---
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):**
```bash
pip install yara-python pefile capstone oletools unicorn pycryptodome \
  volatility3 dissect.cobaltstrike
```

**Linux (apt):**
```bash
apt install strace ltrace tshark binwalk binutils
```

**macOS (Homebrew):**
```bash
brew install wireshark binwalk binutils ghidra
```

**Manual install:**
- dnSpy — [GitHub](https://github.com/dnSpy/dnSpy), .NET decompiler (Windows)

## Additional Resources

- [scripts-and-obfuscation.md](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-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-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

```bash
# 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`/`bash` with `echo` to print underlying code; extract base64/hex blobs and analyze with `file`. See [scripts-and-obfuscation.md](scripts-and-obfuscation.md).

## JavaScript & PowerShell Deobfuscation

- JS: Replace `eval` with `console.log`, decode `unescape()`, `atob()`, `String.fromCharCode()`.
- PowerShell: Decode `-enc` base64, replace `IEX` with output. See [scripts-and-obfuscation.md](scripts-and-obfuscation.md).

## Junk Code Detection

- NOP sleds, push/pop pairs, dead writes, unconditional jumps to next instruction. Filter to extract real `call` targets. See [scripts-and-obfuscation.md](scripts-and-obfuscation.md).

## PCAP & Network Analysis

```bash
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](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-and-protocols.md).

## C2 Traffic Patterns

- Beaconing, DGA, DNS tunneling, HTTP(S) with custom headers, encoded payloads. See [c2-and-protocols.md](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](c2-and-protocols.md).

## Identifying Encryption Algorithms

- AES: `0x637c777b` S-box; ChaCha20: `expand 32-byte k`; TEA/XTEA: `0x9E3779B9`; RC4: sequential S-box init. See [c2-and-protocols.md](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](c2-and-protocols.md).

## PE Analysis

```bash
peframe malware.exe      # Quick triage
pe-sieve                 # Runtime analysis
pestudio                 # Static analysis (Windows)
```

See [pe-and-dotnet.md](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](pe-and-dotnet.md).

## Malware Configuration Extraction

- Check .data section, PE/.NET resources, registry keys, encrypted config files. See [pe-and-dotnet.md](pe-and-dotnet.md).

## Sandbox Evasion Checks

- VM detection, debugger detection, timing checks, environment checks, analysis tool detection. See [pe-and-dotnet.md](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](scripts-and-obfuscation.md#anti-analysis-techniques).

## 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](scripts-and-obfuscation.md#trojanized-plugin-analysis-with-custom-alphabet-c2-decoding-inshack-2018).

## PyInstaller + PyArmor Unpacking

- `pyinstxtractor.py` to extract, PyArmor-Unpacker for protected code. See [pe-and-dotnet.md](pe-and-dotnet.md).

## Telegram Bot Evidence Recovery

- Use bot token from malware source to call `getUpdates` and `getFile` APIs. See [c2-and-protocols.md](c2-and-protocols.md).

## Debian Package Analysis

```bash
ar -x package.deb && tar -xf control.tar.xz  # Check postinst scripts
```

See [scripts-and-obfuscation.md](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](scripts-and-obfuscation.md#yara-rules-for-malware-detection).

## 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](scripts-and-obfuscation.md#shellcode-analysis).

## Memory Forensics for Malware

`vol windows.malfind` detects injected code (PAGE_EXECUTE_READWRITE without mapped file). `windows.pstree` reveals s
````

## File: README.md
upstream: https://github.com/ljagiello/ctf-skills/blob/main/README.md

````text
# ctf-skills

[Agent Skills](https://agentskills.io) for solving CTF challenges — web exploitation, binary pwn, crypto, reverse engineering, forensics, OSINT, and more. Works with any tool that supports the Agent Skills spec, including [Claude Code](https://docs.anthropic.com/en/docs/claude-code).

## Installation

```bash
npx skills add ljagiello/ctf-skills
```

## Environment Setup

Two setup strategies depending on your workflow:

### Pre-install (recommended before competitions)

Use the central installer entrypoint:

```bash
bash scripts/install_ctf_tools.sh all
```

Run a narrower mode when you only want one tool group:

```bash
bash scripts/install_ctf_tools.sh python
bash scripts/install_ctf_tools.sh pat
bash scripts/install_ctf_tools.sh apt
bash scripts/install_ctf_tools.sh brew
bash scripts/install_ctf_tools.sh gems
bash scripts/install_ctf_tools.sh go
bash scripts/install_ctf_tools.sh manual
```

Preview what would be installed (skips already-present packages):

```bash
bash scripts/install_ctf_tools.sh --dry-run all
```

Verify what's already installed:

```bash
bash scripts/install_ctf_tools.sh --verify
```

Use `--force` to reinstall everything regardless of what's already present. Install logs are saved to `~/.ctf-tools/`.

The full package lists now live in [scripts/install_ctf_tools.sh](scripts/install_ctf_tools.sh).

> [!TIP]
> The `pat` mode shallow-clones [PayloadsAllTheThings](https://github.com/swisskyrepo/PayloadsAllTheThings) into `~/.ctf-tools/PayloadsAllTheThings` and links it at `ctf-web/payloads/PayloadsAllTheThings`. Bulk payloads stay out of git; technique files reference `ctf-web/pat-reference.md` with a few exemplar payloads inline.

### On-demand (during challenges)

Each skill's `SKILL.md` has a **Prerequisites** section listing only the tools needed for that category. Install as you go when the agent encounters a missing tool.

## Skills

| Skill | Files | Description |
|-------|-------|-------------|
| **ctf-ai-ml** | 3 | Model weight perturbation negation, adversarial examples (FGSM, PGD, C&W), foolbox L1BasicIterativeAttack Keras evasion, hand-rolled Keras FGSM via K.gradients, prompt injection, LLM jailbreaking, model extraction, membership inference, neural network collision, LoRA adapter exploitation, gradient descent inversion, data poisoning, backdoor detection, token smuggling, context window manipulation |
| **ctf-web** | 23 | SQLi (blind boolean/time/error generators, second-order, WAF bypasses, EXIF metadata injection, keyword fragmentation bypass, MySQL column truncation, DNS record injection, ORDER BY CASE WHERE bypass, QR code input injection, double-keyword filter bypass), Burp Intruder parity via `python-requests.md` (sync, 30-worker `ThreadPoolExecutor`, 100-concurrency `httpx` async, generator streaming feeds, `async_fuzz.py` CLI fuzzer), PayloadsAllTheThings on-demand index (`pat-reference.md`), XSS (AngularJS sandbox escapes, DOM clobbering, CSP bypasses), SSTI (Jinja2, Twig, Go template FuncMap), SSRF (DNS rebinding, cloud metadata), XXE, file upload polyglots, deserialization (Java ysoserial, Python pickle, PHP), JWT (key confusion, dynamic length RSA parameters), OAuth/OIDC, prototype pollution |
| **ctf-pwn** | 65 | Buffer overflow, ROP chains, ret2csu, ret2vdso, vsyscall ROP PIE bypass, bad char XOR bypass, 5 runnable `pwntools==4.15.0` template scripts in `ctf-pwn/scripts/` with `yield` payload generators (ret2libc, SROP, shellcraft asm, format string write-size suites, seccomp ORW), heap exploitation (unlink, House of Force, largebin attack guide, glibc 2.39 tcache key protection + calloc behavior, House of Apple 2 + setcontext SUID variant, House of Tangerine/Einherjar), kernel exploitation (io_uring `CVE-2024-0582`, CET Shadow Stack signal-frame bypass, KASLR, SMEP/SMAP, ret2usr, modprobe_path), format string, SROP with UTF-8 constraints, Linux userland attack playbook + static-signals reference, 43 pwnable.tw writeups (`ctf-pwn/pwnable-tw/`) |
| **ctf-crypto** | 19 | RSA (small e, common modulus, Wiener, Boneh-Durfee $d<N^{0.292}$, partial-$d$ exposure, Hastad broadcast, Hastad broadcast with linear padding Coppersmith, Coppersmith structured primes, Franklin-Reiter related message attack e=3, Manger, Manger OAEP timing, Williams $p+1$ + ECM chain, LSB binary search oracle, Fermat/consecutive primes, multi-prime, restricted-digit primes, p=q bypass, cube root CRT, phi multiple factoring, weak keygen base representation, gcd(e,phi)>1 exponent reduction, CRT fault attack, homomorphic decryption oracle bypass, small prime CRT decomposition, Montgomery timing, Bleichenbacher low-exponent forgery, e=1 bypass), AES (ECB byte-at-a-time, CBC bitflip + padding oracle, GCM nonce reuse forbidden attack, ChaCha20-Poly1305 nonce reuse, key-committing partitioning oracle), ECC (small subgroup, invalid curve 5 variants, Smart $p$-adic lift, MOV pairing, twist attacks, SIDH Castryck-Decru warning, CSIDH volcano walk, ECDSA nonce reuse, Ed25519 torsion), classic DH (trivial `g`, Pohlig-Hellman, Lim-Lee confinement), Lattices/PQC (fpylll Howgrave-Graham lattice, NTRU negacyclic basis, GGH CVP embedding, Mersenne AJPS small roots, BDD predicate, ML-KEM/Kyber flattening), PRNG/stream (PCG XSH-RR, xoroshiro/xoshiro, BBS parity, Henon/Arnold chaos, Spritz/VMPC/RC4A, Trivium cube attack) |
| **ctf-reverse** | 22 | Binary analysis, custom VMs (+ VM bytecode lifting to LLVM IR), WASM, RISC-V, Rust serde, Python bytecode, Unicorn CPU emulation guide (`unicorn-emulation.md`: hooks, mixed-mode 64→32 `retf` with XMM state preservation, MMIO peripherals, Keystone trace inversion), Go (GoReSym), Android APK/DEX/JNI, anti-debug, anti-VM, control flow flattening deobfuscation, radare2 scripting with r2ghidra decompilation, ESIL single-function emulation, and batch-mode byte patching (`radare2-r2pipe.md`), r2frida live-process instrumentation, MBA simplification with msynth, MCP server integration for agent-driven RE (`tools-mcp.md`) |
| **ctf-forensics** | 14 | Disk/memory forensics (GIMP raw memory dump visual inspection, Kyoto Cabinet hash DB forensics), RAID 5 XOR recovery, APFS snapshot recovery, Windows KAPE triage, Windows/Linux forensics, steganography (Arnold's Cat Map descrambling, MJPEG extra bytes after FFD9, high-res SSTV custom FM demodulation, EXIF zlib + triangular numbers LSB, PDF xref generation number covert channel, pixel-wise ECB deduplication image recovery), network captures, tcpdump, TLS/SSL keylog decryption, RDP session decryption via PKCS12 key extraction, USB HID drawing, USB HID keyboard capture decoding (+ arrow key navigation tracking), USB MIDI Launchpad traffic reconstruction, UART decode, serial UART data decoding from WAV audio, side-channel power analysi… |
| **ctf-osint** | 4 | Social media, geolocation, Google Lens cropped region search, reflected/mirrored text reading, Street View panorama matching, What3Words micro-landmark matching, Google Plus Codes, Baidu reverse image search, Overpass Turbo spatial queries, username enumeration, username metadata mining (postal codes), Strava fitness route OSINT, Google Maps photo verification, DNS recon, archive research, Google dorking (TBS image filters), Telegram bots, FEC filings, WHOIS investigation, music-themed landmark geolocation with key encoding, Shodan SSH fingerprint deanonymization, gaming platform OSINT (WoW/Steam/Minecraft character lookup), fake service banner detection via nmap fingerprinting, git commit author email mining for credential pivot, .DS_S… |
| **ctf-malware** | 4 | Obfuscated scripts, C2 traffic, custom crypto protocols, .NET malware, PyInstaller unpacking, PE analysis, sandbox evasion, anti-analysis (VM detection, timing evasion, API hashing, process injection), dynamic analysis (strace/ltrace, network monitoring, memory extraction), YARA rules, shellcode analysis, memory forensics (Volatility malfind, process injection), Poison Ivy RAT Camellia decryption, DarkComet RAT forensics (keylogger log recovery, re
````
