capa identifies the capabilities of a program: not just which APIs it imports, but what behaviors those APIs combine into (creates a mutex, encodes with XOR, beacons over HTTP), each mapped to MITRE ATT&CK. It works on binaries statically and can also process sandbox reports, giving one consistent capability language across static and dynamic views. This sub-skill covers running capa well, reading its output at the right depth, and extending it with custom rules. Scope: run capa only on samples you are authorized to handle, in an isolated lab, during authorized DFIR or malware research.
Quick Workflow
- Run capa on the sample binary first (static capabilities).
- Read the ATT&CK table, then the capability namespaces.
- Re-run with -v on interesting capabilities to find the exact functions and strings behind them.
- If a sandbox report exists, run capa against it for dynamic capabilities and diff the two views.
- Write custom capa rules for family-specific behaviors you spot.
- Export the capability list into the triage report with ATT&CK IDs.
1. Running capa
# Basic run
capa sample.exe
# Verbose: shows which functions/strings triggered each rule
capa -v sample.exe 2>/dev/null | less
# JSON output for scripting
capa -j sample.exe -o capa.json
# Against a CAPE sandbox report (dynamic capabilities)
capa -r report.json
Example output shape (abridged):
+------------------------+-------------------------------------------------+
| ATT&CK Tactic | ATT&CK Technique |
+------------------------+-------------------------------------------------+
| PERSISTENCE | Registry Run Keys / Startup Folder [T1547.001] |
| DEFENSE EVASION | Obfuscated Files or Information [T1027] |
| COMMAND AND CONTROL | Application Layer Protocol [T1071.001] |
+------------------------+-------------------------------------------------+
| CAPABILITY | NAMESPACE |
+------------------------+-------------------------------------------------+
| create mutex | host-interaction/mutex/create |
| encode data using XOR | data-manipulation/encoding/xor |
| send HTTP request | communication/http/client |
| persist via registry | persistence/registry |
+------------------------+-------------------------------------------------+
Read top-down: tactics tell you the campaign shape, namespaces tell you the mechanics. A sample with persistence plus C2 plus defense evasion is an implant; without persistence it is a one-shot tool.
2. Verbose mode: from capability to evidence
capa -v sample.exe 2>/dev/null | grep -B2 -A8 "create mutex"
Example output shape:
- create mutex @ 0x4012a0
- and:
- api: kernel32.CreateMutexA @ 0x4012b3
- string: "Global\\NimbusSyncMutex_7f3a" @ 0x402010
This is the bridge to YARA: the exact string and address behind a capability become rule strings. It is also the bridge to behavior: the function address tells the debugger where to break. Always capture the -v output for capabilities you put in the report; "capa says it beacons" is a claim, the function plus string is evidence.
3. Static versus dynamic capa
Static capa sees what the binary could do (imports, code patterns); dynamic capa on a sandbox report sees what it did. Diff them:
Static only: process injection APIs present but never called -> packed
or conditional; needs unpacking or triggering
Dynamic only: DNS queries with no socket imports -> API hashing or
resolved at runtime; note for string hunting
Both: HTTP beaconing confirmed; highest confidence IOCs
When static shows much more than dynamic, the sample is likely packed or evasive: route accordingly instead of concluding it is less capable than it is.
4. Writing custom capa rules
rule:
meta:
name: nimbus beacon interval check
namespace: c2/nimbus
authors: [analyst]
scope: function
att&ck:
- T1071.001 [Web Protocols]
features:
- and:
- api: wininet.HttpSendRequestA
- string: "/api/v2/beacon"
- number: 60
Custom rules encode family knowledge: the beacon path plus the interval
constant is a Nimbus signature no generic rule captures. Keep custom
rules in a team ruleset directory, version them with git, and pass them
with -r:
capa -r team_rules/ sample.exe
Test custom rules against clean software the same way you test YARA: a capability rule that fires on notepad is a liability.
5. capa output as detection content
Each confirmed capability maps to a detection:
persist via registry+ the Run value string -> Sigma rule on the registry path and value.send HTTP request+ the URL string -> proxy block and YARA string.- ATT&CK technique list -> coverage matrix: which techniques your detections already catch, which are gaps.
Export JSON and script the mapping so every triage produces the same artifacts in the same format.
Edge cases
- Packed samples: capa sees the stub's capabilities, not the payload's. Unpack first or treat static capa as stub-only.
- .NET and Go binaries: capa supports them, but capability quality varies; verify surprising hits with -v.
- capa rule updates change results over time; pin the capa version in reports and re-run on upgrade.
- Very large binaries: capa can be slow; scope with
-ttimeouts and analyze the interesting functions first. - False capability hits from statically linked libraries: a crypto library linked into a benign tool still triggers encoding rules; check the namespace context.
Escalation
If capa crashes or hangs on a sample, try the latest ruleset and version; if it persists, report upstream and fall back to manual triage for that sample.
If static and dynamic capa disagree fundamentally (different malware classes), escalate: you may be analyzing two different files or a multi-stage chain.
If capa flags a capability that changes incident priority (wiper, ransomware), escalate immediately; do not wait for the full triage.
If team capa rules start firing on legitimate admin tools, quarantine the rule and re-tune; capability rules need the same FP discipline as YARA.
Detection and defender view
capa gives defenders a capability inventory per sample, which aggregates into a threat landscape view: which ATT&CK techniques appear most in your intake, where your detection gaps cluster. Share the ATT&CK mapping from each triage with the SOC; it is the common language between your report and their alerts. Custom capa rules for your top families become a standing detection layer in the malware pipeline: every incoming sample gets capa-scanned, and family rules fire before a human looks.
Key references
capa documentation and rules: https://github.com/mandiant/capa
capa rule format reference: https://github.com/mandiant/capa-rules
MITRE ATT&CK: https://attack.mitre.org/
CAPE Sandbox documentation: https://capev2.readthedocs.io/
MITRE ATT&CK Navigator (coverage mapping): https://mitre-attack.github.io/attack-navigator/
