Skip to content

Latest commit

Β 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ”₯ PWN Binary Analyzer

A comprehensive binary analysis tool designed for CTF pwn challenges. This tool provides detailed information about ELF binaries including architecture, security mitigations, disassembly, GOT/PLT entries, ROP gadgets, memory layouts, and heap structures.

⚑ NEW: AI-Powered Exploit Generation!

Now includes an intelligent AI assistant that:

  • πŸ€– Automatically detects vulnerabilities
  • πŸ’‘ Suggests optimal exploit strategies
  • πŸ“ Generates working exploit templates
  • πŸŽ“ Provides step-by-step guidance

Try it now:

python pwn_analyzer.py binary --ai

See AI_GUIDE.md for complete AI features documentation.


✨ Features

  • πŸ“‹ Basic Information: Architecture, bits, endianness, stripped status, entry point
  • πŸ›‘οΈ Security Mitigations: RELRO, Stack Canary, NX, PIE, RUNPATH
  • πŸ“‘ Section Analysis: All section headers with addresses, sizes, and flags
  • πŸ“Š GOT/PLT Analysis: Global Offset Table and Procedure Linkage Table entries
  • πŸ”€ Symbol Table: All symbols with addresses and types
  • πŸ“œ Disassembly: Beautiful disassembly with symbol resolution (shows function names!)
  • πŸ”— ROP Gadgets: Enhanced gadget finder (3-5x more gadgets)
  • πŸ—ΊοΈ Memory Layout: Visual representation of memory segments
  • πŸ“š Stack Frame Layout: Binary-specific stack analysis with real offset calculations
  • πŸ—οΈ Heap Layout: Tcache header structure and heap exploitation techniques
  • πŸ€– AI Assistant: Automatic exploit generation and guidance

πŸš€ Installation

Prerequisites

Make sure you have Python 3.7+ installed.

Install Dependencies

pip install -r requirements.txt

Or install manually:

pip install pwntools capstone pyelftools rich

πŸ“– Usage

Full Analysis (Default)

Run complete analysis on a binary:

python pwn_analyzer.py ./binary_file

Specific Analysis Options

Basic Information Only:

python pwn_analyzer.py ./binary_file -b

Security Mitigations Only:

python pwn_analyzer.py ./binary_file -s

Show GOT/PLT Entries:

python pwn_analyzer.py ./binary_file --got

Disassemble N Instructions:

python pwn_analyzer.py ./binary_file -d 100

Find N ROP Gadgets:

python pwn_analyzer.py ./binary_file -g 50

Show Stack Frame Layout:

python pwn_analyzer.py ./binary_file --stack

Show Heap/Tcache Layout:

python pwn_analyzer.py ./binary_file --heap

Show All Sections:

python pwn_analyzer.py ./binary_file --sections

Combine Multiple Options:

python pwn_analyzer.py ./binary_file -s -g 30 -d 50

πŸ“Š Output Examples

Basic Information

πŸ“‹ Basic Information
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Property           β”‚ Value                   β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ File               β”‚ challenge               β”‚
β”‚ Architecture       β”‚ x86-64 (64-bit)         β”‚
β”‚ Bits               β”‚ 64                      β”‚
β”‚ Endianness         β”‚ little                  β”‚
β”‚ Stripped           β”‚ ❌ Yes (Stripped)       β”‚
β”‚ Entry Point        β”‚ 0x401040                β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Security Mitigations

πŸ›‘οΈ  Security Mitigations
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Protection         β”‚ Status           β”‚ Description                 β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ RELRO              β”‚ ⚠️  Partial      β”‚ GOT is writable            β”‚
β”‚ Stack Canary       β”‚ ❌ Disabled      β”‚ Vulnerable to overflow     β”‚
β”‚ NX (DEP)           β”‚ βœ… Enabled       β”‚ Stack is not executable    β”‚
β”‚ PIE                β”‚ ❌ Disabled      β”‚ Fixed addresses            β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Memory Layout

The tool provides visual tree representation of memory segments and sections.

Stack Frame Layout

Shows detailed stack frame structure with:

  • Command line arguments location
  • Stack growth direction
  • Saved base pointer
  • Return address (pwn target!)
  • Local variables
  • Buffer locations
  • Stack canary position

Heap/Tcache Layout

Displays:

  • Tcache perthread structure
  • Tcache entry format
  • Heap chunk structure
  • Common exploitation techniques

🎯 Use Cases

1. Quick Binary Overview

python pwn_analyzer.py ./challenge -b -s

Get a quick look at what you're dealing with - architecture and security features.

2. Finding ROP Gadgets

python pwn_analyzer.py ./challenge -g 100

Find useful ROP gadgets for your exploit.

3. Understanding Memory Layout

python pwn_analyzer.py ./challenge --stack --heap

Understand stack and heap structures for exploitation.

4. GOT Overwrite Planning

python pwn_analyzer.py ./challenge --got

See which functions are in GOT for overwrite attacks.

5. Full Reconnaissance

python pwn_analyzer.py ./challenge

Complete analysis before starting exploitation.

πŸ”§ Advanced Tips

Working with Stripped Binaries

The tool handles stripped binaries gracefully and shows available information.

Architecture Support

Currently optimized for x86 and x86-64. Other architectures have basic support.

Custom Analysis

You can extend the BinaryAnalyzer class to add custom analysis features.

πŸ“š Understanding the Output

RELRO (Relocation Read-Only)

  • Full RELRO: GOT is read-only, harder to exploit
  • Partial RELRO: GOT is writable, vulnerable to GOT overwrite
  • No RELRO: No protection

Stack Canary

  • Enabled: Stack buffer overflow protection active
  • Disabled: Vulnerable to classic buffer overflow

NX (No Execute) / DEP

  • Enabled: Stack is not executable, need ROP/ret2libc
  • Disabled: Can execute shellcode on stack

PIE (Position Independent Executable)

  • Enabled: ASLR applies to executable, need information leak
  • Disabled: Fixed addresses, easier exploitation

πŸ› Troubleshooting

"No module named 'pwn'"

pip install pwntools

"No module named 'capstone'"

pip install capstone

"Permission denied"

Make sure the script is executable:

chmod +x pwn_analyzer.py

🀝 Contributing

Feel free to extend this tool with additional features:

  • More architecture support
  • Advanced gadget classification
  • Automatic exploit template generation
  • Integration with debugging tools
  • String/reference finding

πŸ“„ License

Free to use for CTF and educational purposes.

πŸŽ“ Learning Resources

πŸ’‘ Example Workflow

# 1. First, analyze the binary
python pwn_analyzer.py ./challenge

# 2. Check for easy wins (no canary, no PIE, executable stack)
python pwn_analyzer.py ./challenge -s

# 3. Find ROP gadgets if needed
python pwn_analyzer.py ./challenge -g 100

# 4. Check GOT for overwrite targets
python pwn_analyzer.py ./challenge --got

# 5. Start exploitation with pwntools!

Happy Pwning! πŸ”₯

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages