Skip to main content

CLI Reference

Complete documentation for all Batin command-line options.

Global Syntax

batin [GLOBAL OPTIONS] <COMMAND> [COMMAND OPTIONS]

Global Options

These options apply to any command.

OptionShortDescription
--format <FORMAT>Output format: table, json, csv, ndjson, sarif, or html
--jsonShorthand for --format json
--csvShorthand for --format csv
--yara <FILE>Load and apply YARA rules from a file (needs the yara build feature)
--verbose-vEnable verbose logging
--help-hShow help information
--version-VShow version information

If both --format and --json/--csv are given, --format wins.

Commands

scan - Scan Files or Directories

Analyze files for type detection and threat assessment.

batin scan <PATH> [OPTIONS]

Arguments

ArgumentDescription
PATHFile or directory path to scan

Options

OptionShortDescriptionDefault
--recursive-rScan directories recursivelyfalse
--output-oOutput file path for resultsstdout
--exclude-eExclude files matching glob pattern (repeatable)none
--min-threatMinimum threat level to showall
--hashInclude MD5/SHA-256 hashesfalse
--scan-archivesRecurse into ZIP/TAR/tar.gz and report nested entriesfalse
--max-archive-depthMaximum archive recursion depth4
--signatures <FILE>Load extra JSON signatures before scanningnone
--concurrency <N>Files to detect in parallel (0 = auto)0
--hash-deny <FILE>Flag files whose SHA-256 is in this denylistnone

Nested archive entries are reported with a path of archive::inner/file.

Threat Level Values

  • safe - Show all files
  • suspicious - Show suspicious and above
  • dangerous - Show dangerous and critical only
  • critical - Show only critical threats

Examples

# Basic file scan
batin scan document.pdf

# Recursive directory scan
batin scan /home/user/Downloads --recursive

# Exclude patterns
batin scan /project -r --exclude "*.log" --exclude "target/*"

# Show only dangerous files
batin scan /uploads -r --min-threat dangerous

# JSON output with hashes
batin scan /evidence -r --json --hash --output report.json

# CSV output
batin scan /samples -r --csv --output results.csv

watch - Real-Time Monitoring

Monitor a directory for new and modified files in real-time.

batin watch <PATH> [OPTIONS]

Arguments

ArgumentDescription
PATHDirectory path to watch

Behavior

  • Monitors recursively by default
  • Debounces duplicate events (200ms window)
  • Waits for file stabilization before scanning (50ms)
  • Shows live results as files are created/modified

Examples

# Watch downloads folder
batin watch ~/Downloads

# Watch with verbose logging
batin watch /var/log --verbose

Output Format

  HH:MM:SS ✓ filename.ext [type] threat_level
└─ Additional details (if applicable)

The watcher stops cleanly on Ctrl+C (SIGINT) or SIGTERM.


completions - Shell Completions

Print a completion script for your shell to stdout.

batin completions <SHELL>

SHELL is one of bash, zsh, fish, elvish, or powershell.

# Install bash completions for the current user
batin completions bash > ~/.local/share/bash-completion/completions/batin

man - Man Page

Print a roff man page to stdout.

batin man > batin.1

serve - HTTP API Daemon

Run a small HTTP service for detection. Requires the server build feature.

batin serve [--addr <ADDR>]
OptionDescriptionDefault
--addrAddress to bind127.0.0.1:8080

Endpoints:

  • GET /health returns 200 ok
  • POST /scan detects the request body and returns the result as JSON
curl --data-binary @suspicious.exe http://127.0.0.1:8080/scan

The server stops cleanly on Ctrl+C or SIGTERM.


reputation - Hash Reputation Lookup

Look up a SHA-256 on VirusTotal. Requires the online build feature.

batin reputation <SHA256> [--api-key <KEY>]

The API key may be passed with --api-key or the VT_API_KEY environment variable. The command exits 2 if the hash is flagged by any engine.

export VT_API_KEY=your_key_here
batin reputation 44d88612fea8a8f36de82e1278abb02f

Output Formats

Table (Default)

Human-readable table with colored output:

╭─────────────────┬──────┬────────────┬───────────┬───────────╮
│ File │ Type │ Confidence │ Threat │ Details │
├─────────────────┼──────┼────────────┼───────────┼───────────┤
│ document.pdf │ pdf │ 95% │ ✓ Safe │ ─ │
│ malware.exe │ exe │ 90% │ ⚠ Dangerous│ 📦 Packed │
╰─────────────────┴──────┴────────────┴───────────┴───────────╯

JSON

batin scan file.pdf --json
[
{
"path": "/path/to/file.pdf",
"file_type": {
"extension": "pdf",
"mime_type": "application/pdf",
"confidence": 0.95,
"entropy_profile": {
"global_entropy": 4.23,
"chi_square": 245.8,
"is_packed": false,
"is_encrypted": false
},
"threat_level": "Safe",
"detected_formats": ["pdf"],
"embedded_threats": [],
"hashes": null,
"binary_metadata": null,
"warnings": []
}
}
]

The warnings array carries non-fatal notices such as an extension mismatch.

Other formats

--format ndjson emits one JSON object per line (useful for streaming into log pipelines). --format sarif produces a SARIF 2.1.0 report for code-scanning dashboards. --format html writes a self-contained report. See Output Formats for full examples of each.

CSV

batin scan /dir -r --csv
Path,Type,MIME,Confidence,Threat Level,Entropy,Is Packed,Is Encrypted,Polyglot,Embedded Threats,MD5,SHA256
/path/file.pdf,pdf,application/pdf,95.0%,Safe,4.23,false,false,,,
/path/packed.exe,exe,application/x-dosexec,90.0%,Dangerous,7.85,true,false,,,

Exit Codes

CodeMeaning
0Success
1Error, such as a missing file, bad argument, or a missing build feature
2reputation: the hash was flagged by at least one engine

Environment Variables

VariableDescription
VT_API_KEYVirusTotal API key for batin reputation (online feature)
RUST_LOGLog filter for tracing output (for example RUST_LOG=debug)
NO_COLORDisable colored output when set

Examples by Use Case

Security Audit

# Scan uploads folder for threats, output JSON report
batin scan /var/www/uploads -r --json --hash \
--min-threat suspicious \
--output audit-report.json

Malware Triage

# Quick scan of suspicious samples
batin scan /malware-samples -r --min-threat dangerous

Forensic Investigation

# Full scan with hashes for evidence collection
batin scan /evidence -r --json --hash --output case-001.json

CI/CD Pipeline

# Fail if any dangerous files found
batin scan ./dist -r --min-threat dangerous --json | jq -e 'length == 0'

Watch Downloads (Interactive)

# Monitor and alert on new files
batin watch ~/Downloads -v

Pro Tip

Combine --json output with jq for powerful filtering:

batin scan /uploads -r --json | jq '.[] | select(.file_type.threat_level != "Safe")'