Write exp
Writes human-looking pwn exploit scripts in the user's local `Mypwn` style. Use when the user asks to write, adapt, humanize, or complete an exploit, exploit skeleton, menu helper set, ret2libc/heap script, shell-uploader flow, or other pwntools exploit that should match the user's actual `Mypwn` board instead of a generic template.From its SKILL.md
npx -y skills add MindednessKind/MyPwnSkill --skill write-expAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
2 things to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
11.1 KB, as published. Nobody here has run it
Write Exp
Use this skill when the exploit should read like the user's normal hand-written Mypwn board, not a polished reusable framework.
Quick Start
- Look for an existing
exp.py, old board, or nearby exploit in the same challenge folder before doing anything else. - If the user shared a board or an old exploit, follow that first and treat references/mypwn-template.py as a fallback.
- Patch an existing exploit in place when possible instead of rewriting from scratch.
- Keep the final script target-specific and slightly rigid if that matches the user's style, but make sure the exploit still works.
Required Style
- Default to
from Mypwn import *. - Add explicit
from pwn import args, process, remoteonly when the script actually uses them. Do not assumeMypwnre-exports every pwntools symbol. - Add
from libcfind import *only when the exploit actually resolves an unknown libc from a real leak. Do not add it by default. - Keep the config block shape centered on:
FILE_NAMELIBC_PATHREMOTE_TARGET
- Add optional knobs only when the target needs them, such as
IS_SSL,SNI_HOST,LOCAL_ARGV, or a GDBsrcsnippet. - Call
init(...)to set upelf,libc,GDB, and syscall helpers. Do not assumeinit(...)returnsio,elf, or wrappers. - Prefer
iopen(...)when it can launch the target cleanly, because it injectsio,s,sl,sa,sla,rcv,rcu, andshellinto globals. - Do not introduce a fresh
start()helper in new scripts. Open the tube directly where the exploit begins, typically withio = iopen(...), and only keep a legacystart()when patching an older board that already depends on it. - For TLS remotes, prefer
iopen(..., ssl=True, sni=host)oriopen(..., ssl=True, sni=SNI_HOST)when SNI matters. KeepIsSSL=Trueonly when patching an older board that already uses the compatibility spelling. - If a custom local launcher is needed, such as
ld-linux, a wrapper script, or unusual argv, start it manually and bind thin wrappers with a short localbind()helper that also exposesshell = lambda: io.interactive(). - For shell-based remote targets, prefer
prepare_shell(...),upload(...),execute(...),execute_and_wait(...), andupload_and_run(...)fromMypwnbefore writing an ad-hoc base64 uploader. - Use
Tool.get_arch_packer(...)andTool.get_byte_packer()instead of ad-hoc pack/unpack helpers. For pure-remote boards, setPACK_ARCHexplicitly before resolving packers. - For heap/tcache work, prefer
Mypwnhelpers over ad-hoc formulas:safe_linking_encrypt,safe_linking_decrypt,safe_linking_demangle,tcache_idx,tcache_layout, and especiallywrite_tcache({0x18: target})for quicktcache_perthread_structpayloads. Drop toTcachePerThreadStructoredit_tcache_perthreadonly when precise low-level patching is needed. Passglibc_versionwhen layout or safe-linking behavior matters, and overrideptr_size,bins,count_size, orfilleronly for custom/backported allocators. - Use
get_log_function()for logging. Match the user's local naming, commonlylogHex, lg, info, debug. - Keep
dbg()asGDB(io)pluspause(), orGDB(io, scripts=src)when the board already carries a local GDB script string. - End with
shell()only when the exploit is meant to stay interactive. If the exploit prints the flag and exits by design, stop there. If a manual launcher branch does not bindshell, callio.interactive()directly instead of relying on a stub.
Workflow
1. Normalize the Skeleton
Start from the reference template and align it to the target immediately:
- First scan the current challenge directory for an existing
exp.py,solve.py, or nearby sibling exploit and reuse that structure when it matches the user's style. - Set
FILE_NAMEto the real binary, loader entry, orNoneif the exploit is purely remote. - Set
LIBC_PATHonly when the libc is actually known and useful. - Preserve the user's remote toggle style:
REMOTE_TARGET = "host:port"REMOTE_TARGET = None
- For fresh scripts, keep connection setup inline in
exploit()instead of wrapping it in a newstart()helper. Preferio = iopen(...)directly in the branch that needs it. - If the challenge already contains an
exp.pyin the user's style, use it as the highest-priority structural reference. - Remove placeholder helpers, dead imports, and template noise that the exploit does not need.
2. Match the Challenge Interface
Write thin helpers that mirror the real target:
- Menu binaries:
cmd,add,edit,dele,show, and similar wrappers. - Line-oriented services: small
bind,sendline, orrecvuntilhelpers that match the prompts exactly. - Shell uploader or kernel helpers: short wrappers named after the primitive, not a generic framework layer. Reuse
prepare_shell(...)and the uploader helpers before writing a custom uploader.
Keep prompts and payloads in bytes. Use itb() for numeric menu arguments when that fits the board.
3. Build the Exploit in the User's Mypwn Style
- Parse leaks close to where they are received.
- Keep offsets, gadgets, fake chunks, and ROP setup grouped near the exploit step that uses them.
- Prefer short comments only around the non-obvious transitions.
- Avoid over-abstracting. The exploit should look like it was written for this target, not prepared as a reusable library.
- Keep retries, CLI parsing, or extra configurability only when the exploit genuinely needs them.
- When editing
tcache_perthread_struct, start withwrite_tcache({0x18: stack_anchor_target}, data=raw, glibc_version=...); dict keys are malloc request sizes by default, so usekey="chunk"orkey="idx"only when needed. Usefiller=for the unmodified bytes/count area, and remember glibc 2.42+ usesnum_slotswith 76 bins. - For shell targets, only keep custom upload code when
Mypwn.uploadergenuinely cannot handle the environment. - Do not force
upload_and_run(...)when the target's post-exec behavior is unusual. If output collection is target-specific, useupload(...)for transport and then drive execution and reads manually.
4. Finish Cleanly
Before returning the exploit:
- Remove
pass,NotImplementedError, unused helper stubs, and scratch code. - Make sure local and remote branches are both coherent.
- Ensure SSL handling, custom loaders, and prompt sync match the actual target.
- Keep the script runnable as a single file unless the challenge already depends on a helper binary or build step.
- Run a real verification when practical. A human-looking exploit still needs to exploit successfully.
Libc Policy
- If
LIBC_PATHis known, prefer it and avoidlibcfind. - If libc is unknown but there is a meaningful leak path, add
from libcfind import *and resolve it from the leak close to where the leak is parsed. - Do not assign
libc.addressunlesslibcis a real ELF object. If you only resolved offsets fromLibcSearcher, keep them in locals such aslibc_base,system_addr, andbinsh_addr. - If libc is unknown and there is no leak yet, keep
LIBC_PATH = Noneand write the current stage cleanly instead of inventing fake resolution logic.
Minimal pattern:
from libcfind import *
puts_addr = unpk(rcu(b"\x7f", drop=False)[-6:])
db = LibcSearcher("puts", puts_addr)
libc_base = puts_addr - db.symbols["puts"]
system_addr = libc_base + db.dump("system")
binsh_addr = libc_base + db.dump("str_bin_sh")
Heap Helper Notes
Use these helpers when they match the primitive; do not reimplement them inline unless the installed Mypwn is older.
GLIBC_VERSION = "2.35"
pos = chunk_addr # address of the stored next/fd field
fd = safe_linking_encrypt(target_addr, pos, glibc_version=GLIBC_VERSION)
target = safe_linking_decrypt(fd, pos, glibc_version=GLIBC_VERSION)
payload = write_tcache(
{0x18: fake_chunk},
data=raw_tcache,
glibc_version=GLIBC_VERSION,
filler=b"\x00",
)
safe_linking_demangle(...) is only for leaks shaped like x ^ (x >> 12) when the storage address is not known; exact pointer recovery should use safe_linking_decrypt(value, pos, ...).
Launcher and Remote Notes
- For SSL services, prefer
iopen(..., ssl=True)and addsni=hostwhen the endpoint expects SNI. KeepIsSSL=Trueonly for compatibility with older boards. - Prefer direct connection setup like
io = iopen(...)in the exploit path; do not add a newstart()wrapper to fresh scripts. - If
iopenis not flexible enough for that target, fall back toremote(host, port, ssl=True, sni=host)with the smallest possible wrapper layer. - If you must keep an older
init(..., target=..., IsBomb=False)board layout,ssl=Truealso works on that legacy path. Prefer the splitinit(...)plusiopen(...)shape for fresh scripts. - For local runs that need a loader such as
./ld-linux-x86-64.so.2, useprocess([...])and then bind wrappers manually, including a realshellhelper. - For shell upload challenges, prefer this flow:
prepare_shell(io, expect=..., timeout=..., disable_echo=...)upload(...),execute(...),execute_and_wait(...), orupload_and_run(...)depending on how the target behaves after exec
- Prefer this decision order:
- If the binary returns cleanly to the same shell,
execute_and_wait(...)is a good fit. - If the exploit only needs fire-and-forget execution and then custom parsing, use
upload(...)plusexecute(...)and read manually. - If upload and immediate exec are enough and no special post-processing is needed, use
upload_and_run(...).
- If the binary returns cleanly to the same shell,
prepare_shell(...)can take either a prompt token or a callableexpectfunction. Use the callable form for odd shells that need custom prompt synchronization.- For terminals that emit cursor-position queries such as
\x1b[6n, preferterminal_reply=make_terminal_reply()or a custom reply map before writing target-specific recv hacks. - Keep shell upload logic separate from the memory-corruption primitive so iteration stays easy.
- If a remote shell needs special decoders, custom probes, or setup commands, use the uploader module knobs first before writing a one-off uploader.
- Prefer direct decoder commands such as
base64 -d,gzip -d -c, oropenssl base64 -d -Awhen you override uploader behavior. Do not switch tobusybox ...decoder wrappers unless the user explicitly asks for that environment.
Output Expectations
- Produce a complete exploit, not a half-template.
- Stay close to the user's current naming and board layout.
- Prefer concise target-shaped helpers over framework-like abstraction.
- When the user asks to "humanize" an exploit, preserve the exploit path but remove the obviously over-engineered structure.
- When the exploit depends on uploading a local helper, prefer the shared uploader helpers unless the target proves they are insufficient.