Last active
December 10, 2019 19:09
-
-
Save flatlinebb/3206ecda284b0fce4145cae5f4a34f0d to your computer and use it in GitHub Desktop.
NMAP scan to HTML
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This script needs to be run as root or sudo!!!! | |
# Provide client name or IP address as CommandLine argument: | |
# For example, sudo ./nmap_ADHOC.sh 192.168.2.111 | |
# Feel free to modify the nmap scan options to suit your needs | |
# Use 'mailx' or any other email solution if you want to be notified by email when the scan is done | |
# Customize the web directory to match your setup | |
# Exit on error, and mark commands with a + in output | |
set -ex | |
# Capture a log file with the same name as the target: | |
exec &> /root/$1.log | |
# Create an 'old' folder to store old scans: | |
mkdir -p -v /var/www/$1/old | |
# Run the nmap scan: | |
nmap --script vuln --open -sV -O --osscan-limit -R -sS -T4 -Pn -oX /var/www/$1/$1_scan.xml $1 | |
# Move old reports to archive: | |
mv -v /var/www/$1/*_report.html /var/www/$1/old/ | |
# Generate HTML document from the scan XML output: | |
xsltproc public_html/$1/$1_scan.xml -o "/var/www/$1/$1_`date +%m%d%y`_report.html" | |
cd /var/www/$1 | |
# Create a simlink to the latest report for easier browser viewing: | |
ln -s -f $1_*_report.html index.html | |
# Update permissions to make them readable: | |
chmod 775 /var/www/$1/* | |
# Change owner to your web user (www/apache/whatever) | |
chown -v -R www:www /var/www/$1/* /var/www/$1.* | |
# Notify scan done via email, and insclude the scan log in the email body: | |
echo "Access the report here: http://your.website/$1/ " | mailx -r "[email protected]" -s "Nmap scan for $1 completed!" -q "/var/www/$1.log" -S smtp="smtp.gmail.com:587" -S smtp-use-starttls -S smtp-auth=login -S smtp-auth-user="[email protected]" -S smtp-auth-password="xxxxxxXXXXxxxxxxx" -S ssl-verify=ignore [email protected] | |
# Get your web link to the fresh report: | |
echo "Access the report here: http://your.website/$1/ " | |
# Profit! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment