Network inventory and comparison with Nmap and NDiff

Do a network comparison with NDIFF, between two networks NMAP scan.

#!/bin/bash

# Variables
TODAY=`date +%A`
OUTPUT_DIR=/reports
SCAN_BASE=$OUTPUT_DIR/scan_baseline.xml
SCAN_CURR=$OUTPUT_DIR/scan_current.xml
REPORT_FILE=$OUTPUT_DIR/scan_report-$TODAY.txt
RECIPIENT='recipient@domain.com'
NET_BLOCK='192.168.1.0/24'

# Script
touch $SCAN_BASE
nmap -n -oX $SCAN_CURR $NET_BLOCK
ndiff -b $SCAN_BASE -o $SCAN_CURR > $REPORT_FILE
mail $RECIPIENT -s "Network Scan" < $REPORT_FILE
cp $SCAN_CURR $SCAN_BASE

Be the first to comment

Leave a Reply

Your email address will not be published.


*


*