Skip to content

milutin2002/ExploitFormatStringVuln

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

ExploitFormatStringVuln

A hands-on demonstration of format string vulnerabilities in C — showing how improper use of printf and related functions can expose a program's memory and be leveraged for exploitation.


What is a Format String Vulnerability?

A format string vulnerability occurs when user-controlled input is passed directly as the format argument to functions like printf, fprintf, or sprintf — without a proper format specifier.

// Vulnerable
printf(user_input);

// Safe
printf("%s", user_input);

An attacker can supply format specifiers (e.g. %x, %s, %n) to read from or write to arbitrary memory locations on the stack.


Contents

Folder Description
ReadFormatVuln/ C source and shell scripts demonstrating how to read memory via format string attacks

Techniques Covered

  • Stack memory leaking — using %lx to dump stack values
  • Arbitrary memory reads — using %s to read from a target address
  • Direct parameter access — using %N$x to access specific stack positions

Requirements

  • Linux (x86 or x86-64)
  • GCC
  • Basic familiarity with C and the stack

Usage

# Compile the vulnerable program
gcc -o main main.c

# Run the exploit script
bash exploit.sh

⚠️ Disclaimer: This repository is for educational purposes only. Do not use these techniques against systems you do not own or have explicit permission to test.


About

Format string vulnerabilities

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors