-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnmapper.py
More file actions
78 lines (64 loc) · 2.39 KB
/
nmapper.py
File metadata and controls
78 lines (64 loc) · 2.39 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
import netifaces
import nmap
from termcolor import colored, cprint
#Definitions
Gateways = netifaces.gateways()
default_gateway = Gateways['default'][netifaces.AF_INET][0]
nm = nmap.PortScanner()
#Menu and Options
cprint("""
--------------------------------------------
| option 1: Scan your Router for open ports|
| option 2: Scan a specific IP |
| option 3: Exit Program |
--------------------------------------------
""",
#Color Settings
"red", attrs=["bold"]
)
optioninput = input("option: ")
if optioninput == "1":
print("Scanning host IP", default_gateway,"...")
nm.scan(hosts=default_gateway, arguments=' -p 1-1024')
# Print scan results
print(f"Scan results for {default_gateway}:")
for host in nm.all_hosts():
print(f"Host : {host} ({nm[host].hostname()})")
print(f"State : {nm[host].state()}")
for proto in nm[host].all_protocols():
print(f"Protocol : {proto}")
lport = nm[host][proto].keys()
for port in lport:
print(f"port : {port}\tstate : {nm[host][proto][port]['state']}")
print("Scanning finished! Press enter to exit...")
elif optioninput == "2":
print("What IP would you like to scan?")
scannedip = input()
print("Scanning IP...")
nm.scan(hosts=scannedip, arguments='-p 1-1024')
# Print scan results
print(f"Scan results for {scannedip}:")
for host in nm.all_hosts():
print(f"Host : {host} ({nm[host].hostname()})")
print(f"State : {nm[host].state()}")
for proto in nm[host].all_protocols():
print(f"Protocol : {proto}")
lport = nm[host][proto].keys()
for port in lport:
print(f"port : {port}\tstate : {nm[host][proto][port]['state']}")
elif optioninput == 3:
print("Exiting Program!")
exit()
# Print scan results
print(f"Scan results for {scannedip}:")
for host in nm.all_hosts():
print(f"Host : {host} ({nm[host].hostname()})")
print(f"State : {nm[host].state()}")
for proto in nm[host].all_protocols():
print(f"Protocol : {proto}")
lport = nm[host][proto].keys()
for port in lport:
print(f"port : {port}\tstate : {nm[host][proto][port]['state']}")
elif optioninput == 3:
print("Exiting Program!")
exit()