Skip to content

Instantly share code, notes, and snippets.

@artikrh
Created November 28, 2018 18:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save artikrh/047a0b0033cd6d5d88b331fff5d4b7ab to your computer and use it in GitHub Desktop.
Save artikrh/047a0b0033cd6d5d88b331fff5d4b7ab to your computer and use it in GitHub Desktop.
A simple python script which accepts an executable file as input argument and then communicates with VirusTotal API to check whether that file has been scanned (if yes, provide results from different AVs). Requires a valid VirusTotal API key to work.
#!/usr/bin/python
import sys,requests
import json,hashlib
def main():
file = sys.argv[1]
with open(file,"rb") as f:
bytes = f.read()
hash = hashlib.sha256(bytes).hexdigest();
params = {'apikey': 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', 'resource': '{}'.format(hash)}
headers = {
"Accept-Encoding": "gzip, deflate",
"User-Agent" : "gzip, My Python requests library example client or username"
}
response = requests.get('https://www.virustotal.com/vtapi/v2/file/report',params=params,headers=headers)
parsed = json.loads(response.text)
print json.dumps(parsed, indent=4, sort_keys=True)
if __name__ == "__main__":
if(len(sys.argv) != 2):
print '[*] Usage: {} file'.format(sys.argv[0])
sys.exit()
else:
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment