added a --open flag for better visibility of open ports, mainly across a subnet

This commit is contained in:
Collins Gitahi
2024-10-17 12:16:44 +03:00
parent a482012a34
commit 8575b492fd
+7 -2
View File
@@ -12,7 +12,8 @@ positional arguments:
options: options:
-p, --port scan a specific port -p, --port scan a specific port
--nmap run nmap after port scan --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 SYNTAX
exit exit
} }
@@ -27,7 +28,7 @@ pp(){
pt(){ pt(){
file=$1 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 [[ $RUN_NMAP == true ]] && return
ports=($(sort -n $file)) ports=($(sort -n $file))
prot=$2 prot=$2
@@ -175,6 +176,7 @@ cidr_to_ips() {
# use args # use args
RUN_NMAP=false RUN_NMAP=false
HOST_SCAN=false HOST_SCAN=false
PRINT_OPEN=false
while [ "$1" != "" ]; do while [ "$1" != "" ]; do
case $1 in case $1 in
-p | --port) -p | --port)
@@ -189,6 +191,9 @@ while [ "$1" != "" ]; do
--nmap) --nmap)
RUN_NMAP=true RUN_NMAP=true
;; ;;
--open)
PRINT_OPEN=true
;;
--hosts) --hosts)
HOST_SCAN=true HOST_SCAN=true
;; ;;