From 8575b492fd21500c380fe25446e93adde302114c Mon Sep 17 00:00:00 2001 From: Collins Gitahi Date: Thu, 17 Oct 2024 12:16:44 +0300 Subject: [PATCH] added a --open flag for better visibility of open ports, mainly across a subnet --- portradar.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/portradar.sh b/portradar.sh index f638281..f3b5f63 100755 --- a/portradar.sh +++ b/portradar.sh @@ -12,7 +12,8 @@ positional arguments: options: -p, --port scan a specific port --nmap run nmap after port scan - --hosts print only live hosts in the subnet + --open only print hosts with atleast one open port + --hosts only print live hosts in the subnet SYNTAX exit } @@ -27,7 +28,7 @@ pp(){ pt(){ file=$1 - [[ ! -f $file ]] && { [[ $port ]] && cg_color bby "Port $port is closed :(" || cg_color bby "No ports discovered"; return; } + [[ ! -f $file ]] && { [[ $port ]] && { [[ ! $PRINT_OPEN == true ]] && cg_color bby "Port $port is closed :(" || { UP='\033[1A'; printf "$UP"; }; } || { [[ ! $PRINT_OPEN == true ]] && cg_color bby "No ports discovered" || { for i in {1..4}; do UP='\033[1A'; printf "$UP"; done; }; }; return; } [[ $RUN_NMAP == true ]] && return ports=($(sort -n $file)) prot=$2 @@ -175,6 +176,7 @@ cidr_to_ips() { # use args RUN_NMAP=false HOST_SCAN=false +PRINT_OPEN=false while [ "$1" != "" ]; do case $1 in -p | --port) @@ -189,6 +191,9 @@ while [ "$1" != "" ]; do --nmap) RUN_NMAP=true ;; + --open) + PRINT_OPEN=true + ;; --hosts) HOST_SCAN=true ;;