#!/bin/sh
TARGET="192.168.1.0/24" NMAP_OPTIONS="-v -T4 -F -sV" DATE=`date +%F` cd /home/joe/nmap nmap $NMAP_OPTIONS $TARGET -oA scan-$DATE > /dev/null if [ -e scan-old.xml ] then ndiff scan-old.xml scan-$DATE.xml > diff-$DATE echo "------NDIFFed-RESULTS------" cat diff-$DATE echo fi echo "------SCAN-RESULTS------" cat scan-$DATE.nmap ln -sf scan-$DATE.xml scan-old.xml |
#!/bin/sh
# # Variable declaration. These you need to make sure fit your environment. ### TARGET is specifying the network that will be scanned. Again, update as needed. TARGET="192.168.1.0/24" ### NMAP_OPTIONS we specify the flags that control how we will scan the targets. NMAP_OPTIONS="-v -T4 -F -sV" ### DATE will make it so the format is YYYY-MM-DD DATE=`date +%F` # # Move over to the desired directory where files will be stored. Again, this should be modified to fit the environment. cd /home/joe/nmap # Here is where the nmap command is made. This is where the work gets done. We send our output to /dev/null so that we are not crowding the cli. nmap $NMAP_OPTIONS $TARGET -oA scan-$DATE > /dev/null # if statement, first we look to see if there is an old file if [ -e scan-old.xml ] then # We compare two files, old and current and we drop them into a third file diff-$DATE ndiff scan-old.xml scan-$DATE.xml > diff-$DATE # Place words on the string so we can see what is going on. echo "------NDIFFed-RESULTS------" # show the contents of the third file cat diff-$DATE # make a blank line on cli echo # now leaving the if loop. Fi # Place words on the string so we can see what is going on…. Again. echo "------SCAN-RESULTS------" # Display our full current results. cat scan-$DATE.nmap # copy the current scan over the old scan. cp scan-$DATE.xml scan-old.xml |