-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvulnscan.py
More file actions
39 lines (34 loc) · 1.69 KB
/
vulnscan.py
File metadata and controls
39 lines (34 loc) · 1.69 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
import portscanner
import argparse as arg
def get_arguments():
"""Get arguments from the command line"""
parser = arg.ArgumentParser()
parser.add_argument('-t', '--target', dest='target', help='The target/s IP or Hostname (split multiple targets with ,)')
parser.add_argument('-p', '--ports', dest='ports', help='The amount of ports to scan for (500 - first 500 ports) [default: 100]', default='100')
parser.add_argument('-f', '--file', dest='file', help='Path to File containing Vulnerable Softwares [default: vulbanners.txt]', default='vulbanners.txt')
options = parser.parse_args()
if not options.target:
options = None
return options
def vuln_scan(target, port_number, vul_file):
"""Scan for vulnerable software"""
target = portscanner.PortScan(target, port_number)
target.scan()
with open(vul_file, 'r') as file:
count = 0
for banner in target.banners:
file.seek(0)
for line in file.readlines():
if line.strip() in banner:
print(f'[!!] VULNERABLE BANNER: "{banner}" ON PORT: {target.open_ports[count]}')
count += 1
if __name__ == '__main__':
optionsValues = get_arguments()
if optionsValues:
vuln_scan(optionsValues.target, optionsValues.ports, optionsValues.file)
else:
target = targets = input('\n[>] Enter Target/s To Scan for Vulnerable Open Ports (split multiple targets with ,): ')
port_number = int(input('[>] Enter the amount of ports to Scan For (100 - first 100 ports): '))
vul_file = input('[>] Enter Path to File containing Vulnerable Softwares: ')
print('\n')
vuln_scan(target, port_number, vul_file)