mirror of
https://github.com/lopes/netbox-scanner.git
synced 2025-07-22 05:14:39 +02:00
added timeout in nmap scan
This commit is contained in:
parent
84f4cdf67f
commit
e2e44cd79a
@ -3,6 +3,7 @@
|
|||||||
TAG = 'auto'
|
TAG = 'auto'
|
||||||
UNKNOWN = 'UNKNOWN HOST'
|
UNKNOWN = 'UNKNOWN HOST'
|
||||||
LOG = '.' # path to logfile
|
LOG = '.' # path to logfile
|
||||||
|
NMAP_ARGS = '-T4 -O -F --host-timeout 30s'
|
||||||
|
|
||||||
NETBOX = {
|
NETBOX = {
|
||||||
'ADDRESS': 'https://',
|
'ADDRESS': 'https://',
|
||||||
|
@ -17,8 +17,9 @@ logging.getLogger('paramiko').setLevel(logging.CRITICAL) # paramiko is noisy
|
|||||||
|
|
||||||
class NetBoxScanner(object):
|
class NetBoxScanner(object):
|
||||||
|
|
||||||
def __init__(self, address, token, tls_verify, devs_auth, tag, unknown):
|
def __init__(self, address, token, tls_verify, nmap_args, devs_auth, tag, unknown):
|
||||||
self.netbox = api(address, token=token, ssl_verify=tls_verify)
|
self.netbox = api(address, token=token, ssl_verify=tls_verify)
|
||||||
|
self.nmap_args = nmap_args
|
||||||
self.devs = devs_auth
|
self.devs = devs_auth
|
||||||
self.tag = tag
|
self.tag = tag
|
||||||
self.unknown = unknown
|
self.unknown = unknown
|
||||||
@ -56,7 +57,7 @@ class NetBoxScanner(object):
|
|||||||
'''
|
'''
|
||||||
hosts = []
|
hosts = []
|
||||||
nm = PortScanner()
|
nm = PortScanner()
|
||||||
nm.scan(network, arguments='-T4 -O -F')
|
nm.scan(network, arguments=self.nmap_args)
|
||||||
|
|
||||||
for host in nm.all_hosts():
|
for host in nm.all_hosts():
|
||||||
address = nm[host]['addresses']['ipv4']
|
address = nm[host]['addresses']['ipv4']
|
||||||
|
@ -18,6 +18,8 @@ argp.add_argument('-t', '--token', help='netbox access token',
|
|||||||
default=config.NETBOX['TOKEN'])
|
default=config.NETBOX['TOKEN'])
|
||||||
argp.add_argument('-v', '--verify', help='tls verify',
|
argp.add_argument('-v', '--verify', help='tls verify',
|
||||||
action='store_true', default=config.NETBOX['TLS_VERIFY'])
|
action='store_true', default=config.NETBOX['TLS_VERIFY'])
|
||||||
|
argp.add_argument('-m', '--nmap', help='set Nmap arguments',
|
||||||
|
default=config.NMAP_ARGS)
|
||||||
argp.add_argument('-d', '--devices', help='device authentication crendentials',
|
argp.add_argument('-d', '--devices', help='device authentication crendentials',
|
||||||
default=config.DEVICE_AUTH)
|
default=config.DEVICE_AUTH)
|
||||||
argp.add_argument('-g', '--tag', help='netbox-scanner tag',
|
argp.add_argument('-g', '--tag', help='netbox-scanner tag',
|
||||||
@ -35,8 +37,8 @@ logging.basicConfig(filename='{}/netbox-scanner-{}.log'.format(args.log,
|
|||||||
|
|
||||||
disable_warnings(InsecureRequestWarning)
|
disable_warnings(InsecureRequestWarning)
|
||||||
|
|
||||||
nbs = NetBoxScanner(args.address, args.token, args.verify, args.devices,
|
nbs = NetBoxScanner(args.address, args.token, args.verify, args.nmap,
|
||||||
args.tag, args.unknown)
|
args.devices, args.tag, args.unknown)
|
||||||
logging.info('started: {} networks'.format(len(args.networks)))
|
logging.info('started: {} networks'.format(len(args.networks)))
|
||||||
stats = nbs.sync(args.networks)
|
stats = nbs.sync(args.networks)
|
||||||
logging.info('finished: +{} ~{} -{} ?{} !{}'.format(stats[0], stats[1],
|
logging.info('finished: +{} ~{} -{} ?{} !{}'.format(stats[0], stats[1],
|
||||||
|
2
setup.py
2
setup.py
@ -7,7 +7,7 @@ with open('README.md', 'r') as fh:
|
|||||||
|
|
||||||
setuptools.setup(
|
setuptools.setup(
|
||||||
name='netbox-scanner',
|
name='netbox-scanner',
|
||||||
version='0.5.0',
|
version='0.5.1',
|
||||||
author='José Lopes de Oliveira Jr.',
|
author='José Lopes de Oliveira Jr.',
|
||||||
author_email='jlojunior@gmail.com',
|
author_email='jlojunior@gmail.com',
|
||||||
description='A scanner util for NetBox',
|
description='A scanner util for NetBox',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user