Symlink Path Shortening
- •
What it is
- •
Pre-create a short symlink name for a target file so size-constrained shellcode needs fewer bytes to build its path. This requires filesystem access before execution.
- •
- •
How it works
- •
Outside the shellcode entirely, from a shell:
ln -s /flag acreates a symlink namedain the working directory pointing at/flag. - •
openandchmodnormally follow symlinks. The target permissions and the process working directory still matter. - •
A one-character path plus a null terminator is shorter to construct than a longer filename.
- •
- •
- •
Examples
- •
Run
ln -s /flag a, then use the relative pathafrom that directory. It is shorter than/flag; normal target-file permissions still apply.
- •
- •
pwntools
- •
path = b'a\x00' print(len(path)) # Two bytes for the shortened path and terminator.
- •
- •
Debugging / shell checks
- •
ls -l a # Shell: confirm the symlink and current working directory.
- •
- •
- •
Cards
- •
Why does referencing a symlink's short name still affect the real target file?
- •
Syscalls like
chmod/openfollow symlinks by default — the short name is just an alias resolved to the real path by the kernel.
- •
- •
What's the practical requirement for this trick to apply?
- •
You need filesystem/shell access to pre-create the symlink before the constrained shellcode runs — it's an environment-prep trick, not something the shellcode itself does.
- •
- •