you can now specify a file with ips or cidr notations

This commit is contained in:
jc
2025-06-23 11:00:47 +00:00
parent 201e851cdd
commit b9f812d2bb
+44 -36
View File
@@ -5,7 +5,7 @@ help() {
usage: $0 [-p port] [--nmap] locale
positional arguments:
locale IP or subnet to scan
locale IP, Subnet or File
options:
-p, --port scan specific port(s)
@@ -101,6 +101,42 @@ scan_tcp(){
[[ -f /tmp/tcp_ports ]] && { command="nmap -Pn -n -sCV -p $(allports=($(</tmp/tcp_ports)); data=${allports[*]}; echo ${data//${IFS:0:1}/,}) $ip -oN ${ip}_nmap.out -v"; echo; [[ $RUN_NMAP == true ]] && { pp "Service Enumeration"; $command; return; }; }
}
do_ip(){
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; }; }
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;
@@ -190,7 +226,7 @@ cidr_to_ips() {
# read
[[ ! $mask == 24 ]] && [[ $HOST_SCAN == true ]] && { for ((c=0; c<116; c++)); do echo -n "-"; done; echo; }
[[ ! $mask == 24 ]] && { [[ ${live_count["total"]} == 0 ]] && { [[ $HOST_SCAN == true ]] && { for i in {1..4}; do UP='\033[1A'; printf "$UP"; done; }; cg_color bby "Either dead hosts in this subnet or ping is disabled :("; exit; } || { [[ $HOST_SCAN == true ]] && exit || { ips=($(sort -t. -n -k1,1 -k2,2 -k3,3 -k4,4 /tmp/ips)); return; }; }; }
[[ ! $mask == 24 ]] && { [[ $HOST_SCAN == true ]] && { [[ ${live_count["total"]} == 0 ]] && { for i in {1..4}; do UP='\033[1A'; printf "$UP"; done; cg_color bby "Either dead hosts in this subnet or ping is disabled :("; exit; } || { exit; }; } || { ips=($(sort -t. -n -k1,1 -k2,2 -k3,3 -k4,4 /tmp/ips)); return; }; }
[[ -f /tmp/ips ]] && ips=($(sort -t. -n -k +4 /tmp/ips)) || { cg_color bby "Either dead hosts in this subnet or ping is disabled :("; exit; }
[[ $HOST_SCAN == true ]] && { out=${ips[*]}; l="\n"; echo -n "Number of live hosts: "; cg_color bbb ${#ips[@]}; echo -e "\e[1;92m${out//${IFS:0:1}/$l}\e[0m"; exit; } || return
}
@@ -241,6 +277,8 @@ while [ "$1" != "" ]; do
ip=$1
elif [[ $1 =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+/[0-9]+$ ]]; then
cidr=$1
elif [[ -f $1 ]]; then
ipocalypse=($(<$1))
else
help
exit
@@ -250,7 +288,7 @@ while [ "$1" != "" ]; do
shift
done
[[ ! ($ip||$cidr) ]] && help
[[ ! ($ip||$cidr||$ipocalypse) ]] && help
# Clean up
cl
@@ -258,39 +296,9 @@ cl
# Scan TCP ports
keyports=([21]=0 [22]=0 [80]=0 [88]=0 [135]=0 [443]=0 [445]=0 [554]=0 [1433]=0 [1521]=0 [2049]=0 [2375]=0 [3000]=0 [3306]=0 [4786]=0 [5000]=0 [5432]=0 [5984]=0 [6379]=0 [8000]=0 [8009]=0 [8080]=0 [8443]=0 [9090]=0 [9100]=0 [9200]=0 [10050]=0 [15672]=0 [27017]=0)
[[ $POINTERS == true ]] && { a=${!keyports[@]}; mports=${a// /,}; }
[[ $ipocalypse ]] && { for line in ${ipocalypse[@]}; do [[ $line =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]] && { ip=$line; do_ip; } || { [[ $line =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+/[0-9]+$ ]] && { cidr=$line; do_cidr; }; } || { continue; }; done; exit; }
if [[ $ip ]]; then
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; }; }
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_ip
elif [[ $cidr ]]; then
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
do_cidr
fi