|
16 | 16 | 2)UDP Scan
|
17 | 17 | 3)Comprehensive Scan \n""")
|
18 | 18 | print("You have selected option: ", resp)
|
19 |
| - |
20 |
| -if resp == '1': |
21 |
| - print("Nmap Version: ", scanner.nmap_version()) |
22 |
| - scanner.scan(ip_addr, '1-1024', '-v -sS') |
23 |
| - print(scanner.scaninfo()) |
24 |
| - print("Ip Status: ", scanner[ip_addr].state()) |
25 |
| - print(scanner[ip_addr].all_protocols()) |
26 |
| - print("Open Ports: ", scanner[ip_addr]['tcp'].keys()) |
27 |
| -elif resp == '2': |
28 |
| - print("Nmap Version: ", scanner.nmap_version()) |
29 |
| - scanner.scan(ip_addr, '1-1024', '-v -sU') |
| 19 | +resp_dict={'1':['-v -sS','tcp'],'2':['-v -sU','udp'],'3':['-v -sS -sV -sC -A -O','tcp']} |
| 20 | +if resp not in resp_dict.keys(): |
| 21 | + print("enter a valid option") |
| 22 | +else: |
| 23 | + print("nmap version: "sccaner.nmap_version()) |
| 24 | + scanner.scan(ip_addr,"1-1024",resp_dict[resp][0]) #the # are port range to scan, the last part is the scan type |
30 | 25 | print(scanner.scaninfo())
|
31 |
| - print("Ip Status: ", scanner[ip_addr].state()) |
32 |
| - print(scanner[ip_addr].all_protocols()) |
33 |
| - print("Open Ports: ", scanner[ip_addr]['udp'].keys()) |
34 |
| -elif resp == '3': |
35 |
| - print("Nmap Version: ", scanner.nmap_version()) |
36 |
| - scanner.scan(ip_addr, '1-1024', '-v -sS -sV -sC -A -O') |
37 |
| - print(scanner.scaninfo()) |
38 |
| - print("Ip Status: ", scanner[ip_addr].state()) |
39 |
| - print(scanner[ip_addr].all_protocols()) |
40 |
| - print("Open Ports: ", scanner[ip_addr]['tcp'].keys()) |
41 |
| -elif resp >= '4': |
42 |
| - print("Please enter a valid option") |
43 |
| - |
| 26 | + if scanner.scaninfo()=='up': |
| 27 | + print("Scanner Status: ",scanner[ip_addr].state()) |
| 28 | + print(scanner[ip_addr].all_protocols()) |
| 29 | + print("Open Ports: ",scanner[ip_addr][resp_dict[resp][1]].keys()) #display all open ports |
44 | 30 |
|
45 | 31 |
|
46 | 32 |
|
|
0 commit comments