diff --git a/nmail.sh b/nmail.sh new file mode 100755 index 0000000..0789588 --- /dev/null +++ b/nmail.sh @@ -0,0 +1,35 @@ +#! /bin/sh + +### +# +# nmail v0.1 +# Author : adrien@malingrey.fr +# +# Scan targets with nmap, +# compare with previous scan +# and send result by mail +# +# Depends : nmap (with ndiff) and xsltproc +# +### + +targets="192.168.0.0/24" +options="" +path=. +mailto=mail@address.com +message="Send by nmail.sh" + +if [ -f "$path/new_scan.xml" ] +then + mv -f "$path/new_scan.xml" "$path/prev_scan.xml" +fi + +nmap $options $targets -oX "$path/new_scan.xml" + +if [ -f "$path/prev_scan.xml" ] +then + ndiff --xml "$path/prev_scan.xml" "$path/new_scan.xml" | xsltproc nmail.xsl - | while read -r line + do + echo $message | mail $mailto -s "$line" + done +fi diff --git a/nmail.xsl b/nmail.xsl new file mode 100644 index 0000000..357b8c4 --- /dev/null +++ b/nmail.xsl @@ -0,0 +1,87 @@ + + + + + + + + + + Scan with + + v + + on + + +Command: + + + + + + ⚠️ Host + + + + ( + + ) + + + + + + is down! ⚠️ + + + + + New host detected : + + + + ( + + ) + + + + + + + + + + + ⚠️ Service + + on + + : + + is down! ⚠️ + + + + + New service detected: + + on + + : + + + + + + \ No newline at end of file