BannedFuncDetector
Find insecure function calls a symbol-table grep can't see — including statically-linked and inlined ones — via radare2 decompilation
Overview
BannedFuncDetector scans binaries for banned/insecure function usage (the Microsoft banned API set: strcpy, sprintf, gets, …).
Why not just rabin2 -i | grep strcpy?
For a dynamically-linked binary, that one-liner is equivalent to the name check here — and you should use it. BannedFuncDetector exists for the case the import-table grep misses:
- Statically-linked and inlined calls. A
strcpycompiled into the binary (static linking, LTO, inlined libc) never appears in the import table, sorabin2 -i | grepfinds nothing. BannedFuncDetector walks the decompiled code (pdc/pdg/pdd) and catches it at the call site. - A curated banned-API list so you don't grep one name at a time.
- Batch + structured output: directory scans, parallel workers, per-target JSON reports for pipelines.
If your target is dynamically linked and you just want a yes/no on imports, the grep is faster and has zero dependencies. Reach for this tool when "is it in the imports?" isn't the same question as "is it in the code?".
Key Features
| Feature | Description |
|---|---|
| Binary Analysis | Analyze PE/ELF/Mach-O binaries for banned functions |
| Multiple Decompilers | r2ghidra, r2dec, default, and decai (AI assistant) |
| Directory Scans | Analyze one file or whole directories |
| Parallel Processing | Speed up directory scans |
| JSON Reports | Results saved per target with structured output |
| Library Mode | Use via CLI or import as a Python package |
Supported Decompilers
Default (pdc) r2ghidra (pdg) r2dec (pdd) decai (AI assistant)
Installation
From PyPI (Recommended)
pip install bannedfuncdetector
From Source
git clone https://github.com/seifreed/BannedFuncDetector.git
cd BannedFuncDetector
python3 -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install -e .
Quick Start
# Analyze a single binary
bannedfunc -f /path/to/binary
# Analyze a directory
bannedfunc -d /path/to/binaries --parallel
# Use r2dec
bannedfunc -f /path/to/binary --decompiler r2dec
Usage
Command Line Interface
# Basic analysis
bannedfunc -f /path/to/binary
# Analyze a directory with parallel workers
bannedfunc -d /path/to/binaries --parallel
# Save output to a custom directory
bannedfunc -f /path/to/binary -o output
# Force a decompiler
bannedfunc -f /path/to/binary --decompiler r2ghidra --force-decompiler
# Skip decompilation analysis (names only)
bannedfunc -f /path/to/binary --skip-analysis
Available Options
| Option | Description |
|---|---|
-f, --file |
Executable file to analyze |
-d, --directory |
Directory with executables to analyze |
-o, --output |
Output directory for results |
--decompiler |
Decompiler to use (default, r2ghidra, r2dec, decai) |
--force-decompiler |
Force the specified decompiler |
--parallel |
Process files in parallel (directory only) |
--skip-banned |
Skip banned function name checks |
--skip-analysis |
Skip decompilation analysis |
--check-requirements |
Check system requirements before running |
-v, --verbose |
Show detailed information |
AI decompilation (decai)
The decai decompiler uses an AI backend through the radare2 decai plugin.
The backend is driven entirely by the decompiler.options.decai section of
config.json, so you can switch providers without touching code.
Default backend: OpenCode Zen — free big-pickle model. Zen exposes free
models (big-pickle, deepseek-v4-flash-free, …) over an OpenAI-compatible
endpoint, so decai reaches them with api=openai. The models are free of
charge but Zen still requires a free key (there is no anonymous access):
# 1. Sign up and copy your key at https://opencode.ai/auth
# 2. Store it in decai's "openai" slot (Zen is OpenAI-compatible):
r2 -qc 'decai -K' /bin/ls # add a line: openai=<your-zen-key>
# or export it: export OPENAI_API_KEY=<your-zen-key>
⚠️ Privacy note for malware analysis. Any cloud backend uploads the disassembly of the analyzed sample to a third party. For sensitive or classified samples, use the local Ollama backend (below) so nothing leaves the host — it is the only key-free, fully private option.
Switch backend by editing config.json → decompiler.options.decai:
// Local / offline (private, no key) — requires Ollama + a local model:
"decai": { "api": "ollama", "model": "qwen2.5-coder:7b",
"host": "http://localhost", "port": 11434 }
// OpenCode Zen (default) — free models, free key:
"decai": { "api": "openai", "model": "big-pickle", "host": "https://opencode.ai/zen" }
api, model and the host(+port)-derived base URL are applied to the
plugin automatically when --decompiler decai runs (decai builds the request
URL as host + /v1/chat/completions). Providers supported by decai:
openai (incl. OpenCode Zen), ollama, ollamacloud, gemini, anthropic,
claude, mistral, xai, deepseek, lmstudio.
If you see
ABI mismatchwarnings forr2ai.dylib, rebuild the backend plugin for your radare2 version:r2pm -ci r2ai.
Python Library
Both helpers return a Result: Ok(outcome) on success or Err(failure) on
error — check with .is_ok() and read the value with .unwrap().
Basic Usage
from bannedfuncdetector.bannedfunc import analyze_file
result = analyze_file(
"/path/to/binary",
decompiler_type="r2ghidra",
output_dir="output",
)
if result.is_ok():
outcome = result.unwrap()
for finding in outcome.report.detected_functions:
print(finding.name, finding.banned_calls)
else:
print("Analysis failed:", result.error)
Directory Analysis
from bannedfuncdetector.bannedfunc import analyze_directory
result = analyze_directory(
"/path/to/binaries",
output_dir="output",
decompiler_type="r2dec",
parallel=True,
)
if result.is_ok():
summary = result.unwrap().summary
print(f"{summary.analyzed_files}/{summary.total_files} files analyzed")
Logging and diagnostics
The CLI uses Python's standard logging module and writes to stderr by default. Set BFD_LOG_DESTINATION=stdout to write to stdout or BFD_LOG_DESTINATION=file:/path/to/bfd.log for a rotating file (10 MiB per file, five backups). Existing root handlers supplied by a host application are retained and take precedence. Text output is the default. Set BFD_LOG_FORMAT=json for one JSON object per line with a UTC timestamp, level, service, component, message, and available operation fields. Set BFD_ENVIRONMENT to attach a deployment environment label. BFD_LOG_LEVEL accepts DEBUG, INFO, WARNING, ERROR, or CRITICAL; -v selects DEBUG unless the environment variable overrides it.
CLI runs receive a request_id; directory jobs pass the same ID to worker processes. BFD_LOG_LEVEL also applies to those workers. Text logs contain a UTC timestamp, component, and available request ID; JSON logs also provide structured operation fields. Analysis completion events include operation, event_name, duration_ms, and outcome. Exception traces and inferred error_type are included when available. No trace/span IDs are generated because the application does not use distributed tracing.
The formatter redacts common credential fields (such as password, access_token, api_key, client_secret, and cookie headers) and escapes ASCII/Unicode control and line-separator characters. Formatting failures use safe placeholders so logging errors do not interrupt analysis. This is a defense in depth measure, not a substitute for minimizing sensitive data at the source: do not log credentials, request/file contents, or confidential data. Logs are not written to local files or sent to a service by the application; configure stderr collection and retention in the deployment environment.
Example:
BFD_LOG_FORMAT=json BFD_LOG_LEVEL=INFO BFD_LOG_DESTINATION=stderr bannedfunc --file ./sample.bin
Requirements
- Supported Python versions: 3.13, 3.14, and 3.15. Python 3.15 is tested on Ubuntu, macOS, and Windows in the CI matrix.
- radare2 (required)
- r2ghidra/r2dec (optional decompilers)
- decai plugin (optional, for AI-assisted decompilation — see "AI decompilation" above)
- See
pyproject.tomlfor Python dependencies
Support the Project
If you find BannedFuncDetector useful, consider supporting its development:
Made with dedication for the reverse engineering community
Metadata
Release files for bannedfuncdetector 3.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| bannedfuncdetector-3.2.0.tar.gz | 269.7 kB | With provenance | Details for bannedfuncdetector-3.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| bannedfuncdetector-3.2.0-py3-none-any.whl | Python 3 | none | any | Details for bannedfuncdetector-3.2.0-py3-none-any.whl |
Total release size: 407.8 kB
Release files / bannedfuncdetector-3.2.0.tar.gz
| Download URL | bannedfuncdetector-3.2.0.tar.gz |
|---|---|
| Size | 269.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1a39c581587ea15532b06a03c69958f3f25e3bc63b499ee2d21fe8b6405d9219
|
|
BLAKE2b-256 checksum How to use checksums |
7ec8c340ca51e4b5d1afa122f29e4505ea93294a05f057bcf59dffa7a0e8ac1c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.
Transparency logRelease files / bannedfuncdetector-3.2.0-py3-none-any.whl
| Download URL | bannedfuncdetector-3.2.0-py3-none-any.whl |
|---|---|
| Size | 138.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a610cbea7ba31a67e1f7e3416e3d86d339ef15739f55beeec768ae05c798eac4
|
|
BLAKE2b-256 checksum How to use checksums |
36bd09741944d7eec81416df5a59dfc0e1175b895f81ae2455a3383961d7dc3d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.
Transparency logSecurity for bannedfuncdetector 3.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for bannedfuncdetector-3.2.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 14, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.