-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnmap-script.py
executable file
·45 lines (30 loc) · 1.03 KB
/
nmap-script.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
#!/usr/bin/env python
import nmap
import logging
import os
import logging.config
import yaml
# logging settings
with open('./logging.yml', 'rt') as f:
config = yaml.safe_load(f.read())
f.close()
logging.config.dictConfig(config)
# Get an instance of a logger
logger = logging.getLogger("flanby")
nmScan = nmap.PortScanner()
location = os.getcwd()
final_location = location + '/scripts/vulners.nse'
final_arg = '-sV --script='+final_location
logger.debug(final_arg)
nmScan.scan(hosts='192.168.1.1', arguments=final_arg)
logger.debug(nmScan.command_line())
for host in nmScan.all_hosts():
logger.debug('Host : %s (%s)' % (host, nmScan[host].hostname()))
logger.debug('|State : %s' % nmScan[host].state())
for proto in nmScan[host].all_protocols():
logger.debug('| Protocol : %s' % proto)
lport = nmScan[host][proto].keys()
# lport.sort()
for port in lport:
logger.debug('|-->port : %s\tstate : %s' % (port, nmScan[host][proto][port]['state']))
logger.debug("async_scan job done")