Created
November 28, 2018 18:13
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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