mirror of
https://github.com/lopes/netbox-scanner.git
synced 2025-07-04 04:24:36 +02:00
add ssl_verify parameter to disable ssl verification for testing
This commit is contained in:
parent
8a842d3c5f
commit
8dc40a7534
4
.gitignore
vendored
4
.gitignore
vendored
@ -106,3 +106,7 @@ venv.bak/
|
||||
# trash
|
||||
.vscode/
|
||||
|
||||
scans/*
|
||||
logs/*
|
||||
|
||||
test_api.py
|
@ -1,11 +1,27 @@
|
||||
import logging
|
||||
import requests
|
||||
|
||||
from pynetbox import api
|
||||
|
||||
|
||||
class NetBoxScanner(object):
|
||||
|
||||
def __init__(self, address, token, tag, cleanup):
|
||||
def __init__(self, address, token, ssl_verify, tag, cleanup):
|
||||
if (ssl_verify == 'No'):
|
||||
session = requests.Session()
|
||||
session.verify = False
|
||||
self.netbox = api(address, token)
|
||||
self.netbox.http_session = session
|
||||
self.tag = tag
|
||||
self.cleanup = cleanup
|
||||
self.stats = {
|
||||
'unchanged': 0,
|
||||
'created': 0,
|
||||
'updated': 0,
|
||||
'deleted': 0,
|
||||
'errors': 0
|
||||
}
|
||||
else:
|
||||
self.netbox = api(address, token)
|
||||
self.tag = tag
|
||||
self.cleanup = cleanup
|
||||
|
@ -1,26 +1,27 @@
|
||||
[NETBOX]
|
||||
address = <server>
|
||||
token = <key>
|
||||
token = <token>
|
||||
logs = logs/
|
||||
ssl_verify = No
|
||||
|
||||
[NMAP]
|
||||
path = ./
|
||||
unknown = autodiscovered:netbox-scanner
|
||||
tag = nmap
|
||||
cleanup = no
|
||||
|
||||
[NETXMS]
|
||||
address = https://netxms.domain
|
||||
username =
|
||||
password =
|
||||
unknown = autodiscovered:netbox-scanner
|
||||
tag = netxms
|
||||
cleanup = yes
|
||||
|
||||
# [NETXMS]
|
||||
# address = https://netxms.domain
|
||||
# username =
|
||||
# password =
|
||||
# unknown = autodiscovered:netbox-scanner
|
||||
# tag = netxms
|
||||
# cleanup = yes
|
||||
|
||||
# [PRIME]
|
||||
# address = https://prime.domain/webacs/api/v4
|
||||
# username =
|
||||
# password =
|
||||
# unknown = autodiscovered:netbox-scanner
|
||||
# tag = prime
|
||||
# cleanup = yes
|
||||
[PRIME]
|
||||
address = https://prime.domain/webacs/api/v4
|
||||
username =
|
||||
password =
|
||||
unknown = autodiscovered:netbox-scanner
|
||||
tag = prime
|
||||
cleanup = yes
|
||||
|
@ -87,6 +87,7 @@ if __name__ == '__main__':
|
||||
scanner = NetBoxScanner(
|
||||
netbox['address'],
|
||||
netbox['token'],
|
||||
netbox['ssl_verify'],
|
||||
nmap['tag'],
|
||||
nmap.getboolean('cleanup')
|
||||
)
|
||||
|
@ -16,7 +16,7 @@
|
||||
# to look for XML files.
|
||||
##
|
||||
|
||||
NETWORKS="192.168.252.0/24 192.168.3.0/24"
|
||||
NETWORKS="192.168.3.0/24 192.168.252.0/24"
|
||||
TODAY="$(date +%d.%m.%yT%H:%M:%S%Z)"
|
||||
|
||||
for net in $NETWORKS; do
|
||||
@ -25,6 +25,6 @@ for net in $NETWORKS; do
|
||||
nmap "$net" -T4 -sn --host-timeout 30s -oX nmap-"$NETNAME".xml
|
||||
done
|
||||
|
||||
python netbox-scanner.py nmap
|
||||
python3 netbox-scanner.py nmap
|
||||
tar -czvf scans/nmap-"$TODAY".tar.gz *.xml
|
||||
rm -rf *.xml
|
||||
|
Loading…
x
Reference in New Issue
Block a user