├── LICENSE ├── README.md ├── ScreenShot.png ├── continuousscan.sh ├── dockerfile ├── index.html └── nmapcsv.sh /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Jerry Gamblin 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # NMap Network Inventory Container 2 | Have you ever wanted up-to-date NMap scan data in an easily understandable format? Have you noticed how hard it is to get that? So did I! So I hacked together a docker container to continually scan (about every 2 Hours) your network and display the findings cleanly using Debian, [Namp Grepable Output](https://nmap.org/book/output-formats-grepable-output.html), A bash script to convert it to a CSV and some [D3.js code](https://d3js.org/). 3 | 4 | ## Build and Run Instructions 5 | 6 | #### Clone 7 | `git clone https://github.com/jgamblin/NMapNetworkInventoryContainer` 8 | 9 | #### Configure 10 | In `continuousscan.sh` edit the `TARGETS="192.168.1.0/24"` and `OPTIONS="-sV"` line with your hosts 11 | 12 | #### Build 13 | `docker build -t inventory .` 14 | 15 | #### Run 16 | `docker run --name nmap-inventory -t -p 1337:1337 inventory` 17 | 18 | #### Enjoy 19 | After the first run is complete (it will take a while) you can access the website [here](http://127.0.0.1:1337). 20 | 21 | It will look like this: 22 |  23 | 24 | #### Important Notice 25 | I likely don't know what I am doing and this could be done faster, better and simpler some other way. Also make sure you have permission to NMap something before you do! 26 | -------------------------------------------------------------------------------- /ScreenShot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jgamblin/NMapNetworkInventoryContainer/82b4ec581a0ef8de8449a964a9631af577d31395/ScreenShot.png -------------------------------------------------------------------------------- /continuousscan.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | TARGETS="192.168.1.0/24" 3 | OPTIONS="-sV" 4 | 5 | cd /inventory || return 6 | python3 -m http.server 1337 & 7 | 8 | while true; do 9 | echo '' 10 | echo '==================' 11 | echo '' 12 | 13 | echo '' 14 | # Remove Old Gnmap 15 | rm scan.gnmap 16 | #Start Nmap:s 17 | printf "nmap ${OPTIONS} ${TARGETS} -oG /inventory/scan.gnmap" 18 | nmap $OPTIONS $TARGETS -oG /inventory/scan.gnmap 19 | #Remove Old Data 20 | rm data.csv 21 | #Update Data: 22 | cat scan.gnmap 23 | ./nmapcsv.sh scan.gnmap > data.csv 24 | 25 | 26 | #2 Hour Count Down Between Scans 27 | m=${1}-1 28 | Floor () { 29 | DIVIDEND=${1} 30 | DIVISOR=${2} 31 | RESULT=$(( ( ${DIVIDEND} - ( ${DIVIDEND} % ${DIVISOR}) )/${DIVISOR} )) 32 | echo ${RESULT} 33 | } 34 | 35 | Timecount(){ 36 | s=7200 37 | HOUR=$( Floor ${s} 60/60 ) 38 | s=$((${s}-(60*60*${HOUR}))) 39 | MIN=$( Floor ${s} 60 ) 40 | SEC=$((${s}-60*${MIN})) 41 | while [ $HOUR -ge 0 ]; do 42 | while [ $MIN -ge 0 ]; do 43 | while [ $SEC -ge 0 ]; do 44 | printf "Rescanning in %02d:%02d:%02d\033[0K\r" $HOUR $MIN $SEC 45 | SEC=$((SEC-1)) 46 | sleep 1 47 | done 48 | SEC=59 49 | MIN=$((MIN-1)) 50 | done 51 | MIN=59 52 | HOUR=$((HOUR-1)) 53 | done 54 | } 55 | 56 | Timecount $m 57 | 58 | done 59 | -------------------------------------------------------------------------------- /dockerfile: -------------------------------------------------------------------------------- 1 | FROM debian:9.4-slim 2 | 3 | RUN apt-get update && apt-get upgrade -y 4 | RUN apt-get install -y \ 5 | nmap \ 6 | python3 \ 7 | gawk \ 8 | && rm -rf /var/lib/apt/lists/* 9 | 10 | RUN mkdir /inventory 11 | COPY nmapcsv.sh index.html continuousscan.sh /inventory/ 12 | 13 | EXPOSE 1337 14 | CMD ["./inventory/continuousscan.sh"] 15 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
5 | 6 | 7 |