-
Notifications
You must be signed in to change notification settings - Fork 11
/
vt.py
55 lines (46 loc) · 1.38 KB
/
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import json
import urllib
import urllib2
import os.path
import sys
sys.path.append("./")
import iprep_conf
def getresult(key):
parameters = { "ip" : key,
"apikey": iprep_conf.vt_key}
print parameters
try:
data = urllib.urlencode(parameters)
req = urllib2.Request(url,data)
response = urllib2.urlopen(req)
stre = response.read()
print stre
return json.loads(stre)
except urllib2.HTTPError, e:
print str(e)
except:
return ""
def urlresult(key):
parameters = { "resource" : key,
"apikey": iprep_conf.vt_key}
try:
data = urllib.urlencode(parameters)
req = urllib2.Request(urlsearch,data)
response = urllib2.urlopen(req)
stre = response.read()
return json.loads(stre)
except:
return ""
def search(text):
parameters = { "ip" : text,
"apikey": iprep_conf.vt_key }
print parameters
try:
data = (urllib.urlopen('%s?%s' % (url, urllib.urlencode(parameters))).read())
return json.loads(data)
except:
return ""
print "error"
url = 'https://www.virustotal.com/vtapi/v2/ip-address/report'
urlsearch = 'https://www.virustotal.com/vtapi/v2/url/report'
HOMEfolder = os.path.dirname(os.path.realpath(__file__))