-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpuerto.py
46 lines (39 loc) · 1.2 KB
/
puerto.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
import socket
import sys, os
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):
f = open("vuln_banners.txt", 'r')
for line in f.readlines():
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)
if 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]
for x in range (1,255):
ip = '192.168.1.'+str(x)
print "Percentage: " + str((x*100)/255) + "%"
for port in portList:
banner = retBanner(ip, port)
if banner:
print '[+] '+ ip +': '+ banner
checkVulns(banner)
if __name__ == '__main__':
main()