SlideShare a Scribd company logo
An Intro to
Binary Exploitation
Aswin M Guptha
@aswinmguptha
$whoami
●
BTech 2nd
year Undergraduate
●
Amrita University
●
Regular CTF Player
●
Team bi0s
●
Focus on Binary Exploitation, Web Exploitation
Aim
●
Give you a better understanding of mechanism of software
exploitation
●
Prepare you to identify the vulnerabilities in program
source codes
●
Help you understand HOW and WHY of exploit mitigation
technologies
●
We will cover a few key concepts deeply
Course Outline
●
Basic Stack overflows
●
Shell code injection
●
Other vulnerability scenarios
●
Recognizing vulnerability
●
Exploit mitigation technologies
Why?
●
Found by the late 90s
●
Still relevent?
●
2016 scenario
●
Your weakness, my strength
Lets get down to business
What is our Goal?
●
Arbitrary code execution
●
Example
●
Forcing binary to give root access over the internet!
●
Forcing a administrator privileged process to execute
normally
First Attempt,
But this worked in movies...
Real life
●
We don’t know the password, and really hard to guess it
too.
●
There is a function which gives shell.
●
What if we could change the flow of execution and execute
that function ?
means what???
Process Memory Organization
Content of an assembly file
● Executable section: TEXT
– The actual code that will
be executed
● Initialized data: DATA
– Global variables
● Uninitialized data: BSS
● Local variables
x86 Review
●
Function call
●
Returning after a function call
●
Instruction pointer
●
Stack
The Stack
The Stack
The Stack
…....
10. push j
11. push i
12. call add
13. add esp, 0x8
……
20. add:
21. mov eax, [esp+0x4]
22. mov ebx, [esp+0x8]
23. add eax, ebx
24. ret
Memory
0XDEADBEEF
Buffer Overflow
Buffer Overflow
#include<stdio.h>
int main(){
char buffer[16];
int var;
}
buffer var sfp ret
Bottomofmemory
Topofstack
Bottomofstack
Topofmemory
16 4 4 4
Buffer Overflow
Lets do some challenges
●
#1 overwrite
●
#2 validate
Buffer Overflow
void function(char *str){
char buffer[16];
strcpy(buffer, str);
}
int main(){
char large_string[256];
int i;
for (i = 0; i < 255; i++){
large_string[i] = ‘A’;
}
function(large_string);
}
Buffer Overflow
AAAAAAAAAAAAAAAA AAAA
AAAA
AAAA
AAAA
AAAAAAAAAAAA
Buffer sfp ret *str
416 4 4
● The return address is overwritten with ‘AAAA’ (0x41414141)
● Thus the function exits and goes to execute the instruction
at 0x41414141
● This results in a SegFault.
So what???
Bottomofmemory
Topofstack
Bottomofstack
Topofmemory
Buffer Overflow
●
We have seen how to crash our own program by
overwriting the return address of a function.
●
What if we could overwrite the return address with valid
address ?
Lets start walking from where we stopped!!!
Buffer Overflow
●
Is anyone mad enough to put a function which give
shell so easily ?
●
So what is the use of this ?
●
There come the shellcode injection
Shellcode
Shellcode
●
List of crafted instructions
●
Executed once the code is injected to a running
application.
Shellcode
Properties of a shell code?
– Should be small enough to fit in the buffer
– Shouldn’t contain any null charecters
– Shouldn’t refer to data section
Shellcode
Whats next?
– Okay, we know what is a shell code, now what?
●
Put a shell code into buffer
●
Fill the rest of buffer with junk
●
Overwrite saved eip to point to buffer
Shellcode
Ready, Set, Go
The battle continues...
●
RET2LIBC
●
ROP
●
Format String Vuln.
●
Heap Vuln.
And so...
Whats next?
●
Google is your best friend!
●
Smashing The Stack For Fun And Profit
– By Aleph One
●
And YES, CTFs!
In a nutshell
●
Changing flow of execution
– Buffer overflow
●
Injecting your vuln code
– Shellcode Injection
●
Vuln detection and prevention
Rest I leave to you,
Good luck! Queries?
Ping @aswinmguptha
Becoming Stronger!
●
NX
– Segments are either executable or writeable, but NOT
both
●
ASLR
– Address Space Layout Randomization
●
Canary, PIE
– Stack protectors

More Related Content

PDF
java.io - streams and files
PDF
Play with FILE Structure - Yet Another Binary Exploit Technique
PDF
Practical Malware Analysis: Ch 8: Debugging
PPTX
Caputre the flag
 
PDF
Super Easy Memory Forensics
 
PPTX
Nmap and metasploitable
ODP
GCC, GNU compiler collection
PPTX
Windows Kernel Exploitation : This Time Font hunt you down in 4 bytes
java.io - streams and files
Play with FILE Structure - Yet Another Binary Exploit Technique
Practical Malware Analysis: Ch 8: Debugging
Caputre the flag
 
Super Easy Memory Forensics
 
Nmap and metasploitable
GCC, GNU compiler collection
Windows Kernel Exploitation : This Time Font hunt you down in 4 bytes

What's hot (20)

PPT
Ch11: File System Interface
PPT
Digital design lect 26 27
PPTX
AES Encryption
PPTX
Introduction of CTF and CGC
PPT
Composition in OOP
PPT
Reliable Windows Heap Exploits
PDF
Spotify: P2P music streaming
PPT
Interrupts.ppt
PPTX
graphics programming in java
DOCX
Password Cracking
PPTX
PHP slides
PDF
Introduction to php
PDF
Binary exploitation - AIS3
PPTX
Java media framework
PPTX
Polymorphism presentation in java
PDF
Golang workshop
PPTX
Metasploit framwork
PDF
Grokking Techtalk #39: Gossip protocol and applications
PPTX
Here Be Dragons: The Unexplored Land of Active Directory ACLs
PPTX
How Functions Work
Ch11: File System Interface
Digital design lect 26 27
AES Encryption
Introduction of CTF and CGC
Composition in OOP
Reliable Windows Heap Exploits
Spotify: P2P music streaming
Interrupts.ppt
graphics programming in java
Password Cracking
PHP slides
Introduction to php
Binary exploitation - AIS3
Java media framework
Polymorphism presentation in java
Golang workshop
Metasploit framwork
Grokking Techtalk #39: Gossip protocol and applications
Here Be Dragons: The Unexplored Land of Active Directory ACLs
How Functions Work
Ad

Viewers also liked (20)

PDF
ATM Malware: Understanding the threat
DOCX
Amenaza a las bases de datos
PPTX
API Management - Practical Enterprise Implementation Experience
PDF
IM World presentation from Chris Swan: Application centric – how the cloud ha...
PDF
Streaming architecture with HDP & ELK
PPTX
Hunting powerpoint
PPTX
MyHeritage backend group - build to scale
PDF
Advanced Microservices - Greach 2015
PPTX
#speakgeek - Open Source Software Infrastructure at iconnect360
PDF
Evolution of OPNFV CI System: What already exists and what can be introduced
PPTX
Reversing malware analysis training part3 windows pefile formatbasics
PPT
Introduction to smpc
PDF
Business selectors
PPTX
Persistence in the cloud with bosh
PPTX
You know, for search
PDF
Neuigkeiten von DEPAROM & Co
PPTX
Item analysis
PPTX
Risk management
PPTX
Expect the unexpected: Anticipate and prepare for failures in microservices b...
PPTX
Security For Humans
ATM Malware: Understanding the threat
Amenaza a las bases de datos
API Management - Practical Enterprise Implementation Experience
IM World presentation from Chris Swan: Application centric – how the cloud ha...
Streaming architecture with HDP & ELK
Hunting powerpoint
MyHeritage backend group - build to scale
Advanced Microservices - Greach 2015
#speakgeek - Open Source Software Infrastructure at iconnect360
Evolution of OPNFV CI System: What already exists and what can be introduced
Reversing malware analysis training part3 windows pefile formatbasics
Introduction to smpc
Business selectors
Persistence in the cloud with bosh
You know, for search
Neuigkeiten von DEPAROM & Co
Item analysis
Risk management
Expect the unexpected: Anticipate and prepare for failures in microservices b...
Security For Humans
Ad

Similar to Introduction to Binary Exploitation (20)

PDF
Exploitation Crash Course
PDF
Advanced Arm Exploitation
PDF
Low Level Exploits
PPTX
antoanthongtin_Lesson 3- Software Security (1).pptx
PDF
Ceh v5 module 20 buffer overflow
PPTX
Software to the slaughter
PPTX
Buffer overflow attacks
PDF
Unix executable buffer overflow
PDF
Buffer overflow tutorial
PPT
Buffer Overflows
PDF
Buffer overflow null
PPTX
fjfh mjgkj jkhglkjh jhlkh lhlkkhl kjhjkhjk
PPTX
test
PPTX
Tranning-2
PPTX
ETCSS: Into the Mind of a Hacker
PPTX
Control hijacking
PPTX
Buffer Overflow by SecArmour
PDF
Davide Berardi - Linux hardening and security measures against Memory corruption
PPTX
Stack-Based Buffer Overflows
PPTX
Buffer overflow explained
Exploitation Crash Course
Advanced Arm Exploitation
Low Level Exploits
antoanthongtin_Lesson 3- Software Security (1).pptx
Ceh v5 module 20 buffer overflow
Software to the slaughter
Buffer overflow attacks
Unix executable buffer overflow
Buffer overflow tutorial
Buffer Overflows
Buffer overflow null
fjfh mjgkj jkhglkjh jhlkh lhlkkhl kjhjkhjk
test
Tranning-2
ETCSS: Into the Mind of a Hacker
Control hijacking
Buffer Overflow by SecArmour
Davide Berardi - Linux hardening and security measures against Memory corruption
Stack-Based Buffer Overflows
Buffer overflow explained

More from Cysinfo Cyber Security Community (20)

PDF
Understanding Malware Persistence Techniques by Monnappa K A
PDF
Understanding & analyzing obfuscated malicious web scripts by Vikram Kharvi
PDF
Getting started with cybersecurity through CTFs by Shruti Dixit & Geethna TK
PPTX
Emerging Trends in Cybersecurity by Amar Prusty
PDF
A look into the sanitizer family (ASAN & UBSAN) by Akul Pillai
PDF
Closer look at PHP Unserialization by Ashwin Shenoi
PDF
Unicorn: The Ultimate CPU Emulator by Akshay Ajayan
PDF
The Art of Executing JavaScript by Akhil Mahendra
PDF
Reversing and Decrypting Malware Communications by Monnappa
PPTX
DeViL - Detect Virtual Machine in Linux by Sreelakshmi
PPTX
Analysis of android apk using adhrit by Abhishek J.M
PDF
Understanding evasive hollow process injection techniques monnappa k a
PPTX
Security challenges in d2d communication by ajithkumar vyasarao
PPTX
S2 e (selective symbolic execution) -shivkrishna a
PPTX
Dynamic binary analysis using angr siddharth muralee
PPTX
Bit flipping attack on aes cbc - ashutosh ahelleya
PDF
Security Analytics using ELK stack
PDF
Linux Malware Analysis
PPTX
XXE - XML External Entity Attack
PPT
Image (PNG) Forensic Analysis
Understanding Malware Persistence Techniques by Monnappa K A
Understanding & analyzing obfuscated malicious web scripts by Vikram Kharvi
Getting started with cybersecurity through CTFs by Shruti Dixit & Geethna TK
Emerging Trends in Cybersecurity by Amar Prusty
A look into the sanitizer family (ASAN & UBSAN) by Akul Pillai
Closer look at PHP Unserialization by Ashwin Shenoi
Unicorn: The Ultimate CPU Emulator by Akshay Ajayan
The Art of Executing JavaScript by Akhil Mahendra
Reversing and Decrypting Malware Communications by Monnappa
DeViL - Detect Virtual Machine in Linux by Sreelakshmi
Analysis of android apk using adhrit by Abhishek J.M
Understanding evasive hollow process injection techniques monnappa k a
Security challenges in d2d communication by ajithkumar vyasarao
S2 e (selective symbolic execution) -shivkrishna a
Dynamic binary analysis using angr siddharth muralee
Bit flipping attack on aes cbc - ashutosh ahelleya
Security Analytics using ELK stack
Linux Malware Analysis
XXE - XML External Entity Attack
Image (PNG) Forensic Analysis

Recently uploaded (20)

PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PPTX
ai tools demonstartion for schools and inter college
PDF
medical staffing services at VALiNTRY
PPT
Introduction Database Management System for Course Database
PDF
AI in Product Development-omnex systems
PPTX
What to Capture When It Breaks: 16 Artifacts That Reveal Root Causes
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PPTX
FLIGHT TICKET RESERVATION SYSTEM | FLIGHT BOOKING ENGINE API
PPTX
Materi-Enum-and-Record-Data-Type (1).pptx
PDF
System and Network Administraation Chapter 3
PDF
Multi-factor Authentication (MFA) requirement for Microsoft 365 Admin Center_...
PDF
Best Practices for Rolling Out Competency Management Software.pdf
PDF
Digital Strategies for Manufacturing Companies
PDF
The Role of Automation and AI in EHS Management for Data Centers.pdf
PPTX
Online Work Permit System for Fast Permit Processing
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PPTX
Introduction to Artificial Intelligence
PPTX
CHAPTER 12 - CYBER SECURITY AND FUTURE SKILLS (1) (1).pptx
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
How to Migrate SBCGlobal Email to Yahoo Easily
VVF-Customer-Presentation2025-Ver1.9.pptx
ai tools demonstartion for schools and inter college
medical staffing services at VALiNTRY
Introduction Database Management System for Course Database
AI in Product Development-omnex systems
What to Capture When It Breaks: 16 Artifacts That Reveal Root Causes
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
FLIGHT TICKET RESERVATION SYSTEM | FLIGHT BOOKING ENGINE API
Materi-Enum-and-Record-Data-Type (1).pptx
System and Network Administraation Chapter 3
Multi-factor Authentication (MFA) requirement for Microsoft 365 Admin Center_...
Best Practices for Rolling Out Competency Management Software.pdf
Digital Strategies for Manufacturing Companies
The Role of Automation and AI in EHS Management for Data Centers.pdf
Online Work Permit System for Fast Permit Processing
Upgrade and Innovation Strategies for SAP ERP Customers
Introduction to Artificial Intelligence
CHAPTER 12 - CYBER SECURITY AND FUTURE SKILLS (1) (1).pptx
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus

Introduction to Binary Exploitation