#!/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+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 .198; 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; } || { tcp_scan_quick(){ ret=$(nc -zn -w2 $ip $c >/dev/null 2>&1; echo $?); [[ $ret == 0 ]] && { echo $c >> /tmp/tcp_ports; }; }; for c in ${1//,/ }; do tcp_scan_quick & done; wait; }; [[ -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=($( Scanning $ip" if [[ $port ]]; then scan_tcp $port; pt /tmp/tcp_ports tcp [[ $HTTPX == true ]] && { [[ ${#http_ports[@]} != 0 || ${#https_ports[@]} != 0 ]] && { echo "[+] Running httpx"; [[ ${http_ports[@]} ]] && probe="http:${http_ports[@]}" || probe="https:${https_ports[@]}"; echo $ip | ~/go/bin/httpx -silent -fr -sc -td -title -ports $probe || echo $ip | ~/.local/share/go/bin/httpx -silent -fr -sc -td -title -ports $probe; }; } elif [[ $mports ]]; then scan_tcp $mports; pt /tmp/tcp_ports tcp [[ $HTTPX == true ]] && { [[ ${#http_ports[@]} != 0 || ${#https_ports[@]} != 0 ]] && { echo "[+] Running httpx"; [[ ${http_ports[@]} ]] && { a=${http_ports[@]}; http_ports=${a// /,}; [[ ${https_ports[@]} ]] && { a=${https_ports[@]}; https_ports=${a// /,}; probe="http:$http_ports,https:$https_ports"; } || probe="http:$http_ports"; } || { a=${https_ports[@]}; https_ports=${a// /,}; probe="https:$https_ports"; }; echo $ip | ~/go/bin/httpx -silent -fr -sc -td -title -ports $probe || echo $ip | ~/.local/share/go/bin/httpx -silent -fr -sc -td -title -ports $probe; }; } else pp "TCP ports"; scan_tcp; pt /tmp/tcp_ports tcp [[ $HTTPX == true ]] && { [[ ${#http_ports[@]} != 0 || ${#https_ports[@]} != 0 ]] && { echo "[+] Running httpx"; [[ ${http_ports[@]} ]] && { a=${http_ports[@]}; http_ports=${a// /,}; [[ ${https_ports[@]} ]] && { a=${https_ports[@]}; https_ports=${a// /,}; probe="http:$http_ports,https:$https_ports"; } || probe="http:$http_ports"; } || { a=${https_ports[@]}; https_ports=${a// /,}; probe="https:$https_ports"; }; echo $ip | ~/go/bin/httpx -silent -fr -sc -td -title -ports $probe || echo $ip | ~/.local/share/go/bin/httpx -silent -fr -sc -td -title -ports $probe; }; } fi } do_cidr(){ cidr_to_ips $cidr for ip in ${ips[@]}; do http_ports=(); https_ports=() echo "-> Scanning $ip" if [[ $port ]]; then scan_tcp $port; pt /tmp/tcp_ports tcp [[ $HTTPX == true ]] && { [[ ${#http_ports[@]} != 0 || ${#https_ports[@]} != 0 ]] && { echo "[+] Running httpx"; [[ ${http_ports[@]} ]] && probe="http:${http_ports[@]}" || probe="https:${https_ports[@]}"; echo $ip | ~/go/bin/httpx -silent -fr -sc -td -title -ports $probe || echo $ip | ~/.local/share/go/bin/httpx -silent -fr -sc -td -title -ports $probe; echo; }; } elif [[ $mports ]]; then scan_tcp $mports; pt /tmp/tcp_ports tcp [[ $HTTPX == true ]] && { [[ ${#http_ports[@]} != 0 || ${#https_ports[@]} != 0 ]] && { echo "[+] Running httpx"; [[ ${http_ports[@]} ]] && { a=${http_ports[@]}; http_ports=${a// /,}; [[ ${https_ports[@]} ]] && { a=${https_ports[@]}; https_ports=${a// /,}; probe="http:$http_ports,https:$https_ports"; } || probe="http:$http_ports"; } || { a=${https_ports[@]}; https_ports=${a// /,}; probe="https:$https_ports"; }; echo $ip | ~/go/bin/httpx -silent -fr -sc -td -title -ports $probe || echo $ip | ~/.local/share/go/bin/httpx -silent -fr -sc -td -title -ports $probe; echo; }; } else pp "TCP ports"; scan_tcp; pt /tmp/tcp_ports tcp [[ $HTTPX == true ]] && { [[ ${#http_ports[@]} != 0 || ${#https_ports[@]} != 0 ]] && { echo "[+] Running httpx"; [[ ${http_ports[@]} ]] && { a=${http_ports[@]}; http_ports=${a// /,}; [[ ${https_ports[@]} ]] && { a=${https_ports[@]}; https_ports=${a// /,}; probe="http:$http_ports,https:$https_ports"; } || probe="http:$http_ports"; } || { a=${https_ports[@]}; https_ports=${a// /,}; probe="https:$https_ports"; }; echo $ip | ~/go/bin/httpx -silent -fr -sc -td -title -ports $probe || echo $ip | ~/.local/share/go/bin/httpx -silent -fr -sc -td -title -ports $probe; echo; }; } fi [[ ($RUN_NMAP == true) && -f /tmp/tcp_ports ]] && echo http_ports=(); https_ports=() cl done } ms(){ [[ $FORCE == true ]] && return [[ $swing -eq 0 ]] && { for ((c=0; c<116; c++)); do echo -n "-"; done; echo; p1=22 p2=20 p3=70 ir "Subnet" "Number of Hosts" "Open Ports" "Subnet" "Number of Hosts" "Open Ports" ir "Subnet" "Number of Hosts" "Open Ports" " - - - - - - - - - - " " - - - - - - - - - " " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "; } local colour="olbg" if [[ ${bytes[3]} == 255 ]]; then wait; [[ -f /tmp/ips ]] && { live=($(/dev/null 2>&1; echo $?); [[ $ret == 0 ]] && echo $c >> /tmp/tcp_ports; } & done; done; wait; [[ -f /tmp/tcp_ports ]] && { disc_ports=($(