Chris Hall - polarclouds.co.uk Metadefender - www.metadefender.com
Scan a folder of files using Metadefender's Public API. The script is can also be used as SABnzbd postprocessing script.
The script performs the following:
For each file in the folder to be scanned,
- Create a MD5 hash of the file
- Post the MD5 hash value to Metadefender via the Metadefender public API
- Categorise the API return value (categories below)
- Report results
- If file extension is on the risky file list, upload file to Metadefender via public API for analysis
- Wait for file analysis to complete
- Re-post the MD5 hash value to Metadefender via the public API
- Categorise the API return value (categories below)
- Rename file if file is found infected or suspicious
- Report results
Script Return Categories:
- VIRUS FOUND!! - Fairly obvious. Metadefender knows that this file is infected with a virus. Infected file's filename is appended with "__INFECTED"
- SUSPICIOUS FILE!! - Metadefender knows that this file is suspicious. Suspicious file's filename is appended with "__SUSPICIOUS"
- All OK - no virus found - Metadefender knows that this file is OK. All good
- File(s) not known to Metadefender - Metadefender has not seen this file before
- Problem Scanning!! - Something went wrong
See Metadefender's API definitions for further information.
- Each API call requires a Metadefender Online API key. To obtain your free Metadefender Online API key, follow the instructions at Metadefender's Public API page
- Enter your API key into your downloaded copy of the script betweeen the quotes into the variable
myapikey
- Review the
extlist
variable. Add or remove any file extensions to be scanned as required. Files with extensions matching those in this list will be uploaded to Metadefender for analysis - Save and close the script
Simply:
python scan-directory-with-metascan.py <path to directory to be scanned>
For example:
python scan-directory-with-metascan.py /home/chris/files
For those running under Linux, dont forget to chmod +x scan-directory-with-metascan.py
to mark the file as an executable first.
See the Opswat about Metadefender
See the changelog for what's new in the most recent release.
If scan-directory-with-metascan helped you, how about buying me a beer? Use the donate button below. THANK YOU!