Repository navigation
Expand file tree
/
Copy pathmap.py
More file actions
49 lines (41 loc) · 1.75 KB
/
Copy pathmap.py
File metadata and controls
49 lines (41 loc) · 1.75 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
#!/usr/bin/env python
import nmap
nm = nmap.PortScanner()
nm.scan('127.0.0.1', '1-9999')
nm.command_line()
nm.scaninfo()
nm.all_hosts()
nm['127.0.0.1'].hostname()
nm['127.0.0.1'].hostnames()
nm['127.0.0.1'].hostname()
nm['127.0.0.1'].state()
nm['127.0.0.1'].all_protocols()
nm['127.0.0.1']['tcp'].keys()
nm['127.0.0.1'].all_tcp()
nm['127.0.0.1'].all_udp()
nm['127.0.0.1'].all_ip()
nm['127.0.0.1'].all_sctp()
nm['127.0.0.1'].has_tcp(22)
nm['127.0.0.1']['tcp'][22]
nm['127.0.0.1'].tcp(22)
nm['127.0.0.1']['tcp'][22]['state']
for host in nm.all_hosts():
print('--------Open Ports on LocalHost-------------------------------')
print('Host : %s (%s)' % (host, nm[host].hostname()))
print('State : %s' % nm[host].state())
for proto in nm[host].all_protocols():
print('----------')
print('Protocol : %s' % proto)
lport = nm[host][proto].keys()
lport.sort()
for port in lport:
print('port : %s\tstate : %s' % (port, nm[host][proto][port]['state']))
print('---------------Specify Network Ex:192.168.1.0/24-------------------')
ip = raw_input("Network range: ")
print ("Trying with:" + ip)
print('-------------Scanning specified networking-------------------------')
nm.scan(hosts= ip , arguments='-n -sP -PE -PA21,23,80,3389')
hosts_list = [(x, nm[x]['status']['state']) for x in nm.all_hosts()]
for host, status in hosts_list:
print('{0}:{1}'.format(host, status))
print ('-----------------------Finished NMAP-------------------------------')