#!/usr/bin/env 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; } } handle(){ prev_la=0; for (( ; ; )); do la=$(awk '{print $1}' /proc/loadavg); [[ ($(awk -v prev_la="$prev_la" 'BEGIN{print(prev_la!=0)}') -eq 1) && ($(awk -v la="$la" -v prev_la="$prev_la" 'BEGIN{print(la>prev_la)}') -eq 1) ]] && { [[ $(awk -v la="$la" -v prev_la="$prev_la" 'BEGIN{print((la-prev_la)>=10)}') -eq 1 ]] && { prev_la=$la; kill -STOP $$; sleep .998; kill -CONT $$; continue; }; } || { [[ ($(awk -v la="$la" -v prev_la="$prev_la" 'BEGIN{print((la-prev_la)>=7)}') -eq 1) && ($(awk -v la="$la" -v prev_la="$prev_la" 'BEGIN{print((la-prev_la)<10)}') -eq 1) ]] && { prev_la=$la; kill -STOP $$; sleep .798; kill -CONT $$; continue; }; } || { [[ ($(awk -v la="$la" -v prev_la="$prev_la" 'BEGIN{print((la-prev_la)>=4)}') -eq 1) && ($(awk -v la="$la" -v prev_la="$prev_la" 'BEGIN{print((la-prev_la)<7)}') -eq 1) ]] && { prev_la=$la; kill -STOP $$; sleep .648; kill -CONT $$; continue; }; } || { [[ ($(awk -v la="$la" -v prev_la="$prev_la" 'BEGIN{print((la-prev_la)>=2)}') -eq 1) && ($(awk -v la="$la" -v prev_la="$prev_la" 'BEGIN{print((la-prev_la)<4)}') -eq 1) ]] && { prev_la=$la; kill -STOP $$; sleep .398; kill -CONT $$; continue; }; } || { [[ ($(awk -v la="$la" -v prev_la="$prev_la" 'BEGIN{print((la-prev_la)>=1)}') -eq 1) && ($(awk -v la="$la" -v prev_la="$prev_la" 'BEGIN{print((la-prev_la)<2)}') -eq 1) ]] && { prev_la=$la; kill -STOP $$; sleep .348; kill -CONT $$; continue; }; } || { prev_la=$la; }; done } 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; wait # Print all ports for nmap enumeration [[ -f /tmp/tcp_ports ]] && { 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