make delays more iregular

This commit is contained in:
fatalerrors
2026-05-27 15:19:42 +02:00
parent fef99326c3
commit 7c761a4895

View File

@@ -116,17 +116,20 @@ export -f busy
# Simulate a long and complex compilation process # Simulate a long and complex compilation process
# Usage: fake_compile [options] # Usage: fake_compile [options]
# Options: # Options:
# --delay=<ms> : delay between output lines (milliseconds, default: 80) # --min-delay=<ms> : minimum delay between output lines (milliseconds, default: 40)
# --max-delay=<ms> : maximum delay between output lines (milliseconds, default: 150)
# --lang=<lang> : source language preset: c (default), cpp, java, python # --lang=<lang> : source language preset: c (default), cpp, java, python
# --errors : inject fake compilation errors at the end of the build # --errors : inject fake compilation errors at the end of the build
fake_compile() fake_compile()
{ {
local delay_ms="${FAKE_COMPILE_DEFAULT_DELAY:-80}" lang="c" with_errors=0 local min_ms="${FAKE_COMPILE_DEFAULT_MIN_DELAY:-40}" \
max_ms="${FAKE_COMPILE_DEFAULT_MAX_DELAY:-150}" \
lang="c" with_errors=0
local PARSED local PARSED
# Short: h, d:, l:, e # Short: h, n:, x:, l:, e
# Long: help, delay:, lang:, errors # Long: help, min-delay:, max-delay:, lang:, errors
PARSED=$(getopt -o hd:l:e --long help,delay:,lang:,errors -n 'fake_compile' -- "$@") PARSED=$(getopt -o hn:x:l:e --long help,min-delay:,max-delay:,lang:,errors -n 'fake_compile' -- "$@")
# shellcheck disable=SC2181 # getopt return code is checked immediately after # shellcheck disable=SC2181 # getopt return code is checked immediately after
if [[ $? -ne 0 ]]; then if [[ $? -ne 0 ]]; then
disp E "Invalid options, use \"fake_compile --help\" to display usage." disp E "Invalid options, use \"fake_compile --help\" to display usage."
@@ -140,16 +143,25 @@ fake_compile()
printf "fake_compile: Simulate a complex compilation process.\n\n" printf "fake_compile: Simulate a complex compilation process.\n\n"
printf "Usage: fake_compile [options]\n\n" printf "Usage: fake_compile [options]\n\n"
printf "Options:\n" printf "Options:\n"
printf "\t-h, --help\t\tDisplay this help screen\n" printf "\t-h, --help\t\t\tDisplay this help screen\n"
printf "\t-d, --delay MS\t\tDelay between lines in milliseconds (default: 80)\n" printf "\t-n, --min-delay MS\t\tMin delay between lines in milliseconds (default: 40)\n"
printf "\t-l, --lang LANG\t\tLanguage preset: c, cpp, java, python (default: c)\n" printf "\t-x, --max-delay MS\t\tMax delay between lines in milliseconds (default: 150)\n"
printf "\t-e, --errors\t\tInject fake compilation errors at the end\n" printf "\t-l, --lang LANG\t\t\tLanguage preset: c, cpp, java, python (default: c)\n"
printf "\t-e, --errors\t\t\tInject fake compilation errors at the end\n"
return 0 return 0
;; ;;
-d|--delay) -n|--min-delay)
delay_ms="$2" min_ms="$2"
if ! [[ "$delay_ms" =~ ^[0-9]+$ ]]; then if ! [[ "$min_ms" =~ ^[0-9]+$ ]]; then
disp E "Invalid delay: must be an integer (milliseconds)." disp E "Invalid min-delay: must be an integer (milliseconds)."
return 1
fi
shift 2
;;
-x|--max-delay)
max_ms="$2"
if ! [[ "$max_ms" =~ ^[0-9]+$ ]]; then
disp E "Invalid max-delay: must be an integer (milliseconds)."
return 1 return 1
fi fi
shift 2 shift 2
@@ -180,10 +192,17 @@ fake_compile()
esac esac
done done
local delay_s if [[ $min_ms -gt $max_ms ]]; then
delay_s=$(awk "BEGIN{ printf \"%.3f\", $delay_ms / 1000 }") disp E "min-delay ($min_ms) must be <= max-delay ($max_ms)."
return 1
fi
( (
rand_sleep() {
local r=$(( min_ms + RANDOM % (max_ms - min_ms + 1) ))
sleep "$(awk "BEGIN{ printf \"%.3f\", $r / 1000 }")"
}
c_files=( "main" "utils" "parser" "lexer" "codegen" "optimizer" c_files=( "main" "utils" "parser" "lexer" "codegen" "optimizer"
"allocator" "scheduler" "resolver" "runtime" "buffer" "allocator" "scheduler" "resolver" "runtime" "buffer"
"hashmap" "io" "net" "crypto" "compress" ) "hashmap" "io" "net" "crypto" "compress" )
@@ -230,13 +249,13 @@ fake_compile()
i=$(( i + 1 )) i=$(( i + 1 ))
warn_count=$(( RANDOM % 3 )) warn_count=$(( RANDOM % 3 ))
printf "[ %2d/%2d ] Compiling %s%s ...\n" "$i" "$total" "$f" "$ext" printf "[ %2d/%2d ] Compiling %s%s ...\n" "$i" "$total" "$f" "$ext"
sleep "$delay_s" rand_sleep
w=0 w=0
while [[ $w -lt $warn_count ]]; do while [[ $w -lt $warn_count ]]; do
wline="${warnings[$((RANDOM % ${#warnings[@]}))]}" wline="${warnings[$((RANDOM % ${#warnings[@]}))]}"
printf " %s%s:%d:%d: %s\n" \ printf " %s%s:%d:%d: %s\n" \
"$f" "$ext" "$(( RANDOM % 200 + 1 ))" "$(( RANDOM % 80 + 1 ))" "$wline" "$f" "$ext" "$(( RANDOM % 200 + 1 ))" "$(( RANDOM % 80 + 1 ))" "$wline"
sleep "$delay_s" rand_sleep
w=$(( w + 1 )) w=$(( w + 1 ))
done done
done done
@@ -246,7 +265,7 @@ fake_compile()
ef="${files[$((RANDOM % ${#files[@]}))]}" ef="${files[$((RANDOM % ${#files[@]}))]}"
printf " %s%s:%d:%d: %s\n" \ printf " %s%s:%d:%d: %s\n" \
"$ef" "$ext" "$(( RANDOM % 200 + 1 ))" "$(( RANDOM % 80 + 1 ))" "$eline" "$ef" "$ext" "$(( RANDOM % 200 + 1 ))" "$(( RANDOM % 80 + 1 ))" "$eline"
sleep "$delay_s" rand_sleep
done done
printf "\nBuild FAILED: %d error(s), %d warning(s)\n" \ printf "\nBuild FAILED: %d error(s), %d warning(s)\n" \
"${#errors[@]}" "$(( RANDOM % 20 + 5 ))" "${#errors[@]}" "$(( RANDOM % 20 + 5 ))"
@@ -272,15 +291,18 @@ export -f fake_compile
# Usage: hack [options] # Usage: hack [options]
# Options: # Options:
# --target=<ip> : target IP address (default: random) # --target=<ip> : target IP address (default: random)
# --delay=<ms> : delay between output lines (milliseconds, default: 120) # --min-delay=<ms> : minimum delay between output lines (milliseconds, default: 60)
# --max-delay=<ms> : maximum delay between output lines (milliseconds, default: 250)
hack() hack()
{ {
local delay_ms="${HACK_DEFAULT_DELAY:-120}" target="" local min_ms="${HACK_DEFAULT_MIN_DELAY:-60}" \
max_ms="${HACK_DEFAULT_MAX_DELAY:-250}" \
target=""
local PARSED local PARSED
# Short: h, t:, d: # Short: h, t:, n:, x:
# Long: help, target:, delay: # Long: help, target:, min-delay:, max-delay:
PARSED=$(getopt -o ht:d: --long help,target:,delay: -n 'hack' -- "$@") PARSED=$(getopt -o ht:n:x: --long help,target:,min-delay:,max-delay: -n 'hack' -- "$@")
# shellcheck disable=SC2181 # getopt return code is checked immediately after # shellcheck disable=SC2181 # getopt return code is checked immediately after
if [[ $? -ne 0 ]]; then if [[ $? -ne 0 ]]; then
disp E "Invalid options, use \"hack --help\" to display usage." disp E "Invalid options, use \"hack --help\" to display usage."
@@ -294,19 +316,28 @@ hack()
printf "hack: Simulate a dramatic hacking sequence.\n\n" printf "hack: Simulate a dramatic hacking sequence.\n\n"
printf "Usage: hack [options]\n\n" printf "Usage: hack [options]\n\n"
printf "Options:\n" printf "Options:\n"
printf "\t-h, --help\t\tDisplay this help screen\n" printf "\t-h, --help\t\t\tDisplay this help screen\n"
printf "\t-t, --target IP\t\tTarget IP address (default: random)\n" printf "\t-t, --target IP\t\t\tTarget IP address (default: random)\n"
printf "\t-d, --delay MS\t\tDelay between output lines in milliseconds (default: 120)\n" printf "\t-n, --min-delay MS\t\tMin delay between output lines in milliseconds (default: 60)\n"
printf "\t-x, --max-delay MS\t\tMax delay between output lines in milliseconds (default: 250)\n"
return 0 return 0
;; ;;
-t|--target) -t|--target)
target="$2" target="$2"
shift 2 shift 2
;; ;;
-d|--delay) -n|--min-delay)
delay_ms="$2" min_ms="$2"
if ! [[ "$delay_ms" =~ ^[0-9]+$ ]]; then if ! [[ "$min_ms" =~ ^[0-9]+$ ]]; then
disp E "Invalid delay: must be an integer (milliseconds)." disp E "Invalid min-delay: must be an integer (milliseconds)."
return 1
fi
shift 2
;;
-x|--max-delay)
max_ms="$2"
if ! [[ "$max_ms" =~ ^[0-9]+$ ]]; then
disp E "Invalid max-delay: must be an integer (milliseconds)."
return 1 return 1
fi fi
shift 2 shift 2
@@ -322,10 +353,16 @@ hack()
esac esac
done done
local delay_s if [[ $min_ms -gt $max_ms ]]; then
delay_s=$(awk "BEGIN{ printf \"%.3f\", $delay_ms / 1000 }") disp E "min-delay ($min_ms) must be <= max-delay ($max_ms)."
return 1
fi
( (
rand_sleep() {
local r=$(( min_ms + RANDOM % (max_ms - min_ms + 1) ))
sleep "$(awk "BEGIN{ printf \"%.3f\", $r / 1000 }")"
}
rand_ip() { printf '%d.%d.%d.%d\n' \ rand_ip() { printf '%d.%d.%d.%d\n' \
$(( RANDOM%223+1 )) $(( RANDOM%255 )) \ $(( RANDOM%223+1 )) $(( RANDOM%255 )) \
$(( RANDOM%255 )) $(( RANDOM%254+1 )); } $(( RANDOM%255 )) $(( RANDOM%254+1 )); }
@@ -348,77 +385,77 @@ hack()
[[ -z "$fixed_target" ]] && target="$(rand_ip)" || target="$fixed_target" [[ -z "$fixed_target" ]] && target="$(rand_ip)" || target="$fixed_target"
printf "[*] Initializing attack sequence against %s\n" "$target" printf "[*] Initializing attack sequence against %s\n" "$target"
sleep "$delay_s" rand_sleep
# Phase 1 — port scan # Phase 1 — port scan
printf "[*] Starting port scan...\n" printf "[*] Starting port scan...\n"
sleep "$delay_s" rand_sleep
open_ports=() open_ports=()
for idx in "${!ports[@]}"; do for idx in "${!ports[@]}"; do
if (( RANDOM % 3 != 0 )); then if (( RANDOM % 3 != 0 )); then
printf " %-6s open %s\n" "${ports[$idx]}/tcp" "${services[$idx]}" printf " %-6s open %s\n" "${ports[$idx]}/tcp" "${services[$idx]}"
open_ports+=( "${ports[$idx]}/${services[$idx]}" ) open_ports+=( "${ports[$idx]}/${services[$idx]}" )
sleep "$delay_s" rand_sleep
fi fi
done done
printf "[+] %d open port(s) found.\n" "${#open_ports[@]}" printf "[+] %d open port(s) found.\n" "${#open_ports[@]}"
sleep "$delay_s" rand_sleep
# Phase 2 — OS fingerprinting # Phase 2 — OS fingerprinting
printf "[*] OS fingerprinting...\n" printf "[*] OS fingerprinting...\n"
sleep "$delay_s" rand_sleep
printf "[+] Target OS: %s (MAC: %s)\n" \ printf "[+] Target OS: %s (MAC: %s)\n" \
"${os_list[$((RANDOM % ${#os_list[@]}))]}" "$(rand_mac)" "${os_list[$((RANDOM % ${#os_list[@]}))]}" "$(rand_mac)"
sleep "$delay_s" rand_sleep
# Phase 3 — CVE check # Phase 3 — CVE check
printf "[*] Checking known vulnerabilities...\n" printf "[*] Checking known vulnerabilities...\n"
sleep "$delay_s" rand_sleep
vuln_count=$(( RANDOM % 3 + 1 )) vuln_count=$(( RANDOM % 3 + 1 ))
v=0 v=0
while [[ $v -lt $vuln_count ]]; do while [[ $v -lt $vuln_count ]]; do
printf "[!] Potential vulnerability: %s\n" "${cve_ids[$((RANDOM % ${#cve_ids[@]}))]}" printf "[!] Potential vulnerability: %s\n" "${cve_ids[$((RANDOM % ${#cve_ids[@]}))]}"
sleep "$delay_s" rand_sleep
v=$(( v + 1 )) v=$(( v + 1 ))
done done
# Phase 4 — exploit # Phase 4 — exploit
printf "[*] Loading exploit module...\n"; sleep "$delay_s" printf "[*] Loading exploit module...\n"; rand_sleep
printf "[*] Bypassing firewall rules...\n"; sleep "$delay_s" printf "[*] Bypassing firewall rules...\n"; rand_sleep
printf "[*] Injecting payload" printf "[*] Injecting payload"
dots=0 dots=0
while [[ $dots -lt 6 ]]; do while [[ $dots -lt 6 ]]; do
printf "." printf "."
sleep "$(awk "BEGIN{ printf \"%.3f\", $delay_ms * 1.5 / 1000 }")" rand_sleep
dots=$(( dots + 1 )) dots=$(( dots + 1 ))
done done
printf "\n" printf "\n"
printf "[+] Shell obtained on %s\n" "$target" printf "[+] Shell obtained on %s\n" "$target"
sleep "$delay_s" rand_sleep
# Phase 5 — hash dumping # Phase 5 — hash dumping
printf "[*] Dumping password hashes...\n" printf "[*] Dumping password hashes...\n"
sleep "$delay_s" rand_sleep
for u in "${users[@]}"; do for u in "${users[@]}"; do
printf " %-12s : \$6\$%s\n" "$u" "$(rand_hash)" printf " %-12s : \$6\$%s\n" "$u" "$(rand_hash)"
sleep "$delay_s" rand_sleep
done done
# Phase 6 — cracking # Phase 6 — cracking
printf "[*] Cracking hashes (wordlist: rockyou.txt)...\n" printf "[*] Cracking hashes (wordlist: rockyou.txt)...\n"
sleep "$delay_s" rand_sleep
cracked=$(( RANDOM % ${#users[@]} + 1 )) cracked=$(( RANDOM % ${#users[@]} + 1 ))
c=0 c=0
while [[ $c -lt $cracked ]]; do while [[ $c -lt $cracked ]]; do
printf "[+] Cracked: %-12s -> %s\n" \ printf "[+] Cracked: %-12s -> %s\n" \
"${users[$c]}" "${passwords[$((RANDOM % ${#passwords[@]}))]}" "${users[$c]}" "${passwords[$((RANDOM % ${#passwords[@]}))]}"
sleep "$delay_s" rand_sleep
c=$(( c + 1 )) c=$(( c + 1 ))
done done
printf "\n[+] -------- ACCESS GRANTED -------- [+]\n" printf "\n[+] -------- ACCESS GRANTED -------- [+]\n"
printf "[*] Cleaning logs on %s...\n" "$target" printf "[*] Cleaning logs on %s...\n" "$target"
sleep "$delay_s" rand_sleep
printf "[+] Done. Have a nice day.\n" printf "[+] Done. Have a nice day.\n"
printf "\n" printf "\n"
done done