MCPcopy Index your code
hub / github.com/mandiant/capa

github.com/mandiant/capa @v9.4.0 sqlite

repository ↗ · DeepWiki ↗ · release v9.4.0 ↗
3,366 symbols 10,849 edges 228 files 763 documented · 23%
README

Website | Download | Web Interface

PyPI - Python Version Last release Number of rules CI status Downloads License


capa detects capabilities in executable files. You run it against a PE, ELF, .NET module, shellcode file, or a sandbox report and it tells you what it thinks the program can do. For example, it might suggest that the file is a backdoor, is capable of installing services, or relies on HTTP to communicate.

To interactively inspect capa results in your browser use the capa Explorer Web.

If you want to inspect or write capa rules, head on over to the capa-rules repository. Otherwise, keep reading.

Below you find a list of our capa blog posts with more details.

example capa output

$ capa.exe suspicious.exe

+--------------------+------------------------------------------------------------------------+
| ATT&CK Tactic      | ATT&CK Technique                                                       |
|--------------------+------------------------------------------------------------------------|
| DEFENSE EVASION    | Obfuscated Files or Information [T1027]                                |
| DISCOVERY          | Query Registry [T1012]                                                 |
|                    | System Information Discovery [T1082]                                   |
| EXECUTION          | Command and Scripting Interpreter::Windows Command Shell [T1059.003]   |
|                    | Shared Modules [T1129]                                                 |
| EXFILTRATION       | Exfiltration Over C2 Channel [T1041]                                   |
| PERSISTENCE        | Create or Modify System Process::Windows Service [T1543.003]           |
+--------------------+------------------------------------------------------------------------+

+-------------------------------------------+-------------------------------------------------+
| CAPABILITY                                | NAMESPACE                                       |
|-------------------------------------------+-------------------------------------------------|
| read and send data from client to server  | c2/file-transfer                               |
| execute shell command and capture output  | c2/shell                                       |
| receive data (2 matches)                  | communication                                   |
| send data (6 matches)                     | communication                                   |
| connect to HTTP server (3 matches)        | communication/http/client                       |
| send HTTP request (3 matches)             | communication/http/client                       |
| create pipe                               | communication/named-pipe/create                 |
| get socket status (2 matches)             | communication/socket                            |
| receive data on socket (2 matches)        | communication/socket/receive                    |
| send data on socket (3 matches)           | communication/socket/send                       |
| connect TCP socket                        | communication/socket/tcp                        |
| encode data using Base64                  | data-manipulation/encoding/base64               |
| encode data using XOR (6 matches)         | data-manipulation/encoding/xor                  |
| run as a service                          | executable/pe                                   |
| get common file path (3 matches)          | host-interaction/file-system                    |
| read file                                 | host-interaction/file-system/read               |
| write file (2 matches)                    | host-interaction/file-system/write              |
| print debug messages (2 matches)          | host-interaction/log/debug/write-event          |
| resolve DNS                               | host-interaction/network/dns/resolve            |
| get hostname                              | host-interaction/os/hostname                    |
| create process                            | host-interaction/process/create                 |
| create registry key                       | host-interaction/registry/create                |
| create service                            | host-interaction/service/create                 |
| create thread                             | host-interaction/thread/create                  |
| persist via Windows service               | persistence/service                             |
+-------------------------------------------+-------------------------------------------------+

download and usage

Download stable releases of the standalone capa binaries here. You can run the standalone binaries without installation. capa is a command line tool that should be run from the terminal.

To use capa as a library or integrate with another tool, see doc/installation.md for further setup instructions.

Documentation: Usage and tips · Installation · Limitations · FAQ

capa Explorer Web

The capa Explorer Web enables you to interactively explore capa results in your web browser. Besides the online version you can download a standalone HTML file for local offline usage.

capa Explorer Web screenshot

More details on the web UI is available in the capa Explorer Web README.

example

In the above sample output, we run capa against an unknown binary (suspicious.exe), and the tool reports that the program can send HTTP requests, decode data via XOR and Base64, install services, and spawn new processes. Taken together, this makes us think that suspicious.exe could be a persistent backdoor. Therefore, our next analysis step might be to run suspicious.exe in a sandbox and try to recover the command and control server.

detailed results

By passing the -vv flag (for very verbose), capa reports exactly where it found evidence of these capabilities. This is useful for at least two reasons:

  • it helps explain why we should trust the results, and enables us to verify the conclusions, and
  • it shows where within the binary an experienced analyst might study with IDA Pro
$ capa.exe suspicious.exe -vv
...
execute shell command and capture output
namespace   c2/shell
author      matthew.williams@mandiant.com
scope       function
att&ck      Execution::Command and Scripting Interpreter::Windows Command Shell [T1059.003]
references  https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/ns-processthreadsapi-startupinfoa
function @ 0x4011C0
  and:
    match: create a process with modified I/O handles and window @ 0x4011C0
      and:
        number: 257 = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW @ 0x4012B8
        or:
          number: 68 = StartupInfo.cb (size) @ 0x401282
        or: = API functions that accept a pointer to a STARTUPINFO structure
          api: kernel32.CreateProcess @ 0x401343
    match: create pipe @ 0x4011C0
      or:
        api: kernel32.CreatePipe @ 0x40126F, 0x401280
    optional:
      match: create thread @ 0x40136A, 0x4013BA
        or:
          and:
            os: windows
            or:
              api: kernel32.CreateThread @ 0x4013D7
        or:
          and:
            os: windows
            or:
              api: kernel32.CreateThread @ 0x401395
    or:
      string: "cmd.exe" @ 0x4012FD
...

capa also supports dynamic capabilities detection for multiple sandboxes including: * CAPE (supported report formats: .json, .json_, .json.gz) * DRAKVUF (supported report formats: .log, .log.gz) * VMRay (supported report formats: analysis archive .zip)

To use this feature, submit your file to a supported sandbox and then download and run capa against the generated report file. This feature enables capa to match capabilities against dynamic and static features that the sandbox captured during execution.

Here's an example of running capa against a packed file, and then running capa against the CAPE report generated for the same packed file:

```yaml $ capa 05be49819139a3fdcdbddbdefd298398779521f3d68daa25275cc77508e42310.exe WARNING:capa.capabilities.common:-------------------------------------------------------------------------------- WARNING:capa.capabilities.common: This sample appears to be packed. WARNING:capa.capabilities.common: WARNING:capa.capabilities.common: Packed samples have often been obfuscated to hide their logic. WARNING:capa.capabilities.common: capa cannot handle obfuscation well using static analysis. This means the results may be misleading or incomplete. WARNING:capa.capabilities.common: If possible, you should try to unpack this input file before analyzing it with capa. WARNING:capa.capabilities.common: Alternatively, run the sample in a supported sandbox and invoke capa against the report to obtain dynamic analysis results. WARNING:capa.capabilities.common: WARNING:capa.capabilities.common: Identified via rule: (internal) packer file limitation WARNING:capa.capabilities.common: WARNING:capa.capabilities.common: Use -v or -vv if you really want to see the capabilities identified by capa. WARNING:capa.capabilities.common:--------------------------------------------------------------------------------

$ capa 05be49819139a3fdcdbddbdefd298398779521f3d68daa25275cc77508e42310.json

┍━━━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┑ │ ATT&CK Tactic │ ATT&CK Technique │ ┝━━━━━━━━━━━━━━━━━━━━━━━━┿━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┥ │ CREDENTIAL ACCESS │ Credentials from Password Stores T1555 │ ├────────────────────────┼────────────────────────────────────────────────────────────────────────────────────┤ │ DEFENSE EVASION │ File and Directory Permissions Modification T1222 │ │ │ Modify Registry T1112 │ │ │ Obfuscated Files or Information T1027 │ │ │ Virtualization/Sandbox Evasion::User Activity Based Checks T1497.002 │ ├────────────────────────┼────────────────────────────────────────────────────────────────────────────────────┤ │ DISCOVERY │ Account Discovery T1087 │ │ │ Application Window Discovery T1010 │ │ │ File and Directory Discovery T1083 │ │ │ Query Registry T1012 │ │ │ System Information Discovery T1082 │ │ │ System Location Discovery::System Language Discovery T1614.001 │ │ │ System Owner/User Discovery T1033 │ ├────────────────────────┼────────────────────────────────────────────────────────────────────────────────────┤ │ EXECUTION │ System Services::Service Execution T1569.002 │ ├────────────────────────┼────────────────────────────────────────────────────────────────────────────────────┤ │ PERSISTENCE │ Boot or Logon Autostart Execution::Registry Run Keys / Startup Folder T1547.001 │ │ │ Boot or Logon Autostart Execution::Winlogon Helper DLL T1547.004 │ │ │ Create or Modify System Process::Windows Service T1543.003 │ ┕━━━━━━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┙

┍━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┯━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┑ │ Capability │ Namespace │ ┝━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┿━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Core symbols most depended-on inside this repo

from_yaml
called by 175
capa/rules/__init__.py
info
called by 119
capa/ida/plugin/item.py
evaluate
called by 103
capa/engine.py
contains
called by 75
capa/features/extractors/binexport2/__init__.py
update
called by 57
capa/ida/plugin/extractor.py
write
called by 49
capa/render/utils.py
from_capa
called by 46
capa/render/result_document.py
assert_never
called by 32
capa/helpers.py

Shape

Function 1,592
Method 1,334
Class 437
Route 3

Languages

Python72%
TypeScript28%

Modules by API surface

web/rules/public/js/bootstrap-5.3.3.bundle.min.js390 symbols
web/public/js/bootstrap-5.3.3.bundle.min.js390 symbols
scripts/lint.py102 symbols
capa/ida/plugin/view.py97 symbols
capa/rules/__init__.py83 symbols
tests/fixtures.py78 symbols
web/rules/public/js/jquery-3.5.1.slim.min.js72 symbols
capa/ida/plugin/form.py69 symbols
capa/features/common.py62 symbols
capa/features/extractors/elf.py57 symbols
capa/features/address.py51 symbols
capa/render/result_document.py50 symbols

Dependencies from manifests, versioned

@highlightjs/vue-plugin2.1.0 · 1×
@primevue/themes4.0.0-rc.2 · 1×
@rushstack/eslint-patch1.8.0 · 1×
@vitejs/plugin-vue5.2.3 · 1×
@vue/test-utils2.4.6 · 1×
eslint8.57.0 · 1×
eslint-plugin-vue9.23.0 · 1×
jsdom24.1.0 · 1×
pako2.1.0 · 1×
plotly.js-dist2.34.0 · 1×
prettier3.2.5 · 1×

For agents

$ claude mcp add capa \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact