Verify an nmap file against a target range file to determine if the network subnet is online or offline.
- Clone the repo
- Install dependencies - Virtual environments are recommended (ie. poetry)
pip install -r requirements.txt
- Run the main script file
python main.py
- Clone the repo
- Install the script using
pipx
pipx install .
- Run the program
nmapSubnetOnline -h
- Clone the repo
- Build the container
docker build -t nso .
- Run the container and map directories inside
docker run --rm -v ${PWD}:/data nso
Development of this project is done with poetry
as it makes managing the depencies and virtual envs much easier.
- Clone the repo
- Install the dependencies
poetry install
- Enter the poetry shell
poetry shell
- Modify source or run the main script file from this shell
usage: nmapSubnetOnline [-h] -r RANGES [-n NMAP] [-d DIR] [-o OUTPUT] [--debug] [--quiet]
Verify an nmap file against a target range file to determine if the network is online or offline
options:
-h, --help show this help message and exit
-r RANGES, --ranges RANGES
Range file to check for online hosts
-n NMAP, --nmap NMAP Path to nmap output file (Supports multiple flags)
-d DIR, --dir DIR Directory of nmap output files
-o OUTPUT, --output OUTPUT
Directory for output files
--debug Enable debug
--quiet Enable quiet mode
Example: nmapSubnetOnline -r ranges.txt -n nmap.xml
(nmapsubnetonline-py3.11) root@cfeaca12f15c:/workspaces/nmapSubnetOnline# nmapSubnetOnline -r example/ranges.txt -d example/
2024-05-29T16:05:44.429698+0000 | SUCCESS | nmapsubnetonline.nmapsubnetonline has started
2024-05-29T16:05:44.434502+0000 | INFO | Reading range file 'example/ranges.txt'
2024-05-29T16:05:44.437332+0000 | INFO | Reading nmap file 'example/ping.xml'
2024-05-29T16:05:44.440492+0000 | INFO | Reading nmap file 'example/possible_dc.xml'
2024-05-29T16:05:44.449440+0000 | INFO | Outputting results to csv file
There are a couple gotchas when running tooling within a docker container.
- The files need to be mapped into the container for processing by using a volume.
- The output files need to be placed within the same directory that is mounted as a volume in order to be transfered back to the host.
- Unless the
--rm
flag is passed the container will exist long after it is exited.
Note: The following command uses the docker container while mapping all files within the current working directory into the docker container at
/data
. We also specify the output directory as/data
and we tell docker to remove the container and it's data on exit.
PS C:\nmapSubnetOnline> docker run --rm -v ${PWD}:/data nso -r /data/ranges.txt -n /data/possible_dc.xml -o /data
2024-05-29T17:32:34.540801+0000 | SUCCESS | nmapsubnetonline.nmapsubnetonline has started
2024-05-29T17:32:34.551113+0000 | INFO | Reading range file '/data/ranges.txt'
2024-05-29T17:32:34.582641+0000 | INFO | Reading nmap file '/data/possible_dc.xml'
2024-05-29T17:32:34.625612+0000 | INFO | Outputting results to csv file
Note: The
-v
volume argument is changed here from the original PowerShell version.
user@cfeaca12f15c:~/$ docker run --rm -v $(pwd):/data nso -r /data/ranges.txt -n /data/possible_dc.xml -o /data
2024-05-29T17:32:34.540801+0000 | SUCCESS | nmapsubnetonline.nmapsubnetonline has started
2024-05-29T17:32:34.551113+0000 | INFO | Reading range file '/data/ranges.txt'
2024-05-29T17:32:34.582641+0000 | INFO | Reading nmap file '/data/possible_dc.xml'
2024-05-29T17:32:34.625612+0000 | INFO | Outputting results to csv file
This file can either be a ping sweep or a port scan. The ping sweep will be faster but network devices may be blocking ICMP packets and a forced port scan may need to be done.
nmap -sn -oX ranges 192.168.1.1/24
nmap -sn -iL ranges.txt -oX ranges
nmap -Pn -n -oX ranges 192.168.1.1/24
nmap -Pn -n -iL ranges.txt -oX ranges
Ranges provided to nmap for scanning. These subnets/CIDRs will be output as online or offline determined by a boolean variable within the CSV.
192.168.1.1/24
192.168.1.2/24