#!/usr/bin/env zsh # ── strings.zsh : pull human-readable text out of binaries ─────────────────── # Firmware, malware samples, CTF binaries, core dumps, stripped ELFs — strings # yanks printable runs so you can grep them for URLs, creds, flags, paths. # Real work = strings PIPED into grep. The verbs below just set good defaults. # # stringsn N f only runs ≥ N chars (cut the noise; 8 is a good floor) # stringsa f scan the WHOLE file, not just loadable sections # stringsx f show hex OFFSET of each run (-t x) — locate it later # strhunt f one-shot: creds/URLs/keys sweep (strings|grep) # strings-cheat this card if command -v strings >/dev/null 2>&1; then alias stringsn='strings -n' # stringsn 8 file alias stringsa='strings -a' # scan all sections alias stringsx='strings -a -t x' # with hex offsets fi # strhunt -- fast triage: readable ≥6-char runs that smell like secrets/IOCs. strhunt() { local f=${1:?usage: strhunt } strings -a -n 6 -- "$f" | grep --color=always -Ei 'pass|passwd|pwd|secret|token|api[_-]?key|key=|BEGIN [A-Z]* ?PRIVATE|https?://|ftp://|[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+|flag\{|/bin/|/etc/|\.dll|cmd\.exe' } strcheat() { print -P "" print -P "%F{#9ccfd8}▰▰▶ STRINGS CHEAT SHEET%f %F{#908caa}readable text out of binaries%f" print -P "%F{#908caa}──────────────────────────────────────────────────────────────%f" print -P "%F{#f6c177} shape%f %F{#e0def4}strings [flags] file%f → prints printable runs, one per line" print -P "%F{#f6c177} the flags that matter%f" print -P " %F{#e0def4}-n 8%f minimum run length (default 4 → lots of noise; raise it)" print -P " %F{#e0def4}-a%f scan the ENTIRE file (default skips to loadable sections)" print -P " %F{#e0def4}-t x%f prefix each run with its offset (x hex · d dec · o oct)" print -P " %F{#e0def4}-e l%f 16-bit little-endian (UTF-16 — Windows/.NET strings)" print -P " %F{#908caa}s=7bit b/l=16bit B/L=32bit big/little%f" print -P " %F{#e0def4}-f%f prefix the filename (when scanning many files)" print -P "%F{#f6c177} strings is only half — pipe into grep%f" print -P " %F{#e0def4}strings -n8 bin | grep -Ei 'pass|key|token|http'%f hunt secrets" print -P " %F{#e0def4}strings bin | grep -i flag%f CTF flag grab" print -P " %F{#e0def4}strings -e l mal.exe | grep -Ei 'http|\\\\.dll'%f wide (UTF-16) IOCs" print -P " %F{#e0def4}strhunt bin%f ↑ all of that, one verb" print -P "%F{#f6c177} find WHERE a string lives (then patch/seek)%f" print -P " %F{#e0def4}strings -a -t x bin | grep -i license%f hex offset of the run" print -P "%F{#f6c177} when strings isn't enough%f" print -P " %F{#e0def4}rabin2 -zz bin%f every string incl. data %F{#e0def4}floss bin%f de-obfuscated" print -P " %F{#e0def4}binwalk bin%f find embedded files/blobs in firmware" print -P "%F{#908caa}──────────────────────────────────────────────────────────────%f" print -P "%F{#908caa} raise %f%F{#e0def4}-n%f%F{#908caa} to cut junk · add %f%F{#e0def4}-a%f%F{#908caa} on stripped/packed files · always pipe to grep%f" } alias strings-cheat='strcheat' alias strhelp='strcheat'