From ad73161463b59f6b0cac9bc7a57d30ebbf8c3fab Mon Sep 17 00:00:00 2001 From: CURSORBLOCK Date: Mon, 19 Sep 2022 20:41:10 -0500 Subject: [PATCH] Added help message --- expandcidr.sh | 52 ++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 39 insertions(+), 13 deletions(-) diff --git a/expandcidr.sh b/expandcidr.sh index f3053a1..60822c0 100644 --- a/expandcidr.sh +++ b/expandcidr.sh @@ -1,13 +1,39 @@ -# $1 - input filename -# $2 - output filename -# $3 - Randomize output number - -# Help - - -if [ -z "$3"] -   then -       nmap -sL -n -iL $1 | grep 'Nmap scan report for' | cut -f 5 -d ' ' > $2 -   else -       nmap -sL -n -iL $1 | grep 'Nmap scan report for' | cut -f 5 -d ' ' | shuf -n $3 > $2 -fi \ No newline at end of file +Help() +{ + echo "" + echo "No arguments supplied - take this:" + echo "" + echo "expandcidr - A file with a scope list in CIDR notation is expanded " + echo " to all possible IPs. It can also output instead a" + echo "▅▅▅▅▅▅▅▅▅ a specified number of unique random IPs from the output" + echo "▅▅▅▅▅▅▅▅▅ file (useful for sample testing, for ex.)." + echo "▅▅▅▅▅▅▅▅▅ Script leverages on nmap - same scope list format" + echo "▅▅▅▅ ▅▅▅▅ " + echo "▅▅▅▅▅▅▅▅▅ Example: expandcidr scope.txt output.txt 4000" + echo "" + echo "Usage: expandcidr [input file] [output file] [optional-rnd-#-ips]" + echo "" + echo "" +} + +while getopts ":h" option; do + case $option in + h) # display Help + Help + exit;; + esac +done + +if [ $# -eq 0 ] + then Help + exit 1 +fi + +# command chain + +if [ -z $3 ] + then + nmap -sL -n -iL $1 | grep 'Nmap scan report for' | cut -f 5 -d ' ' > $2 + else + nmap -sL -n -iL $1 | grep 'Nmap scan report for' | cut -f 5 -d ' ' | shuf -n $3 > $2 +fi