-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnmapDiffScan.sh
More file actions
23 lines (18 loc) · 799 Bytes
/
nmapDiffScan.sh
File metadata and controls
23 lines (18 loc) · 799 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/bash
# Based on THP3 CH02, lated updated on 08/03/19
# TODO - Add error handling for targetlist.txt
# TODO - Add Email notification functionality
# Date variables
d=$(date +%Y-%m-%d)
y=$(date -d yesterday +%Y-%m-%d)
# Creates directory to store files
if [ ! -d /opt/nmap_diff ]; then
mkdir -p /opt/nmap_diff;
fi
# Runs a nmap scan, using a target list, that saves output as XML file that includes a timestamp
# Create targetlist.txt prior to executing script
nmap -T4 -Pn -p- -iL targetlist.txt -oX /opt/nmap_diff/scan_$d.xml > /dev/null #2>&1
# Compares yesterdays XML file with today's XML and if there are differences sames them to diff.txt
if [ -e /opt/nmap_diff/scan$.y.xml ]; then
/usr/bin/ndiff /opt/nmap_diff/scan_$y.xml /opt/nmap_diff/scan$d.xml > /opt/nmap_diff/diff.txt
fi