-
Notifications
You must be signed in to change notification settings - Fork 1
/
vt.py
30 lines (26 loc) · 792 Bytes
/
vt.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import sys
import os
import requests
import json
def results(ipaddr):
params = {'ip': ipaddr, 'apikey': 'API_KEY HERE'}
headers = {
"Accept-Encoding": "gzip, deflate",
"User-Agent" : "gzip, My python example client or username"
}
response = requests.get('https://www.virustotal.com/vtapi/v2/ip-address/report',
params=params, headers=headers)
return json.dumps(response.json(), indent=2, sort_keys=True)
def main(argv):
ipaddr = "ipaddr.txt"
if os.path.exists(ipaddr) and os.path.getsize(ipaddr) > 0:
with open(ipaddr, 'r') as f:
w_str = f.read().splitlines()
else:
w_str = list(sys.argv[1:])
with open("output.txt", 'w') as f:
for i in w_str:
f.write(f'IPAddr: {i}' + '\n')
f.write(results(i) + '\n')
if __name__ == "__main__":
main(sys.argv)