diff --git a/portradar.sh b/portradar.sh index 20e6344..02e4ae0 100755 --- a/portradar.sh +++ b/portradar.sh @@ -8,7 +8,7 @@ positional arguments: locale IP or subnet to scan options: - -p, --port scan a specific port + -p, --port scan specific port(s) --nmap run nmap after port scan --open only print hosts with atleast one open port --hosts only print live hosts in the subnet @@ -75,7 +75,7 @@ fast_ping(){ } scan_tcp(){ - [[ $1 ]] && { c=$1; ret=$(nc -w1 -z $ip $c 2>/dev/null; echo $?); [[ $ret == 0 ]] && { echo $c >> /tmp/tcp_ports; [[ $RUN_NMAP == true ]] && { command="nmap -Pn -n -sCV -p $(allports=($(/dev/null 2>&1; echo $?); [[ $ret == 0 ]] && echo $c >> /tmp/tcp_ports; } || { ports=${1//,/ }; for c in ${ports[@]}; do ret=$(nc -zn -w2 $ip $c >/dev/null 2>&1; echo $?); [[ $ret == 0 ]] && echo $c >> /tmp/tcp_ports; done; }; [[ -f /tmp/tcp_ports ]] && { [[ $RUN_NMAP == true ]] && { command="nmap -Pn -n -sCV -p $(allports=($(/dev/null 2>&1; echo $?); [[ $ret == 0 ]] && echo $c >> /tmp/tcp_ports; } & done; done; wait; [[ -f /tmp/tcp_ports ]] && { disc_ports=($(/dev/null 2>&1; echo $?); [[ $ret == 0 ]] && echo $c >> /tmp/tcp_ports; } & done; done; wait; [[ -f /tmp/tcp_ports ]] && { disc_ports=($( Scanning $ip" if [[ $port ]]; then scan_tcp $port; pt /tmp/tcp_ports tcp + elif [[ $ports ]]; then + scan_tcp $ports; pt /tmp/tcp_ports tcp else pp "TCP ports"; scan_tcp; pt /tmp/tcp_ports tcp fi @@ -252,6 +256,8 @@ elif [[ $cidr ]]; then echo "--> Scanning $ip" if [[ $port ]]; then scan_tcp $port; pt /tmp/tcp_ports tcp + elif [[ $ports ]]; then + scan_tcp $ports; pt /tmp/tcp_ports tcp else pp "TCP ports"; scan_tcp; pt /tmp/tcp_ports tcp fi