Blacksun Level 0
Blacksun Level 0 — exploit a remote format-string bug in a binary with ASLR, PIE and stack protection by using direct parameter access to study the stack.
Table of Contents
Source: This content is aggregated from overthewire (MIT). Visit the original repository for the latest version.
Level0 is a remote format string intended to get you started with blacksun. It is a remote format string bug with you being able to see the reply, with address space randomisation enabled. You’ll need to use the direct parameter access method to analyse the stack and to manipulate it.
Once getting access to a shell, read /etc/motd for more information
Binary information
| Stack smashing protection (SSP): | Enabled |
|---|---|
| Postition Independent Executable (PIE): | Enabled |
| Address space layout randomisation (ASLR): | Enabled |
| Non-executable pages: | None / disabled |
| Location: | Connect to blacksun.overthewire.org on port 79 |
Alternatively, there is a debug version on port 78 if you need help understanding what you’re seeing
Study guide
Level map: you attack a network service (port 79, with a debug version on port 78) to get a shell, then read /etc/motd for more information.
What this level teaches
How to exploit a format-string vulnerability remotely when the layout of memory is randomised.
Key ideas
- You can see the reply. That is what makes a leak possible: format specifiers print stack values back to you.
- Direct parameter access. The
%N$xsyntax reads the Nth argument directly, so you can scan the stack without writing hundreds of specifiers. - Defeating ASLR with a leak. If you can read a pointer from the stack, you can compute where other things are for that particular run.
- Protections table. The page lists SSP, PIE and ASLR as on, and non-executable pages as off, so injected shellcode on the stack is still allowed.
- Debug version. Port 78 serves a version that explains what you are seeing.
How to approach it
- Use the debug service to understand the stack layout, then repeat on the real one.
- Leak the values you need, compute addresses, and design the write.
- Script the exploit so you can rerun it against a fresh address space.
Why it matters
Info leaks plus a write primitive are the building blocks of nearly every modern exploit chain.