added a --threads flag for specifying the number of threads

This commit is contained in:
jc
2025-06-24 06:16:12 +00:00
parent 0bf99656a5
commit 28c327b2aa
+7 -1
View File
@@ -15,6 +15,7 @@ options:
--force scan open ports even if ping is disabled --force scan open ports even if ping is disabled
--pointers only scan key ports --pointers only scan key ports
--httpx run httpx --httpx run httpx
-t, --threads specify the number of threads (default:50, max:500)
SYNTAX SYNTAX
exit exit
} }
@@ -92,7 +93,8 @@ scan_tcp(){
handle & pid=$! handle & pid=$!
# scan residual ports # scan residual ports
k=0; for c in $(seq 1 65535); do [[ ! ${top_1000[$c]} ]] && { tcp_scan & ((k++)); [[ $k -eq 500 ]] && { sleep .248; k=0; }; }; done [[ ! $threads ]] && threads=50
k=0; for c in $(seq 1 65535); do [[ ! ${top_1000[$c]} ]] && { tcp_scan & ((k++)); [[ $k -eq $threads ]] && { sleep .248; k=0; }; }; done
# wait # wait
kill -TERM $pid 2>/dev/null; wait kill -TERM $pid 2>/dev/null; wait
@@ -265,6 +267,10 @@ while [ "$1" != "" ]; do
--httpx) --httpx)
HTTPX=true HTTPX=true
;; ;;
-t | --threads)
shift
[[ $1 =~ ^[0-9]+ ]] && { [[ $1 -gt 500 ]] && { cg_color bby "So now you just want to blow up the CPU?"; help; } || { threads=$1; }; } || help
;;
*) *)
[[ $1 =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]] && { ip=$1; } || { [[ $1 =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+/[0-9]+$ ]] && { cidr=$1; }; } || { [[ -f $1 ]] && { ipocalypse=($(<$1)); }; } || help [[ $1 =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]] && { ip=$1; } || { [[ $1 =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+/[0-9]+$ ]] && { cidr=$1; }; } || { [[ -f $1 ]] && { ipocalypse=($(<$1)); }; } || help
;; ;;