#!/bin/bash help() { cat </dev/null 2>&1; echo $?) [[ $ret == 0 ]] && { echo $c >> /tmp/tcp_ports; cg_color olbg "$c "; } } fast_ping(){ [[ $FORCE == true ]] && { echo $ip >> /tmp/ips; return; } nn=$(ping -n -w2 -c1 $ip >/dev/null 2>&1; echo $?) [[ $nn == 0 ]] && { echo $ip >> /tmp/ips; } } scan_tcp(){ [[ $1 ]] && { [[ $1 =~ ^[0-9]+$ ]] && { c=$1; ret=$(nc -zn -w2 $ip $c >/dev/null 2>&1; echo $?); [[ $ret == 0 ]] && echo $c >> /tmp/tcp_ports; } || { for c in ${1//,/ }; 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=($( Scanning $ip" if [[ $port ]]; then scan_tcp $port; pt /tmp/tcp_ports tcp elif [[ $mports ]]; then scan_tcp $mports; pt /tmp/tcp_ports tcp else pp "TCP ports"; scan_tcp; pt /tmp/tcp_ports tcp fi elif [[ $cidr ]]; then cidr_to_ips $cidr for ip in ${ips[@]}; do echo "--> Scanning $ip" if [[ $port ]]; then scan_tcp $port; pt /tmp/tcp_ports tcp elif [[ $mports ]]; then scan_tcp $mports; pt /tmp/tcp_ports tcp else pp "TCP ports"; scan_tcp; pt /tmp/tcp_ports tcp fi [[ ($RUN_NMAP == true) && -f /tmp/tcp_ports ]] && echo cl done fi