Last active
July 31, 2016 19:00
-
-
Save tremblerz/eeee660b25f75903a05b5f83088babc3 to your computer and use it in GitHub Desktop.
This file contains 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
timeout=0 | |
targets="scanme.nmap.org" | |
filename=~/Downloads/CourseMaterial/nmap/git/testnmap/nmap/scripts/script.db | |
output_path=~/Downloads/CourseMaterial/nmap/tests/host_timeout | |
#Read from script.db file | |
mapfile -t SCRIPT < <(awk -F'[{=", ]+' '$1 == "Entry"{print $3}' $filename) | |
#Maximum number of scripts to use for a host | |
MAX_SCRIPT=3 | |
PORT_LIST=(22 53 80 119 123 135 139 443 4333 5432 8080) | |
MAX_PORT=9 | |
ARGUMENTS_ARRAY=( -p -O -sV --script --traceroute) | |
for i in {1..2} | |
do | |
timeout=$(( $RANDOM % 50 + 1 )) | |
arguments="" | |
for index in `shuf --input-range=0-$(( ${#ARGUMENTS_ARRAY[*]} - 1 )) | head -$(( $RANDOM % $(( ${#ARGUMENTS_ARRAY[*]} - 1 )) + 1 ))` | |
do | |
value=$(( $RANDOM % $MAX_SCRIPT + 1 )) | |
argument=${ARGUMENTS_ARRAY[$index]} | |
if [ "$argument" == "--script" ] | |
then | |
for index2 in `shuf --input-range=0-$(( ${#SCRIPT[*]} - 1 )) | head -$(( $RANDOM % $MAX_SCRIPT + 1))` | |
do | |
script_name="${SCRIPT[$index2]},$script_name" | |
done | |
argument="$argument $script_name" | |
script_name="" | |
argument=${argument%","} | |
elif [ "$argument" == "-p" ] | |
then | |
for index2 in `shuf --input-range=0-$(( ${#PORT_LIST[*]} - 1 )) | head -$(( $RANDOM % $(( ${#PORT_LIST[*]} - 1 )) + 1))` | |
do | |
port_no="${PORT_LIST[$index2]},$port_no" | |
done | |
argument="$argument $port_no" | |
port_no="" | |
argument=${argument%","} | |
fi | |
arguments="$arguments $argument" | |
argument="" | |
done | |
arguments="sudo nmap --host-timeout $(( timeout ))s $arguments -oX $output_path/test$(( i )).xml $targets" | |
echo $arguments | |
eval $arguments | |
echo "" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment