Skip to content

Instantly share code, notes, and snippets.

@sodonnell
Last active May 30, 2019 00:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sodonnell/b7fed25a9eeae89cc9e83550bcc14761 to your computer and use it in GitHub Desktop.
Save sodonnell/b7fed25a9eeae89cc9e83550bcc14761 to your computer and use it in GitHub Desktop.
basic nmap scanning argument iterations and logging
#!/usr/bin/env bash
#
# Run various nmap scans on a hostname and log all scans to a single file.
#
# Alternatively, nmap does support log-output arguments on it's own, but the problem is
# grouping various scans that often conflict during the same process, thus requiring
# a series of multiple scans and would create multiple logs.
#
# usage examples:
# default scan:
# sudo ./nmap.sh somedomain.net
#
# single port scan:
# sudo ./nmap.sh somedomain.net 22
#
# multi-port scan:
# sudo ./nmap.sh somedomain.net 22,23,24,etc.
#
# port-range scan:
# sudo ./nmap.sh somedomain.net 22-2222
#
# Default Ports (if null): 1-65535
#
ARGS="-O -sA -sT -sN -sM -sS -sW -sU";
TARGET="$1 -P0";
LOG="$0.$1.log";
if [ -z $2 ]; then
PORTS="1-65535";
else
PORTS=$2;
fi
echo -e "Beginning Scans...\n" > $LOG;
for i in $ARGS; do
echo -e "\nnmap $TARGET $i -p $PORTS\n" >> $LOG
nmap $TARGET $i -p $PORTS >> $LOG;
done
echo -e "Done.\n";
less $LOG;
@sodonnell
Copy link
Author

lol why!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment