Back to articles
VirusTotal Has a Free API — Scan Files and URLs for Malware Programmatically

VirusTotal Has a Free API — Scan Files and URLs for Malware Programmatically

via Dev.to PythonAlex Spinov

A colleague clicked a suspicious link. We needed to check if it was malicious — fast. VirusTotal scans URLs and files against 70+ antivirus engines. And they have a free API. Getting Started Sign up at virustotal.com for a free API key. The free tier gives you: 4 lookups/minute 500 lookups/day 15.5K lookups/month 1. Scan a URL import requests import time API_KEY = ' your_api_key_here ' # Free from virustotal.com BASE = ' https://www.virustotal.com/api/v3 ' HEADERS = { ' x-apikey ' : API_KEY } def scan_url ( url ): # Submit URL for scanning resp = requests . post ( f ' { BASE } /urls ' , headers = HEADERS , data = { ' url ' : url } ) analysis_id = resp . json ()[ ' data ' ][ ' id ' ] # Wait for results time . sleep ( 15 ) # Get results result = requests . get ( f ' { BASE } /analyses/ { analysis_id } ' , headers = HEADERS ). json () stats = result [ ' data ' ][ ' attributes ' ][ ' stats ' ] return { ' url ' : url , ' malicious ' : stats . get ( ' malicious ' , 0 ), ' suspicious ' : stat

Continue reading on Dev.to Python

Opens in a new tab

Read Full Article
2 views

Related Articles