Skip to content

Instantly share code, notes, and snippets.

@DarkCat09
Created September 11, 2020 12:56
Show Gist options
  • Save DarkCat09/fca648aa4afd37377ac4a24c606e2f0c to your computer and use it in GitHub Desktop.
Save DarkCat09/fca648aa4afd37377ac4a24c606e2f0c to your computer and use it in GitHub Desktop.
Test script for scanning files on VT

VirusTotal Scanning Python Script

What is it?

This is my test script on Python for scanning files on VirusTotal.

How to use

On eight (8) line of code replace <YOUR_API_KEY> on your VT api-key, save file, then start it, using command: python path_to_script/virustotal_scanning.py path_to_file/to_scan.exe

# encoding: utf-8
import os
from sys import argv
import time
import json
import requests
file = argv[1]
print(file)
fileready = False
scanreq = requests.post("https://www.virustotal.com/vtapi/v2/file/scan", \
params={"apikey": "147eac96e8a588d37164c584cdbc9f28d2138558ce7965ffc357dcf29215d963"}, \
files={"file": (file[file.rfind("\\"):], open(file, 'rb'))})
json_scanreq = json.loads(scanreq.content)
reportreq = None
while not fileready:
time.sleep(1)
reportreq = requests.get("https://www.virustotal.com/vtapi/v2/file/report", \
params={"apikey": "147eac96e8a588d37164c584cdbc9f28d2138558ce7965ffc357dcf29215d963",\
"resource": json_scanreq["md5"]})
fileready = (json.loads(reportreq.content)["response_code"] == 1)
print(json.loads(reportreq.content))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment