Rust command-line client for the ScanMalware API.
API docs:
- https://scanmalware.com/api-docs
- https://scanmalware.com/openapi.json
- Submit URL scans, poll for completion, and fetch results/summary/progress.
- Batch mode for URLs or scan IDs (file or stdin).
- Search coverage across all search endpoints exposed by the API.
- Output formats:
json,text,csv,raw. - Quiet and silent modes; ANSI color control for text output.
- Health and module ping checks.
- Cross-compile friendly (Rust + rustls, build script included).
curl -fsSL https://scanmalware.com/install.sh | bash[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; irm https://scanmalware.com/install.ps1 | iexbrew tap scanmalware/tap && brew install scanmalware/tap/scanmalware-cliHomebrew 6 gates third-party taps behind an explicit trust step. If the install is refused with "Refusing to load formula ... from untrusted tap", run:
brew trust scanmalware/tapSupported targets: macOS (x86_64, arm64), Linux (x86_64, arm64, armv7), and Windows (x86_64, arm64).
The install scripts verify the downloaded archive against the sha256sums.txt
published with each release and abort on a mismatch.
Install a specific version or custom location (macOS/Linux):
SCANMALWARE_VERSION=0.2.4 \
SCANMALWARE_INSTALL_DIR="$HOME/.local/bin" \
curl -fsSL https://scanmalware.com/install.sh | bashcargo install --path .Or build a local binary:
cargo build --releasescanmalware completions <bash|zsh|fish|powershell|elvish> prints a completion
script covering every command and flag. The Homebrew formula installs them for
bash, zsh and fish automatically; otherwise:
# bash, with bash-completion 2 (loads it on demand)
mkdir -p ~/.local/share/bash-completion/completions
scanmalware completions bash > ~/.local/share/bash-completion/completions/scanmalware
# bash, without bash-completion: add to ~/.bashrc
eval "$(scanmalware completions bash)"
# zsh: write it to a directory on $fpath, then restart the shell
mkdir -p ~/.zfunc
scanmalware completions zsh > ~/.zfunc/_scanmalware
# and in ~/.zshrc, before compinit runs:
# fpath=(~/.zfunc $fpath)
# autoload -Uz compinit && compinit
# fish
mkdir -p ~/.config/fish/completions
scanmalware completions fish > ~/.config/fish/completions/scanmalware.fish# PowerShell: add this line to $PROFILE to keep it
scanmalware completions powershell | Out-String | Invoke-ExpressionEach GitHub release also carries scanmalware-completions.tar.gz with the
generated scripts for every shell. They are tied to that release's commands, so
regenerate them after an upgrade if you installed them by hand.
Run the CLI directly from Docker Hub (multi-arch linux/amd64, linux/arm64, linux/arm/v7):
docker run --rm jonaslejon/scanmalware-cli:latest --help
docker run --rm jonaslejon/scanmalware-cli:latest scan https://example.com --wait
docker run --rm jonaslejon/scanmalware-cli:latest search screenshot-hash phash bc3c3cc1c3c3c3c3 --limit 5The image is distroless (gcr.io/distroless/cc-debian13): the binary plus
glibc, with no shell or package manager, so --entrypoint sh does not work.
It runs unprivileged (uid 10001) with /work as its working directory.
To write output files into a bind mount, pass your own uid/gid:
docker run --rm --user "$(id -u):$(id -g)" -v "$PWD:/work" \
jonaslejon/scanmalware-cli:latest screenshot get <scan_id> --output /work/shot.pngIf you want to pass environment variables:
docker run --rm \
-e SCANMALWARE_BASE_URL=https://scanmalware.com \
-e SCANMALWARE_TIMEOUT=60 \
jonaslejon/scanmalware-cli:latest healthSCANMALWARE_BASE_URL(default:https://scanmalware.com)SCANMALWARE_TIMEOUT(request timeout in seconds, default:60)SCANMALWARE_API_KEY(optional): an API key from your account page (keys start withsm_pat_). Or store it once withscanmalware config set api-key, which asks for it and saves it to~/.config/scanmalware/config.yaml(mode 0600).
Command-line flags override environment variables. Most commands work without a key, but anonymous scan submissions are limited to about one a minute (a burst of 3). With an API key, scan submissions are not limited that way, other requests get a higher rate limit, and your scans are filed under your account. The limits are described in Getting Started.
If scanmalware alone feels too minimal, use the built-in help:
scanmalware --help
scanmalware scan --help
scanmalware search --help
scanmalware technologies --help
scanmalware pcap --help
scanmalware yara --help
scanmalware malware --help
scanmalware tls --help
scanmalware screenshot --helpscanmalware scan https://example.com
scanmalware scan https://example.com --wait --wait-interval 5 --wait-timeout 600
scanmalware scan https://example.com --unlisted
scanmalware result <scan_id>
scanmalware summary <scan_id>
scanmalware progress <scan_id>
scanmalware recent --page 1 --limit 20
scanmalware health
scanmalware ping--wait polls until the scan has been captured and its security verdict and
AI analysis have landed (the result's verdicts_ready), usually within a
minute or two of the capture, then prints the result. Slower background lookups (RDAP, for one) can still arrive
minutes later; scanmalware result <scan_id> fetches them. If time runs out
after the capture, the result is printed as it stands with a warning, and the
verdict wait never exceeds 5 minutes. Exit code 9 is only for a scan still
queued or processing.
While it waits it polls the small progress endpoint, then the compact result
for the verdict, and fetches the full result once at the end. A poll that fails
on a network error, a 5xx, a 429 or a 404 is retried (with a warning) up to 5
times in a row before the wait gives up with that error's exit code. A scan
that ends with status failed is printed, then exits 1.
The verdict --wait prints is the first one available, not necessarily the
final one: the AI verdict can still change for a few minutes, and a scan can be
re-judged later (a late JavaScript finding or a second-browser capture re-runs
it, within 24 hours). Re-read with scanmalware result <scan_id> when the
verdict matters.
Global flags can be placed before or after the subcommand:
scanmalware --format text --color always stats
scanmalware stats --format text --color alwaysGlobal options:
--base-url <URL> Override API base URL (or SCANMALWARE_BASE_URL)
--timeout-secs <SECS> Request timeout in seconds, at least 1, default 60 (or SCANMALWARE_TIMEOUT);
180 for a TLSH search with --sample-percent above 0.1
--format <FORMAT> text | json | csv | raw; or --text, --json, --csv, --raw
--csv-expand With CSV output, one row per item of the response's list field
--color <MODE> auto | always | never (auto honours NO_COLOR)
--quiet Suppress banner, batch headers, warnings, and progress output
--silent Suppress all output, including errors
--with-input In batch mode, tag each JSON line / CSV row with its input
In text mode the command banner goes to stderr, so scanmalware ... | grep or a
redirect to a file gets only the response. Warnings also go to stderr, in every
output format, so --json output stays clean; only --quiet and --silent
drop them.
# Scan and wait for the verdict (text output)
scanmalware scan https://example.com --wait
# JSON output for a result
scanmalware result <scan_id> --format json
# The same result without the large request logs (typically 70-95% smaller);
# the dropped fields are listed in `compacted`
scanmalware result <scan_id> --compact --format json
# Scan then fetch summary
scanmalware scan https://example.com --wait --format json
scanmalware summary <scan_id>
# OCR text for a scan
scanmalware ocr text <scan_id>
# PCAP metadata + download (decrypted, gzipped)
scanmalware pcap metadata <scan_id>
scanmalware pcap get <scan_id> # writes <scan_id>.pcap.gz
scanmalware pcap get <scan_id> --output scan.pcap.gz
# Hunting-rule (YARA) matches, stats, and recent threats
# (`hunting-rules` is an alias for `yara`; both use /api/v1/hunting-rules)
scanmalware yara scan <scan_id>
scanmalware yara stats
scanmalware hunting-rules recent --hours 24 --limit 50
# Antivirus malware results, stats, and recent threats
scanmalware malware scan <scan_id>
scanmalware malware stats
scanmalware malware recent --hours 24 --limit 50
# TLS/SSL certificate analysis
scanmalware tls cert <scan_id> # JSON: subject, issuer, validity, fingerprints
scanmalware tls asn1 <scan_id> # ASN.1 parsed structure + raw dump
scanmalware tls download <scan_id> # writes <scan_id>.pem
scanmalware tls download <scan_id> --output cert.pem
# Screenshots
scanmalware screenshot get <scan_id> # writes <scan_id>.png
scanmalware screenshot get <scan_id> --width 800 --output thumb.png
scanmalware screenshot get <scan_id> --image-format webp --output thumb.webp
scanmalware screenshot stats
scanmalware screenshot duplicates --hash-type phash --max-distance 0 --limit 20
scanmalware screenshot duplicates --hash-type crop_resistant --max-group-members 25
# --limit counts groups, not scans; --max-group-members caps members per group
# (default 10). Each member carries group_size with the true total.
# duplicates is exact-match only (--max-distance 0). For fuzzy matching against
# a single hash use `search screenshot-similar --max-distance 0..10` or
# `search screenshot-hash --similarity-threshold 0..64`.
# Search OCR text
scanmalware search ocr "login" --limit 5
# CSV output for a search
scanmalware search scans "example" --limit 10 --format csv
# Search technologies (top-level command)
scanmalware technologies search --query cloudflare --limit 5
# Batch scan (NDJSON output)
scanmalware scan --batch urls.txt --format json > scans.ndjson
# Search by screenshot hash (hex values)
scanmalware search screenshot-hash phash bc3c3cc1c3c3c3c3 --limit 5
scanmalware search screenshot-hash dhash 2026000000000000 --limit 5
scanmalware search screenshot-hash color_hash 07000050041 --limit 5
# Within N differing bits (phash/ahash/dhash/whash; capped at the 10,000 nearest)
scanmalware search screenshot-hash phash bc3c3cc1c3c3c3c3 --similarity-threshold 6 --limit 5
# Search similar screenshots (decimal *_int, 16-character *_hex, or 64-bit string)
scanmalware search screenshot-similar 13563782980643832771 --hash-type phash --max-distance 5 --limit 5
scanmalware search screenshot-similar 2316539058328698880 --hash-type dhash --max-distance 5 --limit 5
scanmalware search screenshot-similar bc3c3cc1c3c3c3c3 --hash-type phash --max-distance 5 --limit 5
# Scans of a domain, newest first (no paging; --limit up to 100)
scanmalware domain scans example.com --status completed --limit 50
# TLSH search (JS segments)
scanmalware search js-segments tlsh <tlsh_hash> --max-distance 30 --limit 50 --include-known-libraries true
# --sample-percent 0 skips the random sample and keeps only the exhaustive tiers.
# It is a percentage capped at 1 (1%), not a fraction. Above 0.1 the search can
# take over a minute, so unless you set --timeout-secs the CLI waits up to 180 s.
scanmalware search js-segments tlsh <tlsh_hash> --sample-percent 0
scanmalware search js-segments tlsh <tlsh_hash> --sample-percent 1
# Semantic search: one result per site, most-scanned sites first, and only
# results within 0.05 of the best match
scanmalware search semantic "bank login" --per-site --sort site-scans --within 0.05 --limit 10
# AI classification labels: LEGITIMATE, LOW_RISK, MODERATE_RISK, HIGH_RISK,
# CONFIRMED_SCAM (any case)
scanmalware search ai classification high_risk --limit 20
# ASN search: with or without the AS prefix (scan results show both forms)
scanmalware search asn AS54113 --limit 5Notes:
- Use
screenshot_hashes.*_hexforsearch screenshot-hash. search screenshot-similartakesscreenshot_hashes.*_intor*_hex(or the 64-character bit string). A 16-character value is always read as hex, as the API does.- Color hashes (
screenshot_hashes.color_hash) are 11 hex digits, such as07000050041. Before 2026-11-08 they were 6-digit#rrggbbvalues that did not describe the screenshot; the API now refuses those with a 400 (exit 4), and older scans have no color hash until they are rescanned. Values are percent-encoded before being placed in the URL, so hashes containing/(ssdeep) or other reserved characters are passed through intact.
Batch mode accepts a file path or - for stdin, one input per line; blank lines
and # comments are skipped. Files may be UTF-8, with or without a byte-order
mark, or UTF-16 with one (what PowerShell 5's > writes). Batch JSON output is
NDJSON, and batch --raw output ends each body with a newline.
scanmalware scan --batch urls.txt
scanmalware result --batch scan_ids.txt
cat urls.txt | scanmalware scan --batch -By default each NDJSON line is the API response as-is, and a request that gets
no response at all (a timeout, say) writes nothing to stdout, only an error to
stderr. With --with-input there is exactly one line per input, and it says
which input it belongs to:
scanmalware --json --with-input progress --batch scan_ids.txt
# {"input":"<scan_id>","response":{...},"status":200}
# {"input":"not-a-uuid","response":{"error":"Invalid scan ID format",...},"status":400}
# {"error":"request failed: ... operation timed out","input":"<scan_id>","status":null}With --csv, --with-input adds an input column (and an error column for
requests that got no response). --fail-fast stops at the first failure and
reports it once, naming the input.
-
text(default): human-readable tree output with optional ANSI color. -
json: pretty-printed JSON for a single response. -
csv: one row per response, one column per top-level key, with nested values encoded as JSON strings. In batch mode this is one row per item over the union of all keys. Add--csv-expandto get one row per item of the response's list field (results,threats,groups, ...) instead, which is usually what you want for a search or a listing:scanmalware --csv recent --limit 20 # 1 row, results as a JSON blob scanmalware --csv --csv-expand recent --limit 20 # 20 rows, one column per field
-
raw: raw response body (useful for binary endpoints). In batch mode each body is followed by a newline unless it already ends with one.
Use --quiet to suppress the banner, batch headers, warnings, and progress output.
Use --silent to suppress all output, including errors.
Use --color auto|always|never for text output. Under auto (the default),
a non-empty NO_COLOR environment variable turns colour off
(no-color.org); --color always still wins.
| Code | Meaning |
|---|---|
| 0 | Success, or the reader closed stdout (scanmalware ... | head) |
| 1 | Other or unexpected error, a batch whose failures had different codes, or scan --wait on a scan that ended as failed |
| 2 | Usage error: bad flags or arguments, input such as invalid --options JSON, or ./.. as an ID |
| 3 | HTTP 404: the scan, domain or other resource was not found |
| 4 | Any other HTTP 4xx: validation (400/422), authentication (401/403) |
| 5 | HTTP 5xx: the API failed |
| 6 | Network error or timeout: no usable response arrived |
| 7 | Local I/O error: output file, batch file, or config file |
| 8 | HTTP 429: rate limited; wait and retry |
| 9 | scan --wait timed out while the scan was still queued or processing |
A closed stderr does not change the code: a warning or error line nobody can read is dropped.
A GET answered with a 503 or 429 that carries Retry-After of at most 60
seconds is retried once after that wait, with a warning on stderr. The API
sends one when asking again should work: a cold technologies popular window
being computed, a ct_* SMQL filter while the certificate-transparency store
is busy, and the rate limits. Exit 5 or 8 then means the retry failed too, or
the wait asked for was longer. Requests that submit something (POST) are
never retried.
In batch mode the exit code is the one every failed input shared, or 1 when
they differed. --with-input records each input's HTTP status, so a script
that needs per-input detail reads it there. --fail-fast exits with the code
of the input it stopped at.
scanmalware --quiet result "$id" > result.json
case $? in
0) echo "done" ;;
3) echo "no such scan" ;;
6|8) echo "transient, retry later" ;;
*) echo "failed" ;;
esacBefore 0.2.0 every failure exited 1.
SMQL is the unified query language for searching the scan index. Supports field
filters, boolean operators (AND, OR, NOT), negation (-field:value),
wildcards (domain:*bank.com, url:*login*), ranges
(js_risk_score:60..100), relative dates (submitted:last7d), and existence
checks (has:malware).
Note: on domain:, leading-dot wildcards like *.bank.com are not currently
matched server-side β use *bank.com or *bank* instead. The host filters
below do support that form.
smql filters lists every available filter. The host-oriented ones are useful
for mapping a domain's footprint, and unlike domain: they accept
*.example.com:
| Filter | Meaning |
|---|---|
contacted_host |
Host the browser actually resolved and requested. Observed evidence. |
script_host |
Host of a script the browser actually loaded. Observed evidence. |
js_host |
Host called from a URL sink inside script source. Static finding. |
csp_host |
Host named in the page's CSP. Declared intent, not contact. |
ct_domain |
Domain seen in Certificate Transparency logs. |
ct_san |
Certificate Subject Alternative Name. |
These return scans, not hostnames. To turn them into a subdomain list, pull the names out of the per-scan endpoints β certificate SANs give the highest yield:
# every subdomain named in the certificates of scans covering the apex
scanmalware --quiet --json smql query 'ct_san:*.example.com' --limit 25 \
| jq -r '.results[].scan_id' \
| while read -r id; do scanmalware --quiet --json tls cert "$id"; done \
| jq -r '.sans.dns_names[]?' \
| grep -E '(^|\.)example\.com$' | sort -u
# hosts a scan actually talked to
scanmalware --quiet --json smql query 'contacted_host:*.example.com' --limit 25 \
| jq -r '.results[].scan_id' \
| while read -r id; do scanmalware --quiet --json result "$id"; done \
| jq -r '.domains_contacted[]?' \
| grep -E '(^|\.)example\.com$' | sort -uCoverage is passive: it reflects what the index has scanned, so a domain whose hosts present a large multi-SAN certificate yields far more than one behind a wildcard cert.
scripts/subdomains.sh wraps all of this up:
scripts/subdomains.sh example.com # default 25 scans per source
scripts/subdomains.sh example.com 50If a request fails (a rate limit, or a source such as Certificate Transparency search being unavailable), the script still prints what the other sources found, then names each failed request on stderr and exits non-zero, so a partial list is never mistaken for a complete one.
# Run a query
scanmalware smql query "domain:paypal.com"
scanmalware smql query "(technology:WordPress OR technology:Joomla) AND country:CN" --limit 50
scanmalware smql query "has:malware AND submitted:last7d" --sort oldest
scanmalware smql query "title:login" --count-only # empty results; count in pagination.total_items
# Index stats
scanmalware smql stats
# All available filters, grouped by category
scanmalware smql filters --format jsonOptions on smql query: --page (max 1000), --limit (max 100), --sort
(newest|oldest|url|load-time|ip-count), --count-only.
Negated queries start with - and can be passed as they are; the older form
after -- still works:
scanmalware smql query "-domain:google.com login" --limit 10
scanmalware smql query --limit 10 -- "-domain:google.com login"Search commands are organized under scanmalware search. Use scanmalware search --help
to see the full list.
Core search:
search scanssearch asnsearch ipsearch ip-statssearch jarmsearch faviconsearch favicon-mmh3search fuzzysearch clipboard-suspicioussearch ocrsearch ocr-patternsearch screenshot-hashsearch screenshot-similarsearch semanticsearch similarsearch cpesearch registrarsearch technologies
Every numeric option, length limit and fixed value list in the API spec is
checked locally, so --limit 101 or a 2-character search fails at once with
the allowed range (--help shows it too) rather than after a round trip.
AI and analyzer search:
search ai classificationsearch ai high-risksearch ai scam-typesearch analyzers high-risk
JavaScript search:
search js-fingerprinter2 code-hashsearch js-fingerprinter2 composite-hash(deprecated: the hash is per scan)search js-fingerprinter2 coveragesearch js-fingerprinter2 healthsearch js-fingerprinter2 js-obfuscationsearch js-fingerprinter2 malware-families(deprecated: disabled server-side, returns no families)search js-fingerprinter2 signaturesearch js-fingerprinter2 similarsearch js-segments hashsearch js-segments normalizedsearch js-segments tlshsearch js-fingerprints bundlersearch js-fingerprints fuzzy(exact match on the wholehashes.fuzzyvalue, about 500 characters; not an ssdeep similarity search)search js-fingerprints librarysearch js-fingerprints library-versionsearch js-fingerprints md5search js-fingerprints normalizedsearch js-fingerprints sha1search js-fingerprints sha256
Use request for arbitrary JSON endpoints and download for binary payloads.
scanmalware request --method get --path /api/v1/search --query q=example --query page=1
scanmalware download --path /api/v1/pcap/<scan_id> --output scan.pcap.gz
echo '{"hash_value":"bc3c3cc1c3c3c3c3","hash_type":"phash","max_distance":2}' \
| scanmalware request --method post --path /api/v1/screenshot/search --body-file ---body-file (and scan --options-file) read stdin when given -, and accept
the same encodings as batch files.
Every --output (here and on pcap get, tls download, screenshot get)
accepts - to write to stdout, e.g. scanmalware pcap get <scan_id> --output - | gunzip | tshark -r -. Files are written to a temporary .part file and
renamed into place only once complete, so a failed download leaves an existing
file untouched.
For packet captures specifically, prefer the dedicated pcap command:
scanmalware pcap metadata <scan_id> # JSON: file_size_bytes, available, etc.
scanmalware pcap get <scan_id> # download to <scan_id>.pcap.gz
scanmalware pcap get <scan_id> --output my.pcap.gz # custom pathThis project uses reqwest with rustls to reduce OS-specific dependencies. The
scripts/build-release.sh script builds Linux, Windows, and macOS targets.
cargo install cargo-zigbuild
# Install Zig 0.13.0 from https://ziglang.org/download/ (the version the release
# workflow pins; Zig 0.17 fails to link the Windows targets)
./scripts/build-release.shNotes:
- Building macOS targets on non-macOS hosts requires a macOS SDK (for example via
osxcross). - You can also build native binaries on each OS with
cargo build --release.
- Negative mmh3 hashes can be passed directly
(
scanmalware search favicon -1670507450 --limit 1); the older-- -1670507450form still works. So can negative scores (search semantic "bank login" --threshold -0.5), SMQL negations and OCR patterns that start with-. search ocr-patternandocr patternmatch the text literally, as a case-insensitive substring (add--case-sensitive); they do not take a regex.- Increase
--timeout-secs(default 60) if requests time out on long-running endpoints. - With an API key set, the key is sent only to the
--base-urlorigin. A redirect to another host is refused rather than followed, and an absolute URL passed torequest/download --pathgoes out without the key.
