Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fileanalyzer

Python Tests Coverage License

Analyse a file for malicious or risky content, combining two CIRCL engines:

  1. hashlookup — instant known-file triage against public catalogues (NIST NSRL, Windows builds, Linux distribution packages, CDNJS, Snap). Known-benign files resolve in milliseconds without deeper analysis.
  2. Pandora — deep behavioural file analysis (via pypandora) for everything the triage cannot clear.
             ┌────────────┐   known-benign    ┌─────────┐
 file ─hash─▶│ hashlookup │──────────────────▶│  INFO   │
             └─────┬──────┘   (short-circuit) └─────────┘
                   │ unknown / single-source / offensive-distro
                   ▼
             ┌────────────┐  ALERT→CRITICAL  WARN→HIGH
             │  Pandora   │──────────────────────────────▶ verdict
             └────────────┘  CLEAN→LOW  timeout→MEDIUM

Triage policy — known ≠ benign

A hashlookup hit means the file is catalogued, not that it is safe. The short-circuit therefore only fires when both hold:

  • hashlookup:trust is strictly above 50 — the file appears in more than one independent source (50 means "no opinion", a single source);
  • the source is not an offensive distribution (Kali, BlackArch) — their packages (password crackers, lateral-movement tooling) are catalogued but still deserve deep analysis.

Records carrying a KnownMalicious marker escalate straight to CRITICAL. Both knobs live in fileanalyzer/constants.py (TRUST_THRESHOLD, OFFENSIVE_SOURCE_MARKERS). The full hashlookup context (trust, source, catalogued filename) is always shown in the report, so short-circuited verdicts remain auditable.

Installation

python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"

Usage

fileanalyzer check suspicious.pdf                      # full pipeline
fileanalyzer check sample.exe --no-pandora             # triage-only mode
fileanalyzer check sample.exe --json                   # machine-readable output
fileanalyzer check sample.exe --output report.html     # export (.txt/.svg/.html)
fileanalyzer check sample.exe --pandora-url https://pandora.internal/
fileanalyzer info verdicts                             # verdict mapping + policy
fileanalyzer info engines                              # live engine status
fileanalyzer --version

The Pandora instance defaults to https://pandora.circl.lu/ and can be overridden with --pandora-url or the FILEANALYZER_PANDORA_URL environment variable.

Exit codes

Code Meaning
0 File is clean (verdict INFO or LOW)
1 Risky file (MEDIUM/HIGH/CRITICAL) or invalid input
2 Network / engine error (hashlookup or Pandora unreachable)

Verdicts

Severity Meaning
CRITICAL Known-malicious hash, or Pandora ALERT
HIGH Pandora WARN — suspicious content
MEDIUM Analysis inconclusive (timeout/error) or skipped for an unknown file
LOW Pandora CLEAN — no detection, file not in the known DB
INFO Known benign file — hashlookup short-circuit

Library API

from fileanalyzer.assessor import assess

report = assess("suspicious.pdf")
print(report.verdict)          # VerdictSeverity.LOW
print(report.triage.reason)    # triage explanation
if report.analysis:
    print(report.analysis.link)  # Pandora report URL

Running Tests

python -m pytest             # full suite with coverage
python -m pytest --tb=short -q

The test suite has 80 tests with 100% coverage. All network I/O is mocked at the hashlookup_utils / pandora_utils boundaries — no live calls.

License

GPL-3.0 — see LICENSE.

About

File analysis — CIRCL hashlookup known-file triage + Pandora deep behavioural analysis

Resources

Contributing

Security policy

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages