Explore #!/usr/bin/env bash installredtools.sh — generates 30 small CTF helper scripts (Bash +… Save Share Download ▾ Report#!/usr/bin/env bash
install_redtools.sh — generates 30 small CTF helper scripts (Bash + common CLI + Python3)
For legal CTF/lab use only.
set -euo pipefail
DIR="1 : − p i c o − r e d t o o l s " m k d i r − p " {1:-pico-redtools}"
mkdir -p " 1 : − p i co − r e d t oo l s " mk d i r − p " DIR"
write() {
local name="1 " s h DIR/$name" <<'EOF'
#!/usr/bin/env bash
Show full message · 559 lines AssistantCopy response Copy first prompt
Other models, same or similar prompt Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Details
Provider Anthropic
Model provenance As recorded by source dataset
Turns 1 (2 messages)
Language en
Added to archive Nov 19, 2026
ID 01m7tp8bdpb6a0bmcx5kbs7v56Source & license Imported from Arena Expert 5K (source ). Imported records earn no Research Points.
Upstream record: 75a7e4c9-0e33-48bc-91fb-c0f0b8834800:b
LMArena, Arena Expert (2025). https://news.lmarena.ai/arena-expert/
License: Prompts CC-BY-4.0; outputs governed by provider terms
Dataset releases Not yet included in a published release.
i f t c a t > " 1"
shift
cat > " 1" s hi f t c a t > "
placeholder EOF
chmod +x "D I R / DIR/ D I R / name"
}
1) b64decode_loop.sh write b64decode_loop.sh
cat > "$DIR/b64decode_loop.sh" <<'EOF'
#!/usr/bin/env bash
Repeatedly base64-decode input until it fails.
Usage: ./b64decode_loop.sh [file] > out set -euo pipefail
tmp=( m k t e m p ) ; t r a p ′ r m − f " (mktemp); trap 'rm -f " ( mk t e m p ) ; t r a p ′ r m − f " tmp"' EXIT
if [[ # -gt 0 && -f " {1:-}" ]]; then data=( c a t " (cat " ( c a t " 1"); else data=( c a t ) ; f i c o u n t = 0 w h i l e t r u e ; d o i f p r i n t f (cat); fi
count=0
while true; do
if printf %s " ( c a t ) ; f i co u n t = 0 w hi l e t r u e ; d o i f p r in t f data" | base64 -d > "t m p " 2 > / d e v / n u l l ; t h e n d a t a = " tmp" 2>/dev/null; then
data=" t m p "2 > / d e v / n u l l ; t h e n d a t a = " (cat "t m p " ) " c o u n t = tmp")"
count= t m p " ) " co u n t = ((count+1))
else
break
fi
done
printf %s "d a t a " p r i n t f " \n [ d e c o d e d data"
printf "\n[decoded %d time(s)]\n" " d a t a " p r in t f " \n [ d eco d e d count" >&2
EOF
chmod +x "$DIR/b64decode_loop.sh"
2) b64encode.sh cat > "$DIR/b64encode.sh" <<'EOF'
#!/usr/bin/env bash
Base64-encode input N times (default 1).
Usage: ./b64encode.sh [-n N] [file] set -euo pipefail
N=1
if [[ "1 : − " = = " − n " ] ] ; t h e n N = " {1:-}" == "-n" ]]; then N=" 1 : − " == " − n " ]] ; t h e n N = " {2:-1}"; shift 2; fi
if [[ # -gt 0 && -f " {1:-}" ]]; then data=( c a t " (cat " ( c a t " 1"); else data=(cat); fi
for ((i=0;i<N;i++)); do
if base64 --help 2>&1 | grep -q '\-w'; then
data= (printf %s "d a t a " ∣ b a s e 64 − w 0 ) e l s e d a t a = data" | base64 -w0)
else
data= d a t a "∣ ba se 64 − w 0 ) e l se d a t a = (printf %s "d a t a " ∣ b a s e 64 ∣ t r − d ′ \n ′ ) f i d o n e p r i n t f data" | base64 | tr -d '\n')
fi
done
printf %s " d a t a "∣ ba se 64∣ t r − d ′ \n ′ ) data"\n
EOF
chmod +x "$DIR/b64encode.sh"
3) base32decode.sh cat > "$DIR/base32decode.sh" <<'EOF'
#!/usr/bin/env bash
Base32 decode (case-insensitive).
Usage: ./base32decode.sh [file] > out set -euo pipefail
if command -v python3 >/dev/null 2>&1; then
if [[ # -gt 0 && -f " {1:-}" ]]; then cat "1"; else cat; fi | \
python3 - <<'PY'
import sys, base64
data = sys.stdin.buffer.read().replace(b'\n', b'')
sys.stdout.buffer.write(base64.b32decode(data, casefold=True))
PY
elif command -v base32 >/dev/null 2>&1; then
if [[ # -gt 0 && -f "1 : − " ] ] ; t h e n b a s e 32 − d " {1:-}" ]]; then base32 -d " 1 : − " ]] ; t h e nba se 32 − d " 1"; else base32 -d; fi
else
echo "Need python3 or base32." >&2; exit 1
fi
EOF
chmod +x "$DIR/base32decode.sh"
4) url_decode.sh cat > "$DIR/url_decode.sh" <<'EOF'
#!/usr/bin/env bash
URL-decode
Usage: echo 'foo%20bar' | ./url_decode.sh set -euo pipefail
if command -v python3 >/dev/null 2>&1; then
python3 - <<'PY'
import sys, urllib.parse
print(urllib.parse.unquote_plus(sys.stdin.read()), end="")
PY
else
sed -e 's/+/ /g' -e 's/%/\x/g' | xargs -0 printf "%b" || true
fi
EOF
chmod +x "$DIR/url_decode.sh"
5) url_encode.sh cat > "$DIR/url_encode.sh" <<'EOF'
#!/usr/bin/env bash
URL-encode
Usage: echo 'a b&c' | ./url_encode.sh set -euo pipefail
if command -v python3 >/dev/null 2>&1; then
python3 - <<'PY'
import sys, urllib.parse
print(urllib.parse.quote_plus(sys.stdin.read()), end="")
PY
else
python - <<'PY'
import sys, urllib
print urllib.quote_plus(sys.stdin.read()),
PY
fi
EOF
chmod +x "$DIR/url_encode.sh"
6) hex2bin.sh cat > "$DIR/hex2bin.sh" <<'EOF'
#!/usr/bin/env bash
Convert hex to raw bytes.
Usage: ./hex2bin.sh [file-or-hex] > out.bin set -euo pipefail
if [[ # -gt 0 && -f " {1:-}" ]]; then
tr -d ' \t\r\n' < "1 " ∣ x x d − r − p e l i f [ [ 1" | xxd -r -p
elif [[ 1"∣ xx d − r − p e l i f [[ # -gt 0 ]]; then
printf %s "1 " ∣ t r − d ′ \t \n ˚ ′ ∣ x x d − r − p e l s e t r − d ′ \t \n ˚ ′ ∣ x x d − r − p f i E O F c h m o d + x " 1" | tr -d ' \t\r\n' | xxd -r -p
else
tr -d ' \t\r\n' | xxd -r -p
fi
EOF
chmod +x " 1"∣ t r − d ′ \t \n ˚ ′ ∣ xx d − r − p e l DIR/hex2bin.sh"
7) bin2hex.sh cat > "$DIR/bin2hex.sh" <<'EOF'
#!/usr/bin/env bash
Convert bytes to hex (continuous).
Usage: ./bin2hex.sh file.bin set -euo pipefail
if [[ # -gt 0 && -f " {1:-}" ]]; then xxd -p -c 999999 "1 " e l s e x x d − p − c 999999 f i E O F c h m o d + x " 1"
else xxd -p -c 999999
fi
EOF
chmod +x " 1" e l se xx d − p − c 999999 f i E O F c hm o d + x " DIR/bin2hex.sh"
8) rotN.sh cat > "$DIR/rotN.sh" <<'EOF'
#!/usr/bin/env bash
ROT-N (default 13). Letters only.
Usage: echo Hello | ./rotN.sh [N] set -euo pipefail
N="1 : − 13 " p y t h o n 3 − " {1:-13}"
python3 - " 1 : − 13 " p y t h o n 3 − " N" <<'PY'
import sys
n=int(sys.argv[1])
text=sys.stdin.read()
out=[]
for ch in text:
o=ord(ch)
if 65<=o<=90: out.append(chr((o-65+n)%26+65))
elif 97<=o<=122: out.append(chr((o-97+n)%26+97))
else: out.append(ch)
sys.stdout.write(''.join(out))
PY
EOF
chmod +x "$DIR/rotN.sh"
9) caesar_bruteforce.sh cat > "$DIR/caesar_bruteforce.sh" <<'EOF'
#!/usr/bin/env bash
Try all ROT 0-25 shifts.
Usage: echo "uryyb" | ./caesar_bruteforce.sh set -euo pipefail
text="( c a t ) " f o r n i n (cat)"
for n in ( c a t ) " f or nin (seq 0 25); do
printf "ROT %02d: " "n " p r i n t f n"
printf %s " n " p r in t f text" | "0 d i r / r o t N . s h " " 0_dir/rotN.sh" " 0 d i r / r o tN . s h "" n" 2>/dev/null || {
python3 - "n" <<'PY'
import sys
n=int(sys.argv[1]); t=sys.stdin.read()
def rot(text,n):
r=[]
for ch in text:
o=ord(ch)
if 65<=o<=90: r.append(chr((o-65+n)%26+65))
elif 97<=o<=122: r.append(chr((o-97+n)%26+97))
else: r.append(ch)
return ''.join(r)
print(rot(t,n), end='')
PY
}
printf "\n"
done
EOF
chmod +x " DIR/caesar_bruteforce.sh"
fix $0_dir reference sed -i '1i 0_dir="( c d " (cd " ( c d " (dirname "0")" && pwd)"' " DIR/caesar_bruteforce.sh" || true
10) xor_single_byte_bruteforce.sh cat > "$DIR/xor_single_byte_bruteforce.sh" <<'EOF'
#!/usr/bin/env bash
Single-byte XOR brute-force (prints top candidates).
Usage: ./xor_single_byte_bruteforce.sh <hexstring|file> set -euo pipefail
if [[ # -lt 1 ]]; then echo "Usage: 0 <hexstring|file>" >&2; exit 1; fi
if [[ -f "1 " ] ] ; t h e n h e x = 1" ]]; then hex= 1" ]] ; t h e nh e x = (xxd -p -c 999999 "1 " ∣ t r − d ′ \n ′ ) ; e l s e h e x = " 1" | tr -d '\n'); else hex=" 1"∣ t r − d ′ \n ′ ) ; e l se h e x = " 1"; fi
python3 - "h e x " < < ′ P Y ′ i m p o r t s y s , b i n a s c i i , s t r i n g h e x d a t a = s y s . a r g v [ 1 ] d a t a = b i n a s c i i . u n h e x l i f y ( h e x d a t a ) d e f s c o r e ( b ) : r e t u r n s u m ( 1 f o r c i n b i f 32 < = c < 127 o DIR/xor_single_byte_bruteforce.sh"
11) xor_with_key.sh cat > "$DIR/xor_with_key.sh" <<'EOF'
#!/usr/bin/env bash
XOR bytes with repeating ASCII key.
Usage: ./xor_with_key.sh KEY [file] > out set -euo pipefail
if [[ # -lt 1 ]]; then echo "Usage: 0 KEY [file|-]" >&2; exit 1; fi
KEY="1 " ; s h i f t ∣ ∣ t r u e i f [ [ 1"; shift || true
if [[ 1" ; s hi f t ∣∣ t r u e i f [[ # -gt 0 && "1" != "-" && -f " 1" ]]; then exec < "1 " ; f i p y t h o n 3 − " 1"; fi
python3 - " 1" ; f i p y t h o n 3 − " KEY" <<'PY'
import sys
key=sys.argv[1].encode()
data=sys.stdin.buffer.read()
out=bytes(b ^ key[i%len(key)] for i,b in enumerate(data))
sys.stdout.buffer.write(out)
PY
EOF
chmod +x "$DIR/xor_with_key.sh"
12) vigenere.sh cat > "$DIR/vigenere.sh" <<'EOF'
#!/usr/bin/env bash
Vigenère cipher encrypt/decrypt (letters only).
Usage: echo HELLOWORLD | ./vigenere.sh -e KEY
echo RIJVSUYVJN | ./vigenere.sh -d KEY set -euo pipefail
MODE="-d"
if [[ "1 : − " = = " − e " ∣ ∣ " {1:-}" == "-e" || " 1 : − " == " − e "∣∣" {1:-}" == "-d" ]]; then MODE="1 " ; s h i f t ; f i K E Y = " 1"; shift; fi
KEY=" 1" ; s hi f t ; f i K E Y = " {1:?Need KEY}"; KEY=( p r i n t f (printf %s " ( p r in t f KEY" | tr '[:lower:]' '[:upper:]' | tr -cd 'A-Z')
python3 - "M O D E " " MODE" " M O D E "" KEY" <<'PY'
import sys
mode,key=sys.argv[1],sys.argv[2]
text=sys.stdin.read()
def shift(c,k,enc=True):
if not c.isalpha(): return c
base='A' if c.isupper() else 'a'; o=ord(c)-ord(base); kk=ord(k)-65
n=(o+kk)%26 if enc else (o-kk)%26
return chr(n+ord(base))
out=[]; j=0
for c in text:
if c.isalpha():
out.append(shift(c, key[j%len(key)], enc=(mode=='-e'))); j+=1
else: out.append(c)
sys.stdout.write(''.join(out))
PY
EOF
chmod +x "$DIR/vigenere.sh"
13) file_inspect.sh cat > "$DIR/file_inspect.sh" <<'EOF'
#!/usr/bin/env bash
Quick file triage: type, size, hashes, magic bytes, strings, exif if available.
Usage: ./file_inspect.sh file set -euo pipefail
f="1 : ? f i l e r e q u i r e d " e c h o " = = f i l e = = " f i l e " {1:?file required}"
echo "== file =="
file " 1 : ? f i l er e q u i r e d " ec h o " == f i l e == " f i l e " f" || true
echo "== size =="
stat --printf="bytes:%s\n" "f " 2 > / d e v / n u l l ∣ ∣ s t a t − f " b y t e s : f" 2>/dev/null || stat -f "bytes:%z" " f "2 > / d e v / n u l l ∣∣ s t a t − f " b y t es : f"
echo "== hashes =="
{ md5sum "f " 2 > / d e v / n u l l ∣ ∣ m d 5 − r " f" 2>/dev/null || md5 -r " f "2 > / d e v / n u l l ∣∣ m d 5 − r " f"; } | sed 's/^/MD5: /'
{ sha1sum "f " 2 > / d e v / n u l l ∣ ∣ s h a s u m " f" 2>/dev/null || shasum " f "2 > / d e v / n u l l ∣∣ s ha s u m " f"; } | sed 's/^/SHA1: /'
{ sha256sum "f " 2 > / d e v / n u l l ∣ ∣ s h a s u m − a 256 " f" 2>/dev/null || shasum -a 256 " f "2 > / d e v / n u l l ∣∣ s ha s u m − a 256" f"; } | sed 's/^/SHA256: /'
echo "== magic (first 64 bytes) =="
xxd -g1 -l 64 "f " e c h o " = = s t r i n g s ( m i n 6 c h a r s , t o p 50 ) = = " s t r i n g s − n 6 " f"
echo "== strings (min 6 chars, top 50) =="
strings -n 6 " f " ec h o " == s t r in g s ( min 6 c ha r s , t o p 50 ) == f" | head -50 || true
if command -v exiftool >/dev/null 2>&1; then
echo "== exiftool =="
exiftool "f " ∣ h e a d − 100 f i E O F c h m o d + x " f" | head -100
fi
EOF
chmod +x " f "∣ h e a d − 100 f i E O F c hm o d + x " DIR/file_inspect.sh"
14) carve_png.sh cat > "$DIR/carve_png.sh" <<'EOF'
#!/usr/bin/env bash
Carve first PNG from a blob by signature and IEND.
Usage: ./carve_png.sh blob.bin out.png set -euo pipefail
inp="1 : ? b l o b " ; o u t = " {1:?blob}"; out=" 1 : ? b l o b " ; o u t = " {2:?out.png}"
python3 - "i n p " " inp" " in p "" out" <<'PY'
import sys, binascii
data=open(sys.argv[1],'rb').read()
sig=b'\x89PNG\r\n\x1a\n'
start=data.find(sig)
if start==-1: sys.exit("PNG signature not found")
iend=data.find(b'IEND', start)
if iend==-1: sys.exit("IEND not found")
iend+=8 # IEND + CRC
open(sys.argv[2],'wb').write(data[start:iend])
print("Wrote", sys.argv[2])
PY
EOF
chmod +x "$DIR/carve_png.sh"
15) png_chunk_dump.sh cat > "$DIR/png_chunk_dump.sh" <<'EOF'
#!/usr/bin/env bash
List PNG chunks and extract tEXt/zTXt/iTXt as text.
Usage: ./png_chunk_dump.sh file.png set -euo pipefail
png="1 : ? p n g " p y t h o n 3 − " {1:?png}"
python3 - " 1 : ? p n g " p y t h o n 3 − " png" <<'PY'
import sys, struct, zlib
with open(sys.argv[1],'rb') as f:
sig=f.read(8)
if sig!=b'\x89PNG\r\n\x1a\n': sys.exit("Not a PNG")
off=8; i=0
while True:
lenb=f.read(4)
if not lenb: break
ln=struct.unpack(">I",lenb)[0]
typ=f.read(4)
data=f.read(ln)
crc=f.read(4)
print(f"{i:02d} off=0x{off:08x} type={typ.decode()} len={ln}")
if typ in [b'tEXt', b'zTXt', b'iTXt']:
try:
if typ==b'zTXt':
k,method_and_rest=data.split(b'\x00',1)
if method_and_rest[:1]!=b'\x00': raise ValueError
txt=zlib.decompress(method_and_rest[1:])
print(" key:", k.decode(errors='ignore'))
print(" text:", txt.decode(errors='replace')[:200])
else:
print(" text:", data.decode(errors='replace')[:200])
except Exception as e:
print(" (could not parse text chunk)", e)
off += 12+ln; i+=1
PY
EOF
chmod +x "$DIR/png_chunk_dump.sh"
16) strings_grep.sh cat > "$DIR/strings_grep.sh" <<'EOF'
#!/usr/bin/env bash
Find printable strings matching a pattern.
Usage: ./strings_grep.sh file PATTERN set -euo pipefail
f="1 : ? f i l e " ; p a t = " {1:?file}"; pat=" 1 : ? f i l e " ; p a t = " {2:?pattern}"
strings -n 4 "f " ∣ g r e p − a E " f" | grep -aE " f "∣ g r e p − a E " pat" || true
EOF
chmod +x "$DIR/strings_grep.sh"
17) wordlist_mangler.sh cat > "$DIR/wordlist_mangler.sh" <<'EOF'
#!/usr/bin/env bash
Simple mangler: case flips + common suffixes.
Usage: ./wordlist_mangler.sh word > variants.txt set -euo pipefail
w="1 : ? w o r d " b a s e = ( " {1:?word}"
base=(" 1 : ? w or d " ba se = ( " w" "(tr '[:lower:]' '[:upper:]' <<<" w")" "(tr '[:lower:]' '[:upper:]' <<<" {w:0:1}")w : 1 " ) f o r b i n " {w:1}")
for b in " w : 1 " ) f or bin " {base[@]}"; do
echo "b"
for s in '' '1' '123' '!' '2024' '2025' '@' '#' '!' '1234' '321' '01' '!' '99'; do
echo " {b}s " d o n e d o n e ∣ a w k ′ ! s e e n [ {s}"
done
done | awk '!seen[ s " d o n e d o n e ∣ a w k ′ ! see n [ 0]++'
EOF
chmod +x "$DIR/wordlist_mangler.sh"
18) pcap_host_list.sh cat > "$DIR/pcap_host_list.sh" <<'EOF'
#!/usr/bin/env bash
List hosts/servers seen in a PCAP (needs tshark).
Usage: ./pcap_host_list.sh file.pcap set -euo pipefail
pcap="{1:?pcap}"
if ! command -v tshark >/dev/null 2>&1; then echo "Need tshark" >&2; exit 1; fi
echo "IPs:"; tshark -r " pcap" -T fields -e ip.src -e ip.dst 2>/dev/null | tr '\t' '\n' | sort -u
echo "DNS names:"; tshark -r "p c a p " − Y " d n s . q r y . n a m e " − T f i e l d s − e d n s . q r y . n a m e 2 > / d e v / n u l l ∣ s o r t − u E O F c h m o d + x " pcap" -Y "dns.qry.name" -T fields -e dns.qry.name 2>/dev/null | sort -u
EOF
chmod +x " p c a p " − Y " d n s . q r y . nam e " − T f i e l d s − e d n s . q r y . nam e 2 > / d e v / n u l l ∣ sor t − u E O F c hm o d + x " DIR/pcap_host_list.sh"
19) pcap_export_http.sh cat > "$DIR/pcap_export_http.sh" <<'EOF'
#!/usr/bin/env bash
Export HTTP objects from PCAP (tshark).
Usage: ./pcap_export_http.sh file.pcap outdir set -euo pipefail
pcap="1 : ? p c a p " ; o u t = " {1:?pcap}"; out=" 1 : ? p c a p " ; o u t = " {2:?outdir}"
mkdir -p "out"
if ! command -v tshark >/dev/null 2>&1; then echo "Need tshark" >&2; exit 1; fi
tshark -r " pcap" --export-objects "http,o u t " e c h o " E x p o r t e d t o out"
echo "Exported to o u t " ec h o " E x p or t e d t o out"
EOF
chmod +x "$DIR/pcap_export_http.sh"
20) http_headers.sh cat > "$DIR/http_headers.sh" <<'EOF'
#!/usr/bin/env bash
Fetch HTTP(S) headers. set -euo pipefail
url="1 : ? u r l " c u r l − s S L − D − − o / d e v / n u l l " {1:?url}"
curl -sSL -D - -o /dev/null " 1 : ? u r l " c u r l − s S L − D − − o / d e v / n u l l " url"
EOF
chmod +x "$DIR/http_headers.sh"
21) banner_grab.sh cat > "$DIR/banner_grab.sh" <<'EOF'
#!/usr/bin/env bash
TCP banner grab (sends optional payload).
Usage: ./banner_grab.sh host port [payload] set -euo pipefail
host="1 : ? h o s t " ; p o r t = " {1:?host}"; port=" 1 : ? h os t " ; p or t = " {2:?port}"; payload="{3:-}"
{ sleep 1; [[ -n " payload" ]] && printf %s "payload"; } | nc -v " host" "port" -w 3 2>&1 || true
EOF
chmod +x " DIR/banner_grab.sh"
22) tcp_check.sh cat > "$DIR/tcp_check.sh" <<'EOF'
#!/usr/bin/env bash
Check if a TCP port is open.
Usage: ./tcp_check.sh host port set -euo pipefail
host="1 : ? h o s t " ; p o r t = " {1:?host}"; port=" 1 : ? h os t " ; p or t = " {2:?port}"
if nc -z -w2 "h o s t " " host" " h os t "" port" 2>/dev/null; then
echo "OPEN: h o s t : host: h os t : port"
else
echo "CLOSED: h o s t : host: h os t : port"
fi
EOF
chmod +x "$DIR/tcp_check.sh"
23) udp_send.sh cat > "$DIR/udp_send.sh" <<'EOF'
#!/usr/bin/env bash
Send a UDP datagram and listen briefly for a reply.
Usage: echo "ping" | ./udp_send.sh host port set -euo pipefail
host="1 : ? h o s t " ; p o r t = " {1:?host}"; port=" 1 : ? h os t " ; p or t = " {2:?port}"
nc -u -w2 "h o s t " " host" " h os t "" port"
EOF
chmod +x "$DIR/udp_send.sh"
24) dns_enum_basic.sh cat > "$DIR/dns_enum_basic.sh" <<'EOF'
#!/usr/bin/env bash
Basic DNS lookups (A/AAAA/MX/TXT/CNAME/NS).
Usage: ./dns_enum_basic.sh example.com set -euo pipefail
d="1 : ? d o m a i n " f o r t i n A A A A A C N A M E M X T X T N S ; d o e c h o " = = {1:?domain}"
for t in A AAAA CNAME MX TXT NS; do
echo "== 1 : ? d o main " f or t in AAAAA C N A M E M X T X T N S ; d oec h o " == t =="
dig +short "d " " d" " d "" t"
done
EOF
chmod +x "$DIR/dns_enum_basic.sh"
25) connect_send.sh cat > "$DIR/connect_send.sh" <<'EOF'
#!/usr/bin/env bash
Connect to remote service and send data from a file or stdin.
Usage: ./connect_send.sh host port [file] set -euo pipefail
h="1 : ? h o s t " ; p = " {1:?host}"; p=" 1 : ? h os t " ; p = " {2:?port}"; f="3 : − " i f [ [ − n " {3:-}"
if [[ -n " 3 : − " i f [[ − n " f" && -f "f " ] ] ; t h e n n c " f" ]]; then nc " f " ]] ; t h e nn c " h" "p " < " p" < " p " < " f"
else nc "h " " h" " h "" p"
fi
EOF
chmod +x "$DIR/connect_send.sh"
26) jwt_decode.sh cat > "$DIR/jwt_decode.sh" <<'EOF'
#!/usr/bin/env bash
Decode JWT header and payload (no verify).
Usage: ./jwt_decode.sh set -euo pipefail
tok="1 : ? J W T " p y t h o n 3 − " {1:?JWT}"
python3 - " 1 : ? J W T " p y t h o n 3 − " tok" <<'PY'
import sys, json, base64
def b64u(s):
s+= '=' * (-len(s)%4)
return base64.urlsafe_b64decode(s.encode())
hdr,pay,_=sys.argv[1].split('.')
print("== header =="); print(json.dumps(json.loads(b64u(hdr)), indent=2))
print("== payload =="); print(json.dumps(json.loads(b64u(pay)), indent=2))
PY
EOF
chmod +x "$DIR/jwt_decode.sh"
27) zip_list_extract.sh cat > "$DIR/zip_list_extract.sh" <<'EOF'
#!/usr/bin/env bash
List ZIP contents or print a file from ZIP to stdout.
Usage: ./zip_list_extract.sh file.zip [path/in/zip] set -euo pipefail
z="1 : ? z i p " i f [ [ − z " {1:?zip}"
if [[ -z " 1 : ? z i p " i f [[ − z " {2:-}" ]]; then
unzip -l "z " e l s e u n z i p − p " z"
else
unzip -p " z " e l se u n z i p − p " z" "2 " f i E O F c h m o d + x " 2"
fi
EOF
chmod +x " 2" f i E O F c hm o d + x " DIR/zip_list_extract.sh"
28) hash_calc.sh cat > "$DIR/hash_calc.sh" <<'EOF'
#!/usr/bin/env bash
Compute MD5/SHA1/SHA256 of file or stdin.
Usage: ./hash_calc.sh [file] set -euo pipefail
if [[ -n "{1:-}" && -f " 1" ]]; then f="1"; else f="-"; fi
{ md5sum " f" 2>/dev/null || md5 -r "f"; } | sed 's/^/MD5: /'
{ sha1sum " f" 2>/dev/null || shasum "f"; } | sed 's/^/SHA1: /'
{ sha256sum " f" 2>/dev/null || shasum -a 256 "f"; } | sed 's/^/SHA256: /'
EOF
chmod +x " DIR/hash_calc.sh"
29) ssl_cert_info.sh cat > "$DIR/ssl_cert_info.sh" <<'EOF'
#!/usr/bin/env bash
Show remote TLS certificate details.
Usage: ./ssl_cert_info.sh host [port] [servername] set -euo pipefail
host="1 : ? h o s t " ; p o r t = " {1:?host}"; port=" 1 : ? h os t " ; p or t = " {2:-443}"; sni="{3:- host}"
openssl s_client -servername "s n i " − c o n n e c t " sni" -connect " s ni " − co nn ec t " host:p o r t " − s h o w c e r t s < / d e v / n u l l 2 > / d e v / n u l l ∣ o p e n s s l x 509 − n o o u t − t e x t E O F c h m o d + x " port" -showcerts </dev/null 2>/dev/null | openssl x509 -noout -text
EOF
chmod +x " p or t " − s h o w cer t s < / DIR/ssl_cert_info.sh"
30) http_status.sh cat > "$DIR/http_status.sh" <<'EOF'
#!/usr/bin/env bash
Get HTTP status code and timing.
Usage: ./http_status.sh URL set -euo pipefail
url="1 : ? u r l " c u r l − s − o / d e v / n u l l − w " c o d e : {1:?url}"
curl -s -o /dev/null -w "code:%{http_code} time_total:%{time_total}s\n" " 1 : ? u r l " c u r l − s − o / d e v / n u l l − w " co d e : url"
EOF
chmod +x "$DIR/http_status.sh"
echo "Created 30 scripts in: DIR"
printf "Tip: export PATH=\"%s:\ PATH"\n" "( c d " (cd " ( c d " DIR" && pwd)" make it powershell
Here's the PowerShell version that creates 30 CTF helper scripts for Windows:
powershell Copy code
# install_redtools.ps1 - generates 30 small CTF helper scripts (PowerShell + Python3)
# For legal CTF/lab use only.
param(
[string]$Dir = "pico-redtools"
)
$ErrorActionPreference = "Stop"
# Create directory
if (!(Test-Path $Dir)) {
New-Item -ItemType Directory -Path $Dir | Out-Null
}
function Write-Script {
param(
[string]$Name,
[string]$Content
)
$Path = Join-Path $Dir $Name
Set-Content -Path $Path -Value $Content -Encoding UTF8
Write-Host "Created: $Name" -ForegroundColor Green
}
# 1) b64decode_loop.ps1
Write-Script "b64decode_loop.ps1" @'
# Repeatedly base64-decode input until it fails
param([string]$InputFile)
if ($InputFile -and (Test-Path $InputFile)) {
$data = Get-Content $InputFile -Raw
} else {
$data = $input | Out-String
}
$count = 0
while ($true) {
try {
$bytes = [Convert]::FromBase64String($data)
$data = [System.Text.Encoding]::UTF8.GetString($bytes)
$count++
} catch {
break
}
}
Write-Output $data
Write-Host "[decoded $count time(s)]" -ForegroundColor Yellow
'@
# 2) b64encode.ps1
Write-Script "b64encode.ps1" @'
# Base64-encode input N times
param(
[int]$N = 1,
[string]$InputFile
)
if ($InputFile -and (Test-Path $InputFile)) {
$data = Get-Content $InputFile -Raw
} else {
$data = $input | Out-String
}
for ($i = 0; $i -lt $N; $i++) {
$bytes = [System.Text.Encoding]::UTF8.GetBytes($data)
$data = [Convert]::ToBase64String($bytes)
}
Write-Output $data
'@
# 3) base32decode.ps1
Write-Script "base32decode.ps1" @'
# Base32 decode (requires Python3)
param([string]$InputFile)
$pythonScript = @"
import sys, base64
data = sys.stdin.buffer.read().replace(b'\n', b'').replace(b'\r', b'')
sys.stdout.buffer.write(base64.b32decode(data, casefold=True))
"@
if ($InputFile -and (Test-Path $InputFile)) {
Get-Content $InputFile -Raw | python -c $pythonScript
} else {
$input | python -c $pythonScript
}
'@
# 4) url_decode.ps1
Write-Script "url_decode.ps1" @'
# URL-decode
param([string]$InputString)
if (!$InputString) {
$InputString = $input | Out-String
}
Add-Type -AssemblyName System.Web
[System.Web.HttpUtility]::UrlDecode($InputString)
'@
# 5) url_encode.ps1
Write-Script "url_encode.ps1" @'
# URL-encode
param([string]$InputString)
if (!$InputString) {
$InputString = $input | Out-String
}
Add-Type -AssemblyName System.Web
[System.Web.HttpUtility]::UrlEncode($InputString)
'@
# 6) hex2bin.ps1
Write-Script "hex2bin.ps1" @'
# Convert hex to raw bytes
param(
[string]$Input,
[string]$OutputFile
)
if (Test-Path $Input -PathType Leaf) {
$hex = Get-Content $Input -Raw
} elseif ($Input) {
$hex = $Input
} else {
$hex = $input | Out-String
}
$hex = $hex -replace '\s', ''
$bytes = [byte[]]::new($hex.Length / 2)
for ($i = 0; $i -lt $hex.Length; $i += 2) {
$bytes[$i/2] = [Convert]::ToByte($hex.Substring($i, 2), 16)
}
if ($OutputFile) {
[System.IO.File]::WriteAllBytes($OutputFile, $bytes)
} else {
[Console]::OpenStandardOutput().Write($bytes, 0, $bytes.Length)
}
'@
# 7) bin2hex.ps1
Write-Script "bin2hex.ps1" @'
# Convert bytes to hex
param([string]$InputFile)
if ($InputFile -and (Test-Path $InputFile)) {
$bytes = [System.IO.File]::ReadAllBytes($InputFile)
} else {
$bytes = [byte[]]($input | Out-String).ToCharArray()
}
($bytes | ForEach-Object { "{0:X2}" -f $_ }) -join ''
'@
# 8) rotN.ps1
Write-Script "rotN.ps1" @'
# ROT-N cipher (default 13)
param(
[int]$N = 13,
[string]$Text
)
if (!$Text) { $Text = $input | Out-String }
$result = ""
foreach ($ch in $Text.ToCharArray()) {
$ascii = [int]$ch
if ($ascii -ge 65 -and $ascii -le 90) {
$result += [char]((($ascii - 65 + $N) % 26) + 65)
} elseif ($ascii -ge 97 -and $ascii -le 122) {
$result += [char]((($ascii - 97 + $N) % 26) + 97)
} else {
$result += $ch
}
}
Write-Output $result -NoNewline
'@
# 9) caesar_bruteforce.ps1
Write-Script "caesar_bruteforce.ps1" @'
# Try all ROT 0-25 shifts
param([string]$Text)
if (!$Text) { $Text = $input | Out-String }
for ($n = 0; $n -le 25; $n++) {
$result = ""
foreach ($ch in $Text.ToCharArray()) {
$ascii = [int]$ch
if ($ascii -ge 65 -and $ascii -le 90) {
$result += [char]((($ascii - 65 + $n) % 26) + 65)
} elseif ($ascii -ge 97 -and $ascii -le 122) {
$result += [char]((($ascii - 97 + $n) % 26) + 97)
} else {
$result += $ch
}
}
Write-Host ("ROT {0:D2}: $result" -f $n)
}
'@
# 10) xor_single_byte_bruteforce.ps1
Write-Script "xor_single_byte_bruteforce.ps1" @'
# Single-byte XOR brute-force
param([string]$Input)
$pythonScript = @"
import sys, binascii, string
hexdata = sys.argv[1].replace(' ','')
data = binascii.unhexlify(hexdata)
def score(b):
return sum(1 for c in b if 32<=c<127 or c in b'\n\r\t')/max(1,len(b))
cands = []
for k in range(256):
pt = bytes([c^k for c in data])
cands.append((score(pt),k,pt))
for s,k,pt in sorted(cands, reverse=True)[:10]:
print(f"key=0x{k:02x} ({k}) score={s:.2f} -> {pt[:120].decode('utf-8','replace')}")
"@
if (Test-Path $Input -PathType Leaf) {
$hex = (Get-Content $Input -Raw -Encoding Byte | ForEach-Object { "{0:X2}" -f $_ }) -join ''
} else {
$hex = $Input
}
python -c $pythonScript $hex
'@
# 11) xor_with_key.ps1
Write-Script "xor_with_key.ps1" @'
# XOR with repeating key
param(
[string]$Key,
[string]$InputFile,
[string]$OutputFile
)
if ($InputFile -and (Test-Path $InputFile)) {
$data = [System.IO.File]::ReadAllBytes($InputFile)
} else {
$data = [System.Text.Encoding]::UTF8.GetBytes(($input | Out-String))
}
$keyBytes = [System.Text.Encoding]::UTF8.GetBytes($Key)
$result = New-Object byte[] $data.Length
for ($i = 0; $i -lt $data.Length; $i++) {
$result[$i] = $data[$i] -bxor $keyBytes[$i % $keyBytes.Length]
}
if ($OutputFile) {
[System.IO.File]::WriteAllBytes($OutputFile, $result)
} else {
[Console]::OpenStandardOutput().Write($result, 0, $result.Length)
}
'@
# 12) vigenere.ps1
Write-Script "vigenere.ps1" @'
# Vigenere cipher
param(
[switch]$Encrypt,
[switch]$Decrypt,
[string]$Key,
[string]$Text
)
if (!$Text) { $Text = $input | Out-String }
$Key = $Key.ToUpper() -replace '[^A-Z]',''
$result = ""
$j = 0
foreach ($ch in $Text.ToCharArray()) {
if ($ch -match '[a-zA-Z]') {
$isUpper = [char]::IsUpper($ch)
$base = if ($isUpper) { 65 } else { 97 }
$o = [int]$ch - $base
$k = [int]$Key[$j % $Key.Length] - 65
if ($Decrypt) {
$n = ($o - $k + 26) % 26
} else {
$n = ($o + $k) % 26
}
$result += [char]($n + $base)
$j++
} else {
$result += $ch
}
}
Write-Output $result -NoNewline
'@
# 13) file_inspect.ps1
Write-Script "file_inspect.ps1" @'
# File triage: type, size, hashes, magic bytes
param([string]$File)
if (!(Test-Path $File)) {
Write-Error "File not found: $File"
return
}
$item = Get-Item $File
Write-Host "== File Info ==" -ForegroundColor Cyan
Write-Host "Name: $($item.Name)"
Write-Host "Size: $($item.Length) bytes"
Write-Host "Modified: $($item.LastWriteTime)"
Write-Host "`n== Hashes ==" -ForegroundColor Cyan
$md5 = (Get-FileHash $File -Algorithm MD5).Hash
$sha1 = (Get-FileHash $File -Algorithm SHA1).Hash
$sha256 = (Get-FileHash $File -Algorithm SHA256).Hash
Write-Host "MD5: $md5"
Write-Host "SHA1: $sha1"
Write-Host "SHA256: $sha256"
Write-Host "`n== Magic Bytes (first 64) ==" -ForegroundColor Cyan
$bytes = [System.IO.File]::ReadAllBytes($File) | Select-Object -First 64
$hex = ($bytes | ForEach-Object { "{0:X2}" -f $_ }) -join ' '
$ascii = ($bytes | ForEach-Object { if ($_ -ge 32 -and $_ -le 126) { [char]$_ } else { '.' } }) -join ''
Write-Host $hex
Write-Host $ascii
'@
# 14) carve_png.ps1
Write-Script "carve_png.ps1" @'
# Carve PNG from blob
param(
[string]$InputFile,
[string]$OutputFile
)
$pythonScript = @"
import sys
data = open(sys.argv[1],'rb').read()
sig = b'\x89PNG\r\n\x1a\n'
start = data.find(sig)
if start == -1: sys.exit("PNG signature not found")
iend = data.find(b'IEND', start)
if iend == -1: sys.exit("IEND not found")
iend += 8 # IEND + CRC
open(sys.argv[2],'wb').write(data[start:iend])
print("Wrote", sys.argv[2])
"@
python -c $pythonScript $InputFile $OutputFile
'@
# 15) png_chunk_dump.ps1
Write-Script "png_chunk_dump.ps1" @'
# List PNG chunks
param([string]$PngFile)
$pythonScript = @"
import sys, struct, zlib
with open(sys.argv[1],'rb') as f:
sig = f.read(8)
if sig != b'\x89PNG\r\n\x1a\n': sys.exit("Not a PNG")
off = 8; i = 0
while True:
lenb = f.read(4)
if not lenb: break
ln = struct.unpack(">I",lenb)[0]
typ = f.read(4)
data = f.read(ln)
crc = f.read(4)
print(f"{i:02d} off=0x{off:08x} type={typ.decode()} len={ln}")
if typ in [b'tEXt', b'zTXt']:
try:
if typ == b'zTXt':
k,rest = data.split(b'\x00',1)
txt = zlib.decompress(rest[1:])
print(" key:", k.decode(errors='ignore'))
print(" text:", txt.decode(errors='replace')[:200])
else:
print(" text:", data.decode(errors='replace')[:200])
except: pass
off += 12+ln; i+=1
"@
python -c $pythonScript $PngFile
'@
# 16) strings_grep.ps1
Write-Script "strings_grep.ps1" @'
# Find strings matching pattern
param(
[string]$File,
[string]$Pattern,
[int]$MinLength = 4
)
$bytes = [System.IO.File]::ReadAllBytes($File)
$text = [System.Text.Encoding]::ASCII.GetString($bytes)
$strings = [regex]::Matches($text, "[\x20-\x7E]{$MinLength,}")
foreach ($match in $strings) {
if ($match.Value -match $Pattern) {
Write-Output $match.Value
}
}
'@
# 17) wordlist_mangler.ps1
Write-Script "wordlist_mangler.ps1" @'
# Generate word variants
param([string]$Word)
$variants = @()
$bases = @($Word, $Word.ToUpper(),
$Word.Substring(0,1).ToUpper() + $Word.Substring(1).ToLower())
$suffixes = @('', '1', '123', '!', '2024', '2025', '@', '#', '1234', '321', '01', '99')
foreach ($base in $bases) {
foreach ($suffix in $suffixes) {
$variants += "$base$suffix"
}
}
$variants | Select-Object -Unique
'@
# 18) tcp_check.ps1
Write-Script "tcp_check.ps1" @'
# Check TCP port
param(
[string]$Host,
[int]$Port,
[int]$Timeout = 2000
)
try {
$tcp = New-Object System.Net.Sockets.TcpClient
$connection = $tcp.BeginConnect($Host, $Port, $null, $null)
$wait = $connection.AsyncWaitHandle.WaitOne($Timeout, $false)
if ($wait) {
$tcp.EndConnect($connection)
Write-Host "OPEN: ${Host}:${Port}" -ForegroundColor Green
$tcp.Close()
} else {
Write-Host "CLOSED/TIMEOUT: ${Host}:${Port}" -ForegroundColor Red
}
} catch {
Write-Host "CLOSED: ${Host}:${Port}" -ForegroundColor Red
}
'@
# 19) banner_grab.ps1
Write-Script "banner_grab.ps1" @'
# TCP banner grab
param(
[string]$Host,
[int]$Port,
[string]$Payload = ""
)
try {
$tcp = New-Object System.Net.Sockets.TcpClient($Host, $Port)
$stream = $tcp.GetStream()
if ($Payload) {
$bytes = [System.Text.Encoding]::ASCII.GetBytes($Payload)
$stream.Write($bytes, 0, $bytes.Length)
}
$buffer = New-Object byte[] 4096
$read = $stream.Read($buffer, 0, 4096)
$response = [System.Text.Encoding]::ASCII.GetString($buffer, 0, $read)
Write-Output $response
$tcp.Close()
} catch {
Write-Error $_
}
'@
# 20) http_headers.ps1
Write-Script "http_headers.ps1" @'
# Get HTTP headers
param([string]$Url)
try {
$response = Invoke-WebRequest -Uri $Url -Method Head -UseBasicParsing
$response.Headers | Format-Table -AutoSize
} catch {
if ($_.Exception.Response) {
$_.Exception.Response.Headers | Format-Table -AutoSize
} else {
Write-Error $_
}
}
'@
# 21) dns_enum_basic.ps1
Write-Script "dns_enum_basic.ps1" @'
# Basic DNS lookups
param([string]$Domain)
$types = @('A','AAAA','CNAME','MX','TXT','NS')
foreach ($type in $types) {
Write-Host "== $type ==" -ForegroundColor Cyan
try {
Resolve-DnsName -Name $Domain -Type $type -ErrorAction Stop |
Select-Object Name, Type, TTL, @{N='Data';E={
if ($_.Type -eq 'MX') { "$($_.Preference) $($_.NameExchange)" }
elseif ($_.Type -eq 'TXT') { $_.Strings -join ' ' }
else { $_.IPAddress; $_.NameHost }
}} | Where-Object {$_.Data} | Format-Table -AutoSize
} catch {
Write-Host "No $type records found" -ForegroundColor Gray
}
}
'@
# 22) jwt_decode.ps1
Write-Script "jwt_decode.ps1" @'
# Decode JWT (no verification)
param([string]$Token)
function ConvertFrom-Base64Url {
param([string]$base64Url)
$base64 = $base64Url.Replace('-','+').Replace('_','/')
$pad = 4 - ($base64.Length % 4)
if ($pad -lt 4) { $base64 += "=" * $pad }
return [System.Text.Encoding]::UTF8.GetString([Convert]::FromBase64String($base64))
}
$parts = $Token.Split('.')
if ($parts.Count -ne 3) {
Write-Error "Invalid JWT format"
return
}
Write-Host "== Header ==" -ForegroundColor Cyan
ConvertFrom-Base64Url $parts[0] | ConvertFrom-Json | ConvertTo-Json
Write-Host "`n== Payload ==" -ForegroundColor Cyan
ConvertFrom-Base64Url $parts[1] | ConvertFrom-Json | ConvertTo-Json
'@
# 23) zip_list_extract.ps1
Write-Script "zip_list_extract.ps1" @'
# List or extract from ZIP
param(
[string]$ZipFile,
[string]$ExtractFile
)
Add-Type -AssemblyName System.IO.Compression.FileSystem
$zip = [System.IO.Compression.ZipFile]::OpenRead($ZipFile)
if ($ExtractFile) {
$entry = $zip.Entries | Where-Object { $_.FullName -eq $ExtractFile }
if ($entry) {
$stream = $entry.Open()
$reader = New-Object System.IO.StreamReader($stream)
Write-Output $reader.ReadToEnd()
$reader.Close()
} else {
Write-Error "File not found in ZIP: $ExtractFile"
}
} else {
$zip.Entries | Select-Object FullName, Length, CompressedLength, LastWriteTime |
Format-Table -AutoSize
}
$zip.Dispose()
'@
# 24) hash_calc.ps1
Write-Script "hash_calc.ps1" @'
# Calculate file hashes
param([string]$File)
if (!(Test-Path $File)) {
Write-Error "File not found: $File"
return
}
Write-Host "MD5: $((Get-FileHash $File -Algorithm MD5).Hash)"
Write-Host "SHA1: $((Get-FileHash $File -Algorithm SHA1).Hash)"
Write-Host "SHA256: $((Get-FileHash $File -Algorithm SHA256).Hash)"
'@
# 25) http_status.ps1
Write-Script "http_status.ps1" @'
# Get HTTP status code
param([string]$Url)
try {
$response = Invoke-WebRequest -Uri $Url -Method Head -UseBasicParsing
Write-Host "Status: $($response.StatusCode) $($response.StatusDescription)" -ForegroundColor Green
} catch {
if ($_.Exception.Response) {
$status = [int]$_.Exception.Response.StatusCode
Write-Host "Status: $status" -ForegroundColor Yellow
} else {
Write-Error $_
}
}
'@
# 26) connect_send.ps1
Write-Script "connect_send.ps1" @'
# Connect and send data to service
param(
[string]$Host,
[int]$Port,
[string]$Data
)
try {
$tcp = New-Object System.Net.Sockets.TcpClient($Host, $Port)
$stream = $tcp.GetStream()
$writer = New-Object System.IO.StreamWriter($stream)
$reader = New-Object System.IO.StreamReader($stream)
if ($Data) {
$writer.WriteLine($Data)
$writer.Flush()
}
while ($stream.DataAvailable -or $reader.Peek() -ne -1) {
Write-Output $reader.ReadLine()
}
$tcp.Close()
} catch {
Write-Error $_
}
'@
# 27) reverse_shell_listener.ps1
Write-Script "reverse_shell_listener.ps1" @'
# Simple TCP listener (for receiving connections)
param([int]$Port = 4444)
Write-Host "Listening on port $Port..." -ForegroundColor Yellow
$listener = New-Object System.Net.Sockets.TcpListener([System.Net.IPAddress]::Any, $Port)
$listener.Start()
$client = $listener.AcceptTcpClient()
Write-Host "Connection received from $($client.Client.RemoteEndPoint)" -ForegroundColor Green
$stream = $client.GetStream()
$reader = New-Object System.IO.StreamReader($stream)
$writer = New-Object System.IO.StreamWriter($stream)
$writer.AutoFlush = $true
while ($client.Connected) {
$data = $reader.ReadLine()
if ($data) { Write-Host $data }
$cmd = Read-Host ">"
if ($cmd) { $writer.WriteLine($cmd) }
}
$client.Close()
$listener.Stop()
'@
# 28) ssl_cert_info.ps1
Write-Script "ssl_cert_info.ps1" @'
# Get SSL certificate info
param(
[string]$Host,
[int]$Port = 443
)
[Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}
$tcpClient = New-Object System.Net.Sockets.TcpClient($Host, $Port)
$sslStream = New-Object System.Net.Security.SslStream($tcpClient.GetStream(), $false, {$true})
$sslStream.AuthenticateAsClient($Host)
$cert = $sslStream.RemoteCertificate
Write-Host "Subject: $($cert.Subject)"
Write-Host "Issuer: $($cert.Issuer)"
Write-Host "Valid From: $($cert.GetEffectiveDateString())"
Write-Host "Valid To: $($cert.GetExpirationDateString())"
Write-Host "Thumbprint: $($cert.GetCertHashString())"
$tcpClient.Close()
'@
# 29) find_flag_pattern.ps1
Write-Script "find_flag_pattern.ps1" @'
# Search for CTF flag patterns
param(
[string]$Path = ".",
[string]$Pattern = "flag\{[^}]+\}|FLAG\{[^}]+\}|picoCTF\{[^}]+\}|CTF\{[^}]+\}"
)
Get-ChildItem -Path $Path -Recurse -File -ErrorAction SilentlyContinue |
ForEach-Object {
$content = Get-Content $_.FullName -Raw -ErrorAction SilentlyContinue
if ($content) {
$matches = [regex]::Matches($content, $Pattern)
if ($matches.Count -gt 0) {
Write-Host "$($_.FullName):" -ForegroundColor Cyan
$matches | ForEach-Object { Write-Host " $_" -ForegroundColor Green }
}
}
}
'@
# 30) quick_webserver.ps1
Write-Script "quick_webserver.ps1" @'
# Start simple HTTP server
param(
[int]$Port = 8080,
[string]$Path = "."
)
Write-Host "Starting HTTP server on port $Port..." -ForegroundColor Yellow
Write-Host "Serving files from: $Path" -ForegroundColor Yellow
Write-Host "Press Ctrl+C to stop" -ForegroundColor Yellow
$http = [System.Net.HttpListener]::new()
$http.Prefixes.Add("http://+:$Port/")
$http.Start()
try {
while ($http.IsListening) {
$context = $http.GetContext()
$request = $context.Request
$response = $context.Response
Write-Host "$($request.HttpMethod) $($request.Url.LocalPath)" -ForegroundColor Cyan
$localPath = Join-Path $Path $request.Url.LocalPath.TrimStart('/')
if (Test-Path $localPath -PathType Leaf) {
$bytes = [System.IO.File]::ReadAllBytes($localPath)
$response.ContentLength64 = $bytes.Length
$response.OutputStream.Write($bytes, 0, $bytes.Length)
} else {
$response.StatusCode = 404
$msg = [System.Text.Encoding]::UTF8.GetBytes("Not Found")
$response.OutputStream.Write($msg, 0, $msg.Length)
}
$response.Close()
}
} finally {
$http.Stop()
}
'@
Write-Host "`nCreated 30 scripts in: $Dir" -ForegroundColor Green
Write-Host "Tip: Add to PATH with: `$env:Path += `";$(Resolve-Path $Dir)`"" -ForegroundColor Yellow
Save this as install_redtools.ps1 and run it with:
powershell Copy code
.\install_redtools.ps1
The scripts are adapted for PowerShell and Windows, using native .NET capabilities where possible and falling back to Python for complex operations. Each script can be run individually from the pico-redtools directory.
Show full message · 697 lines Copy first response
f
i
d
o
n
e
p
r
in
t
f
se
t
r
−
d ′ \t \n ˚ ′ ∣ xx d −
r −
p f i E O F c hm o d +
x "
r c i n b ′ \n \t ˚ ′ ) / m a x ( 1 , l e n ( b ) ) c a n d s = [ ] f o r k i n r a n g e ( 256 ) : p t = b y t e s ( [ c k f o r c i n d a t a ] ) c a n d s . a p p e n d ( ( s c o r e ( p t ) , k , p t ) ) f o r s , k , p t i n s o r t e d ( c a n d s , r e v e r s e = T r u e ) [ : 10 ] : p r i n t ( f " k e y = 0 x k : 02 x ( k ) s c o r e = s : .2 f − > p t [ : 120 ] . d e c o d e ( ′ u t f − 8 ′ , ′ r e p l a c e ′ ) " ) P Y E O F c h m o d + x " hex" <<'PY'
import sys, binascii, string
hexdata=sys.argv[1]
data=binascii.unhexlify(hexdata)
def score(b):
return sum(1 for c in b if 32<=c<127 or c in b'\n\r\t')/max(1,len(b))
cands=[]
for k in range(256):
pt=bytes([c^k for c in data])
cands.append((score(pt),k,pt))
for s,k,pt in sorted(cands, reverse=True)[:10]:
print(f"key=0x{k:02x} ({k}) score={s:.2f} -> {pt[:120].decode('utf-8','replace')}")
PY
EOF
chmod +x " h e x " < < ′ P Y ′ im p or t sy s , bina sc ii , s t r in g h e x d a t a = sy s . a r g v [ 1 ] d a t a = bina sc ii . u nh e x l i f y ( h e x d a t a ) d e f scor e ( b ) : r e t u r n s u m ( 1 f or c inbi f 32 <= c < 127 or c in b ′ \n \t ˚ ′ ) / ma x ( 1 , l e n ( b )) c an d s = [ ] f or k in r an g e ( 256 ) : pt = b y t es ([ c k f or c in d a t a ]) c an d s . a pp e n d (( scor e ( pt ) , k , pt )) f or s , k , pt in sor t e T r u e ) [ : 10 ] : p r in t ( f " k ey = 0 x k : 02 x ( k ) scor e = s : .2 f − > pt [ : 120 ] . d eco d e ( ′ u t f − 8 ′ , ′ r e pl a c e x "
" s t r in g s −
n 6"
d
e
v
/
n
u
l
l
2
>
/ d e v / n u l l ∣ o p e n ss l x 509 −
n oo u t −
t e x tE O F c hm o d +
x "
d
(
c
an
d
s
,
r
e
v
er
se
=
′
)
"
)
P
Y
E
O
F
c
hm
o
d
+