Repository navigation
Expand file tree
/
Copy pathvirus_check.py
More file actions
79 lines (65 loc) · 2.37 KB
/
Copy pathvirus_check.py
File metadata and controls
79 lines (65 loc) · 2.37 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import re
import http.client
import time
import os
import optparse
from urllib import *
def printResults(url):
status = 200
host = urlparse(url)[1]
path = urlparse(url)[2]
if 'analysis' not in path:
while status != 302:
conn = http.client.HTTPConnection(host)
conn.request('GET', path)
resp = conn.getresponse()
status = resp.status
print('[+] Scanning File...')
conn.close()
time.sleep(15)
print('[+] Scan Complete.')
path = path.replace('file', 'analysis')
conn = http.client.HTTPConnection(host)
conn.request('GET', path)
resp = conn.getresponse()
data = resp.read()
conn.close()
reResults = re.findall(r'Detection Rate:.*\)', data)
htmlStipRes = reResults[1].\
replace('<font color=\'red\'>', '').\
replace('</font>', '')
print('[+] ' + str(htmlStripRes))
def uploadFile(fileName):
print('[+] Uploading File to NoVirusThanks...')
fileContents = open(fileName,'rb').read()
header = {'Content-Type': 'multipart/form-data; boundary=----WebKitFormBoundaryF17rwCZdGuPNPT9U'}
params = '------WebKitFormBoundaryF17rwCZdGuPNPT9U'
params += '\r\nContent-Disposition: form-data; ' + 'name=\'upfile\'; filename=\''+str(fileName)+'\''
params += '\r\nContent-Type: ' + 'application/octet stream\r\n\r\n'
params += fileContents
params += '\r\n------WebKitFormBoundaryF17rwCZdGuPNPT9U'
params += '\r\nContent-Disposition: form-data; ' + 'name=\'submitfile\'\r\n'
params += '\r\nSubmit File\r\n'
params += '------WebKitFormBoundaryF17rwCZdGuPNPT9U--\r\n'
conn = http.client.HTTPConnection('vscan.novirusthanks.org')
conn.request('POST', '/', params, header)
response = conn.getresponse()
location = response.getheader('location')
conn.close()
return location
def main():
parser = optparse.OptionParser('usage %prog -f <filename>')
parser.add_option('-f', dest='fileName', type='string', help='specify filename')
(options, args) = parser.parse_args()
fileName = options.fileName
if not fileName:
print(parser.usage)
exit(0)
elif not os.path.isfile(fileName):
print(f'[+] {fileName} does not exist.')
exit(0)
else:
loc = uploadFile(fileName)
printResults(loc)
if __name__ == '__main__':
main()