
A script that automatically submits files to Hybrid Analysis (API)
This Python script recursively scans a folder and submits executable, script, document, and other relevant files to Hybrid Analysis (Falcon Sandbox) for automated malware analysis.
~/.hybrid_analysis_submitter/) to avoid polluting scanned folders.env file for securityClone or download this script to your local machine.
Install required packages:
pip install requests python-dotenv
.env file in the same directory as the script with your API key:HYBRID_API_KEY=your_api_key_here
You can obtain an API key by registering at Hybrid Analysis.
Run the script from the command line, specifying the folder to scan:
python submit_to_hybrid.py /path/to/folder
Scan a folder with default settings:
python submit_to_hybrid.py C:\suspicious_files
Scan a folder but increase the size limit to 200 MB and use a different environment (e.g., Android):
python submit_to_hybrid.py /home/user/samples --max-file-size 200 --environment-id 300
Use a custom cache file name:
python submit_to_hybrid.py ./malware --cache-file my_cache.json
Scanning folder: C:\suspicious_files
Submitting: C:\suspicious_files\malware.exe (2.34 MB)
-> Success! Job ID: 5f8a9c2d3e4f5a6b7c8d9e0f
Submitting: C:\suspicious_files\document.pdf (0.12 MB)
-> Success! Job ID: 6g9b0c1d2e3f4a5b6c7d8e9f
Skipping already submitted: C:\suspicious_files\malware.exe
Skipping symlink: C:\suspicious_files\link_to_malware.exe
Finished.
Files found: 42
Files submitted: 35
Files skipped: 6
Files failed: 1
.exe, .scr, .pif, .dll, .com, .cpl.msi.bat, .cmd, .ps1, .psd1, .psm1, .js, .vbs, .vbe, .wsf, , For the official list of all supported file types, check the Hybrid Analysis FAQ.
os.walk() to traverse every subfolder.--max-file-size are skipped), and whether the file has been submitted before (SHA‑256 cache).https://hybrid-analysis.com/api/v2/submit/file endpoint using a persistent requests Session with your API key.~/.hybrid_analysis_submitter/ so they are not re‑submitted in future runs. The cache is saved sorted for human readability.429 responses and stops after 3 such errors to avoid endless retries..env file – do not hardcode it.--max-file-size are skipped.ALLOWED_EXTENSIONS are submitted.~/.hybrid_analysis_submitter/).This script is provided as‑is for educational and security analysis purposes. Use responsibly and in accordance with Hybrid Analysis Terms of Service.
Submitting files to a third‑party sandbox may expose potentially sensitive content. Ensure you have the right to share the files before uploading.
| Argument | Description |
|---|
folder_path | Required – Path to the folder to scan (recursive) |
--max-file-size | Maximum file size in MB (default: 250) |
--environment-id | Analysis environment ID (default: 120 = Windows 7 64‑bit) |
--cache-file | Cache filename (default: submitted_cache.json). The file is stored in ~/.hybrid_analysis_submitter/ |
.hta.sct.lnk, .chm.doc, .docx, .ppt, .pps, .pptx, .ppsx, .xls, .xlsx, .rtf, .pub.pdf, .eml, .msg.jar, .py, .pl.apk (Android), .elf (Linux).svg| Problem | Likely Solution |
|---|
ERROR: HYBRID_API_KEY not found | Create a .env file in the same directory with HYBRID_API_KEY=your_key_here. |
'folder_path' is not a valid directory | Provide a correct path to an existing folder. |
| Permission denied when reading files | Run the script with appropriate read permissions. |
| Frequent 429 errors | Reduce the submission rate (increase the time.sleep(2) in the script) or upgrade your API plan. |
| Files are skipped unexpectedly | Check if the extension is in ALLOWED_EXTENSIONS. You can add more extensions by editing the script. |
| Duplicate submissions not skipped | The cache file might be missing or corrupted. Delete ~/.hybrid_analysis_submitter/submitted_cache.json to start fresh, or use the --cache-file argument to use a different cache file name. |
| Files outside scan root are being skipped | This is intentional for security. Ensure all target files are inside the specified folder. |