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