Implementation:7onez Cti expert Binary Auto Analyze Target
| Knowledge Sources | |
|---|---|
| Domains | OSINT, Binary_Analysis, Pipeline |
| Last Updated | 2026-10-28 14:00 GMT |
Overview
Concrete tool for running a complete binary analysis (acquire → analyze → save → ingest) with case directory integration and completeness gating, provided by the cti-expert pipeline integration module.
Description
The analyze_target function in binary_auto.py is the pipeline-integration wrapper around analyze_artifact.analyze. It runs the full static analysis on one binary (local path or URL), and with a case_dir it:
- Saves the sample under <case>/bin (the canonical store for the completeness gate).
- Writes the analysis JSON to <case>/bin/analysis/<sha256>.json.
- Ingests it into the KB (via binary_auto.ingest) — which also registers REA nodes for the harness.
- Enforces the hostile-egress policy: on hostile infra, a direct download URL is refused (it would touch attacker infra from your IP).
The function returns a summary dict, never raises. The ingest function reads binary analysis JSONs, re-checks the completeness gate (_complete), and ingests only docs that pass — a truncated/forged JSON left by an interrupted run never reaches the KB on a later pass.
Usage
Import this when you need to:
- Run a full binary analysis from the pipeline (shared by /cti <binary> and the harness).
- Save the sample and JSON to the canonical case directory structure.
- Ingest binary evidence into the KB with REA node registration.
- Enforce hostile-egress on binary downloads.
Code Reference
Source Location
- Repository: cti-expert
- File: intel_engine/tools/binary_auto.py
- Lines: L52-125 (analyze_target), L206-231 (ingest)
Signature
def analyze_target(target, *, case_dir=None, kb=None, keep=None, hostile=False, rea=True,
root=ROOT, timeout=240):
"""Statically analyze ONE binary (local path or URL), REA included unless rea=False.
With a case_dir the sample is kept under <case>/bin, the JSON lands in
bin/analysis/<sha256>.json, and it is ingested into `kb`. Returns a summary dict,
never raises."""
def ingest(case_dir, kb):
"""Ingest binary evidence separately; raw/ remains exclusively web-host evidence.
Only docs that pass the completeness gate are ingested."""
Import
from binary_auto import analyze_target, ingest
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| target | str | Yes /// Local file path or URL | |
| case_dir | str | No /// Case directory (enables save + ingest) | |
| kb | str | No /// KB root path (enables ingest) | |
| hostile | bool | No /// Deny direct download (default False) | |
| rea | bool | No /// Run REA deep-static layer (default True) | |
| timeout | int | No /// Total timeout (default 240) |
Outputs
| Name | Type | Description |
|---|---|---|
| out | dict | {ok, error, leads, saved, host, sha256, n_pivots, packed, ingest_note?} |
Usage Examples
Pipeline-Integrated Analysis
from binary_auto import analyze_target
out = analyze_target(
target="/path/to/sample.apk",
case_dir="cases/CASE-0001",
kb="intel_engine/knowledge",
rea=True,
)
if out["ok"]:
print(f"saved: {out['saved']}")
print(f"sha256: {out['sha256']}")
print(f"pivots: {out['n_pivots']}")
else:
print(f"error: {out['error']}")
Hostile Egress (Block URL)
# On hostile infra, a direct download is refused
out = analyze_target(
target="https://example.com/sample.apk",
case_dir="cases/CASE-0001",
hostile=True,
)
# out["error"] = "BLOCKED by egress policy: refusing a direct download..."
Related Pages
Implements Principle
- Principle:7onez_Cti_expert_Static_IOC_Extraction
- Principle:7onez_Cti_expert_Provenance_Idempotent_Ingest