-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvuln_scan.py
50 lines (43 loc) · 1.29 KB
/
vuln_scan.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
#!/usr/bin/env python3
#-*- codinf: utf-8 -*-
import sys
import os
import socket
def retBanner(ip,port):
try:
socket.setdefaulttimeout(2)
s = socket.socket()
s.connect((ip,port))
banner = s.recv(1024)
return banner
except:
return
def checkVulns(banner,filename):
f = open(filename,'r')
for line in f.readline():
if line.strip('\n') in banner:
print('[+] Server is vulnerable: ' + banner.strip('\n'))
def main():
if len(sys.argv) == 2:
filename = sys.argv[1]
if not os.path.isfile(filename):
print('[-] ' + filename + 'does not exist.')
exit(0)
elif not os.access(filename,os.R_OK):
print('[-] ' + filename + 'access denied.')
exit(0)
else:
print('[-] Usage: ' + str(sys.argv[0]) + ' <vuln filename>')
exit(0)
portList = [21,22,25,80,110,443]
for x in range(1,254):
ip = '192.168.30.' + str(x)
for port in portList:
banner = retBanner(ip,port)
if banner:
print('[+]' + ip + ': ' + banner)
checkVulns(banner,filename)
else:
print('No')
if __name__ == '__main__':
main()