CSE 598 - Spring 2025

Format String Exploits

Exploiting format string vulnerabilities is like a locksmith using a special set of tools to subtly manipulate the inner workings of a lock. It involves delicately inserting custom-crafted sequences into a program's output functions, much like a skilled safecracker tuning into the faint clicks of a safe's mechanism. Each carefully chosen character or specifier in the format string acts like a precise tweak to the internal gears, potentially revealing hidden information or granting control over the system's memory. This technique is a blend of art and science, requiring a deep understanding of the software's architecture and a creative approach to bending its functionalities beyond their intended limits. It's a thrilling intellectual puzzle, unlocking the secrets of a program from the inside out.

24 challenges

Format String Exploits: Introduction

Format String Exploits: Leaking Data

Format String Exploits: Writing Data

Autogenerated tips and tricks from the discord channel

This material was generated by ChatGPT-4 from a transcript of the Discord help channel for this module.

  • When dealing with format string challenges, it's important to understand the difference between %n, %hn, and %hhn. Each one has its purpose, and depending on the size of the data you want to write, one might be more suitable than the others.
  • In some cases, you might need to overwrite only a single byte of a return address to achieve the desired result. Be creative and look for opportunities to use this technique.
  • Consider using the $ specifier to write to pointers on the stack if the challenge allows it. This can be helpful for modifying the return address in some situations.
  • Pwntools is a powerful library for dealing with format strings, but it might not always work perfectly for every scenario. If you encounter issues with it, consider simplifying your approach and building up the solution manually. Pwntools has useful functions like fmtstr_payload() and leak_stack(), which can be helpful in building your payload.
  • When attempting to solve more difficult format string challenges, it's crucial to understand how stack addresses work and how they can change during runtime. In some cases, overwriting a whole address might not be an option due to a lack of leaks.
  • For some challenges, the intended solution might involve using tricks or techniques that are not strictly related to format string payloads. Be open to exploring new ideas and approaches to find the solution.
  • It's possible that there are multiple ways to solve a challenge, especially when it comes to ROP (Return-Oriented Programming). Don't be afraid to discuss and compare solutions with others to learn new techniques.
  • When dealing with more complex challenges, remember that theory and practice might differ. Keep testing and refining your ideas until you find a working solution.
  • Finally, don't hesitate to ask for help and collaborate with others. Sharing knowledge and discussing solutions can lead to a deeper understanding of the subject and help you become more proficient in solving cybersecurity challenges.
CHALLENGE 01

Level1.0

— solves

Use a format string exploit to reveal a string stored on the stack

CHALLENGE 02

Level1.1

— solves

Use a formatstring exploit to reveal a string stored on the stack

CHALLENGE 03

Level2.0

— solves

Use a format string exploit to reveal a string stored on the stack

CHALLENGE 04

Level2.1

— solves

Use a format string exploit to reveal a string stored on the stack

CHALLENGE 05

Level3.0

— solves

Use a format string exploit to read the flag directly from the .bss section

CHALLENGE 06

Level3.1

— solves

Use a format string exploit to read the flag directly from the .bss section

CHALLENGE 07

Level4.0

— solves

Use a format string exploit to set a global variable

CHALLENGE 08

Level4.1

— solves

Use a format string exploit to set a global variable

CHALLENGE 09

Level5.0

— solves

Use a format string exploit to set a larger global variable

CHALLENGE 10

Level5.1

— solves

Use a format string exploit to set a larger global variable

CHALLENGE 11

Level6.0

— solves

Use a format string exploit to copy a value and overwrite a global variable

CHALLENGE 12

Level6.1

— solves

Use a format string exploit to copy a value and overwrite a global variable

CHALLENGE 13

Level7.0

— solves

Use a format string exploit to overwrite a got entry

CHALLENGE 14

Level7.1

— solves

Use a format string exploit to overwrite a got entry

CHALLENGE 15

Level8.0

— solves

Use a format string exploit to call win

CHALLENGE 16

Level8.1

— solves

Use a format string exploit to call win

CHALLENGE 17

Level9.0

— solves

Use a format string exploit to call win. this time, with no loop.

CHALLENGE 18

Level9.1

— solves

Use a format string exploit to call win. this time, with no loop.

CHALLENGE 19

Level10.0

— solves

Chain a format string exploit into rop

CHALLENGE 20

Level10.1

— solves

Chain a format string exploit into rop

CHALLENGE 21

Level11.0

— solves

Chain a format string exploit into rop, now with pie!

CHALLENGE 22

Level11.1

— solves

Chain a format string exploit into rop, now with pie!

CHALLENGE 23

Level12.0

— solves

Chain a format string exploit into ROP, now with pie and input filtering!

CHALLENGE 24

Level12.1

— solves

Chain a format string exploit into ROP, now with pie and input filtering!