This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| muf:it:recipies [2025/02/18 10:23] – [xmlrpc dokuvimki edit] mfulz | muf:it:recipies [2025/09/23 23:39] (current) – [DokuVimNG edit] mfulz | ||
|---|---|---|---|
| Line 18: | Line 18: | ||
| </ | </ | ||
| - Import the OTP in KeePassXC {{muf: | - Import the OTP in KeePassXC {{muf: | ||
| + | |||
| + | ==== Hide & Seek ==== | ||
| + | |||
| + | All stuff about searching everywhre and everything ;) | ||
| + | |||
| + | === Git I'll find you :P === | ||
| + | |||
| + | Git I'll find you :P | ||
| + | Full-history regex scan (mirror clone) | ||
| + | |||
| + | Below is a ready-to-run shell helper that clones a repo as a mirror (so all refs/tags are included) and executes regex searches across all commits / blobs. | ||
| + | |||
| + | Save as scan_public_repo_regex.sh, | ||
| + | |||
| + | < | ||
| + | |||
| + | REPO_URL=" | ||
| + | PATTERN=" | ||
| + | EXCLUDE=" | ||
| + | |||
| + | if [[ -z " | ||
| + | cat << | ||
| + | Usage: $0 < | ||
| + | Example: | ||
| + | $0 https:// | ||
| + | ' | ||
| + | USAGE | ||
| + | exit 2 | ||
| + | fi | ||
| + | |||
| + | TMP=" | ||
| + | trap 'rm -rf " | ||
| + | cd " | ||
| + | |||
| + | echo "[*] Cloning mirror of ' | ||
| + | git clone --mirror " | ||
| + | cd repo.git | ||
| + | |||
| + | REVLIST=" | ||
| + | if [[ -z " | ||
| + | echo "[!] no refs found" | ||
| + | exit 1 | ||
| + | fi | ||
| + | |||
| + | echo "[] Running git grep across all commits (pattern):" | ||
| + | echo " $PATTERN" | ||
| + | if [[ -n " | ||
| + | echo "[] Exclude pattern:" | ||
| + | echo " $EXCLUDE" | ||
| + | fi | ||
| + | echo | ||
| + | |||
| + | Try PCRE first; fallback otherwise | ||
| + | |||
| + | set +e | ||
| + | if git grep -P -n --text --heading --break -e " | ||
| + | if [[ -n " | ||
| + | git grep -P -n --text --heading --break -e " | ||
| + | | grep -P -v --color=never " | ||
| + | else | ||
| + | git grep -P -n --text --heading --break -e " | ||
| + | fi | ||
| + | else | ||
| + | echo "[*] git grep -P not available or failed, falling back to POSIX regex and grep filter." | ||
| + | if [[ -n " | ||
| + | git grep -n --text --heading --break -G -e " | ||
| + | | ( grep -P -v --color=never " | ||
| + | else | ||
| + | git grep -n --text --heading --break -G -e " | ||
| + | fi | ||
| + | fi | ||
| + | set -e | ||
| + | |||
| + | echo | ||
| + | echo "[*] Also scanning commit messages (git log --grep)..." | ||
| + | if [[ -n " | ||
| + | git log --all --pretty=fuller --grep=" | ||
| + | | awk '/ | ||
| + | | xargs -I{} bash -c 'git show --pretty=fuller {} || true' | ||
| + | | ( grep -P -v --color=never " | ||
| + | else | ||
| + | git log --all --pretty=fuller --grep=" | ||
| + | fi | ||
| + | |||
| + | echo | ||
| + | echo "[*] Done. Temp dir: $TMP (auto-removed on exit)." | ||
| + | </ | ||
| + | |||
| + | Quick usage examples | ||
| + | |||
| + | Literal / case-insensitive search for EXACT_STRING (YOUR-EXACT-STRING): | ||
| + | |||
| + | < | ||
| + | |||
| + | ./ | ||
| + | ' | ||
| + | </ | ||
| + | |||
| + | Regex search: find keys like user: username or user = username (case-insensitive): | ||
| + | |||
| + | < | ||
| + | |||
| + | ' | ||
| + | </ | ||
| + | |||
| + | Search for password variants (password, passwd, pwd) next to a value: | ||
| + | |||
| + | < | ||
| + | |||
| + | ' | ||
| + | </ | ||
| + | |||
| + | Combined: look for any auth/ | ||
| + | |||
| + | < | ||
| + | |||
| + | ' | ||
| + | </ | ||
| + | |||
| + | Your “SEARCH FOR but EXCLUDE exact username/ | ||
| + | |||
| + | < | ||
| + | |||
| + | ' | ||
| + | ' | ||
| + | </ | ||
| + | This finds user: < | ||
| + | |||
| + | Notes on the examples & intuition | ||
| + | |||
| + | Why so many variants? Humans store credentials in many ways. Use these families: | ||
| + | |||
| + | Key names: user, username, uid, owner · pass, passwd, password, pwd · secret, api_key, apikey, api-key · token, auth, access_token, | ||
| + | |||
| + | Separators: key: value · key = value · key => value · " | ||
| + | |||
| + | Value patterns: Base64-like [A-Za-z0-9+/ | ||
| + | |||
| + | Practical approach: | ||
| + | |||
| + | Start literal with YOUR-EXACT-STRING (fast, exact). | ||
| + | |||
| + | Expand to key families: password|passwd|pwd|secret|token|api[_-]? | ||
| + | |||
| + | Add context anchors: check left key names or separators. | ||
| + | |||
| + | Need to ignore a known safe value → negative lookahead (?!value) or post-filter grep -v. | ||
| + | |||
| + | Too much noise → restrict file types (*.env, *.yaml, *.json, *.tf, *.ini). | ||
| + | |||
| + | Regex cheat-sheet (PCRE, case-insensitive) | ||
| + | |||
| + | Simple literal (case-insensitive) | ||
| + | |||
| + | < | ||
| + | |||
| + | (? | ||
| + | </ | ||
| + | |||
| + | Keys + value (JSON/ | ||
| + | |||
| + | < | ||
| + | |||
| + | (? | ||
| + | (? | ||
| + | </ | ||
| + | |||
| + | Auth/ | ||
| + | |||
| + | < | ||
| + | |||
| + | (? | ||
| + | </ | ||
| + | |||
| + | Base64-ish blobs (suspicious but noisy) | ||
| + | |||
| + | < | ||
| + | |||
| + | [A-Za-z0-9+/ | ||
| + | </ | ||
| + | |||
| + | URL with embedded basic auth (user: | ||
| + | |||
| + | < | ||
| + | |||
| + | (? | ||
| + | </ | ||
| + | |||
| + | “SEARCH FOR but EXCLUDE” (negative lookahead) | ||
| + | |||
| + | < | ||
| + | |||
| + | (? | ||
| + | (? | ||
| + | </ | ||
| + | |||
| + | Practical tips | ||
| + | |||
| + | Use literal -F for your exact known string first — zero false positives. | ||
| + | |||
| + | To exclude a test token: post-filter with grep -v or use PCRE negative lookahead. | ||
| + | |||
| + | If your git grep lacks -P, fallback with git grep -G then pipe into grep -P or perl. | ||
| + | |||
| + | Limit file types to reduce noise: | ||
| + | |||
| + | < | ||
| + | |||
| + | git grep -P -n -I --heading --break -e ' | ||
| + | </ | ||
| + | |||
| + | Inspect matches precisely: | ||
| + | |||
| + | < | ||
| + | |||
| + | git show < | ||
| + | </ | ||
| + | |||
| + | Example workflows | ||
| + | |||
| + | Exact-string quick check (literal): | ||
| + | |||
| + | < | ||
| + | |||
| + | ./ | ||
| + | ' | ||
| + | </ | ||
| + | |||
| + | Password-like keys but ignore known placeholder secret: | ||
| + | |||
| + | < | ||
| + | |||
| + | ./ | ||
| + | ' | ||
| + | </ | ||
| + | |||
| + | Any API keys/ | ||
| + | |||
| + | < | ||
| + | |||
| + | ./ | ||
| + | ' | ||
| + | </ | ||
| + | |||
| + | Safety / assurance notes | ||
| + | |||
| + | This script only reads repo objects; it does not modify the remote. | ||
| + | |||
| + | If you find a secret in the public repo, rotate/ | ||
| + | |||
| + | PCRE-first: the script attempts -P and falls back if unavailable. | ||
| ===== OS Tricks ===== | ===== OS Tricks ===== | ||