Skip to main content

MalSearch Tweet

Search for samples from various malware databases.

PyPi Python Versions Read The Docs Build Status Security Coverage Status License

This library communicates with the APIs of the following malware databases to download samples by hash and, for some of them, to get feeds of recent sample hashes:

Service Name in config Download by Feed Notes
ANY.RUN anyrun MD5, SHA1, SHA256 requires a TI Lookup license
AndroZoo androzoo SHA256 Android apps only ; API key granted on request
Hybrid Analysis hybridanalysis SHA256 ✓ downloading requires a vetted account
Joe Sandbox joesandbox MD5, SHA1, SHA256 downloading may require a Cloud Pro account
Koodous koodous SHA256 Android apps only ; no downloads with the free plan
Maldatabase maldatabase ✓
Malpedia malpedia MD5, SHA256
MalShare malshare MD5, SHA1, SHA256 ✓
Malware Bazaar malwarebazaar MD5, SHA1, SHA256 ✓ at most 2000 downloads per day
Malware-Feed malwarefeed SHA256 ✓ uses a GitHub token instead of an API key
MetaDefender metadefender MD5, SHA1, SHA256 ✓ downloads for malware exchange partners only
PolySwarm polyswarm MD5, SHA1, SHA256
SOREL-20M sorel20m SHA256 no API key ; Windows PE only (static dataset, 2020)
theZoo thezoo MD5, SHA1, SHA256 ✓ no API key ; first use indexes ~420 MB of archives
Triage triage MD5, SHA1, SHA256, SHA512
UnpacMe unpacme SHA256 ✓ paid plan ; monthly download limit ; supports -u
URLhaus urlhaus SHA256 ✓ same Auth-Key as the other abuse.ch services
VirusShare virusshare MD5, SHA1, SHA224, SHA256, SHA384, SHA512
VirusTotal virustotal MD5, SHA1, SHA256 downloading requires a premium API key ; supports -u

A service is only asked for the hash types it supports.

pip install malsearch

Usage

Configuration

MalSearch reads the API keys from an INI configuration file, by default ~/.malsearch.conf. Each key is set in the API keys section under the client's name from the table above; only the clients listed there are used, except a client named with --select, which gets a warning if its key is missing. SOREL-20M and theZoo need no key: list them with an empty value (sorel20m =, thezoo =) to use them.

theZoo only publishes the hashes of its archives, not of the samples inside. On first use, MalSearch downloads every archive listed in theZoo's maldb.db (about 420 MB, which takes several minutes) and builds an index of the sample hashes in the user cache directory (~/.cache/malsearch/thezoo.json on Linux). Later runs only download the archives that changed.

[API keys]
androzoo = YOUR-KEY
anyrun = YOUR-KEY
hybridanalysis = YOUR-KEY
joesandbox = YOUR-KEY
koodous = YOUR-TOKEN
maldatabase = YOUR-KEY
malpedia = YOUR-KEY
malshare = YOUR-KEY
malwarebazaar = YOUR-KEY
malwarefeed = YOUR-GITHUB-TOKEN
metadefender = YOUR-KEY
polyswarm = YOUR-KEY
sorel20m = 
thezoo = 
triage = YOUR-KEY
unpacme = YOUR-KEY
urlhaus = YOUR-KEY
virusshare = YOUR-KEY
virustotal = YOUR-KEY

When a service hits its rate limit or rejects its API key, MalSearch disables that client for a while. It records this in a Disabled section of the same file, with an expiration date (DD/MM/YYYY HH:MM:SS), and re-enables the client automatically once that date has passed. You can also add an entry yourself to disable a client temporarily. An entry whose value is not a date disables the client until you remove it.

Command line

# download a sample (MD5, SHA1, SHA224, SHA256, SHA384 or SHA512) to the current directory
malsearch 2037f9b7dd268eef7d2e950b27c6cf80e3ba692d262c785ab67b04dc71c99bf9

# only query some clients (or exclude some with --skip) ; put the hashes first, as --select and --skip take all
#  the names that follow them
malsearch 094fd325049b8a9cf6d3e5ef2a6d4cc6a567d7d49c35f8bb8dd9e3c6acf3d78d --select malwarebazaar virustotal

# download every hash from a newline-separated list into the "samples" folder, without the requests cache
malsearch -f hashes.txt -o samples --disable-cache

# download the latest samples published by the hash feeds
malsearch -m -o samples

# idem, only keeping the Windows and Linux executables
malsearch -m -o samples --format pe elf

# only download 10 samples from the hash feeds
malsearch -m -n 10 -o samples
Option Description
-f, --from-file FILE read hashes from a file (one per line)
-m, --from-malware-feed get hashes from the malware feeds
--format FORMAT [FORMAT ...] only keep the feed entries of the given file formats (e.g. pe, elf, apk)
-n, --number N only take the first N distinct hashes from the malware feeds
-c, --config FILE INI configuration file (default: ~/.malsearch.conf)
-o, --output-dir DIR output directory for downloaded samples (default: .)
--select NAME [NAME ...] only use the given clients
--skip NAME [NAME ...] do not use the given clients
-u, --unpacked also download the unpacked versions of a packed sample (VirusTotal, UnpacMe)
--disable-cache disable the requests cache ("not found" answers are otherwise cached for one day)
--no-check-hash do not check that downloaded samples match their hashes
-v, --verbose display debug information

Each sample is saved under its hash as the filename, and samples that already exist in the output directory are skipped. For each hash, the clients are tried in turn until one returns the sample. Several hashes are downloaded in parallel, with a progress bar if tqdm is installed.

Python

The same features are available from Python. Unlike the command line, the functions below do not create the output directory, so make sure it exists first:

from malsearch import download_samples, get_samples_feed

# download samples, using the same options as on the command line
download_samples("2037f9b7dd268eef7d2e950b27c6cf80e3ba692d262c785ab67b04dc71c99bf9",
                 config="~/.malsearch.conf", output_dir="samples", select=["malwarebazaar", "virustotal"])

# iterate over the hashes of the PE files from the malware feeds
for h in get_samples_feed(config="~/.malsearch.conf", formats=["pe"]):
    print(h)

You can also use a single client directly:

from malsearch import MalwareBazaar

MalwareBazaar(api_key="YOUR-KEY", output_dir="samples").get_file_by_hash("2037f9b7dd268eef7d2e950b27c6cf80e3ba692d262c785ab67b04dc71c99bf9")

Back to top

Metadata

Release files for malsearch 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for malsearch 1.1.0
File Size Uploaded Provenance Actions
malsearch-1.1.0.tar.gz 167.5 kB With provenance Details for malsearch-1.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for malsearch 1.1.0
File Interpreter ABI Platform Actions
malsearch-1.1.0-py3-none-any.whl Python 3 none any Details for malsearch-1.1.0-py3-none-any.whl

Total release size: 229.8 kB

Release files / malsearch-1.1.0.tar.gz

Download URL malsearch-1.1.0.tar.gz
Size 167.5 kB
Tags Source
SHA-256 checksum
How to use checksums
af36027d7910209de8ba9c1b7b56dec6b94ff4c217079ffec69bc756bde31b50
BLAKE2b-256 checksum
How to use checksums
fd52c1d8640db598f9a39494e9a5fb57bedaad19e9397de738007cc78281473a
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 29, 2026.

Transparency log

Release files / malsearch-1.1.0-py3-none-any.whl

Download URL malsearch-1.1.0-py3-none-any.whl
Size 62.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8f65d12d0c66d04b1bb627cb242dc47fe93d74e991e71b5a4ec1a955340eb820
BLAKE2b-256 checksum
How to use checksums
564bdb28c6f3151400c7b52757cef5ced178c6b25a7abe9eef383f9bfa722288
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 29, 2026.

Transparency log

Security for malsearch 1.1.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.

Select from 2 files

Attestation for malsearch-1.1.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 29, 2026.

Transparency log

A 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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page