SlideShare a Scribd company logo
Anatomy of a Buffer
Overflow Attack
Rob Gillen
@argodev
Don’t Be Stupid
The following presentation describes
real attacks on real systems. Please
note that most of the attacks
described would be considered ILLEGAL
if attempted on machines that you do
not have explicit permission to test
and attack. I assume no responsibility
for any actions you perform based on
the content of this presentation or
subsequent conversations. Please
remember this basic guideline: With
knowledge comes responsibility.
Disclaimer
The content of this presentation
represents my personal views and
thoughts at the present time. This
content is not endorsed by, or
representative in any way of my
employer nor is it intended to be a
view into my work or a reflection on
the type of work that I or my group
performs. It is simply a hobby and
personal interest and should be
considered as such.
Credits
The vulnerability that we’ll be discussing
was initially discovered by C4SS!0 G0M3S
(louredo_@hotmail.com) and was published
on June 17, 2011.
http://www.exploit-db.com/exploits/17539/
James Fitts created a MetaSploit module
that I also reviewed while building this
module
http://www.exploit-db.com/exploits/17540/
Overview
• Scenario
– Machine 1: Kali Linux (BackTrack)
– Machine 2:
• Windows 7 Professional x64, SP1
• Freefloat FTP Server v1.0

• Tasks
– Discover a vulnerability exists
– Craft & test an exploit

• Goal: Obtain reverse shell
Attack Process
• Identify target of interest
• Identify software/versions being
used
• Setup local Instance
• Fuzz to identify vulnerability
• Design/Develop Exploit
• Test
• Package/Weaponize
Terminology
•
•
•
•
•
•
•

CPU Registers
Debugger
Buffer Overflows
Fuzzing
Shellcode
Encoding
Bind Shell/Reverse Shell
CPU Registers (8086)
•
•
•
•
•
•
•
•

EAX
EBX
ECX
EDX
ESI
EDI
EBP
ESP

–
–
–
–
–
–
–
–

Accumulator Register
Base Register
Counter Register
Data Register
Source Index
Destination Index
Base Pointer
Stack Pointer

Content from: http://www.swansontec.com/sregisters.html
CPU Registers (8086)
• EIP – program counter or commonly
“instruction pointer” – a processor
register that indicates where a
computer is in its program sequence.
• Holds the memory address of (“points
to”) the next instruction that would
be executed.
• Any thoughts on why this specific
register is particularly
interesting?
Content from: http://en.wikipedia.org/wiki/Instruction_pointer
Debugger
Buffer Overflow

Content from: http://en.wikipedia.org/wiki/Buffer_overflow
Fuzzing
• Identify points where application
or service accepts data
• Send varying lengths/types of data
until we crash the service and/or
overwrite key buffers.
• Increase buffer length until no
longer successful (identify upper
bounds of memory space available
for exploit)
Shellcode
• Small piece of code used as the
payload in the exploitation of a
software vulnerability
• Name comes from the purpose –
usually spawns a shell and
performs some action
• Often written in assembly code
• Types:
– “normal”, Staged, Egg-hunt, Omelette
Content from: http://en.wikipedia.org/wiki/Shellcode
Shellcode Example
[BITS 32]
mov ebx, 0x00424F52
push ebx
mov esi, esp
xor eax, eax
push eax
push esi
push esi
push eax
mov eax, 0x7E45058A
call eax
[BITS 32]
mov ebx, 0x00424F52 ; Loads a null-terminated string “ROB” to
ebx
push ebx
; pushes ebx to the stack
mov esi, esp
; saves null-terminated string “ROB” in esi
xor eax, eax
; Zero our eax (eax=0)
push eax
; Push the fourth parameter (uType) to the
stack (value 0)
push esi
; Push the third parameter (lpCaption) to
the stack (value ROB00)
push esi
; Push the second parameter (lpText) to the
stack (value ROB00)
push eax
; Push the first parameter (hWnd) to the
stack (value 0)
mov eax, 0x7E45058A ; Move the MessageBoxA address in to eax
call eax
; Call the MessageBoxA function with all
parameters supplied.
Shellcode Example
BB 52 4F 42 00 53 89 E6
31 C0 50 56 56 50 B8 8A
05 45 7E FF D0
Encoding
• There are often restrictions as to
what data can be sent via the
exploit (NULLs, etc.)
• Self-extracting (smaller
shellcode)
• Self-decrypting (avoid IDS
signatures)
• Tools such as msfencode offer many
options.
Encoded Shellcode
xbex13xafx49x81xdaxc7
xd9x74x24xf4x58x31xc9
xb1x06x83xe8xfcx31x70
x0fx03x70x1cx4dxbcx3a
x70xdex7dx3dx27x69x67
x0cx07x39x3ex39xd7x02
x34xc0x92x0cxb6x1b
Bind Shell/Reverse Shell
• Bind Shell
– Target exposes a shell on a given port
– Attacker connects to that port and
executes commands
– Remote Administration

• Reverse Shell
– Attacker listens for connections on a
given port
– Shell code on target connects to
attacker and sends a shell
– NAT-safe!
Bind Shell
Code executes on
target and exposes
a listener on a
specific port
(i.e. 4444)

Attacker connects
(Binds) to client
ip:4444

Attacker

Target

Target sends shell
to attacker
Reverse Shell
Code executes on
target and
connects to the
attacker ip:4444

Attacker exposes
a listener on a
specific port
(i.e. 4444)

Attacker

Target

Target sends shell
to attacker
Fuzzing Pseudo-Code
• Build array of increasing length
strings (“A”)
• Build array of valid commands
• For each command in arrayOfCommands
– For each string in arrayOfStrings
• Establish FTP connection
• Submit command + string

• Watch for application hang/crash
• Inspect register values/pointers
Demonstration

FUZZING THE SERVICE
Design The Exploit
• Iterate with various malicious
buffer sizes to see how much space
is available
• Locate where within the evil
buffer we actually overwrite EIP
• Locate where within the evil
buffer we can locate our shellcode
(pointed to by other register)
Design The Exploit
• Select / configure / encode
shellcode
• Integrate into exploit script (NOP
slide, breakpoints, etc)
• Identify reusable jump address to
consistently move to shellcode
• Test with breakpoints
• Test in “real world” scenario
Demonstration

DESIGNING THE EXPLOIT
Solutions?
•
•
•
•

This was an “easy” scenario
Bounds checking is critical!
Fuzz your own applications
Address Space Layout Randomization
(ASLR) makes life harder
• Operating System Support
– Data Execution Prevention
Questions/Contact

Rob Gillen
rob@gillenfamily.net
http://rob.gillenfamily.net
@argodev

More Related Content

PPTX
Hands On with Amazon Web Services (StirTrek)
PPTX
Scaling Document Clustering in the Cloud
PPTX
(Training) Malware - To the Realm of Malicious Code
PPTX
Finding the Sweet Spot: Counter Honeypot Operations (CHOps) by Jonathan Creek...
PPTX
Path of Cyber Security
PPTX
Web Security Workshop : A Jumpstart
PDF
Password Cracking using dictionary attacks
PPTX
Defending Against 1,000,000 Cyber Attacks by Michael Banks
Hands On with Amazon Web Services (StirTrek)
Scaling Document Clustering in the Cloud
(Training) Malware - To the Realm of Malicious Code
Finding the Sweet Spot: Counter Honeypot Operations (CHOps) by Jonathan Creek...
Path of Cyber Security
Web Security Workshop : A Jumpstart
Password Cracking using dictionary attacks
Defending Against 1,000,000 Cyber Attacks by Michael Banks

What's hot (8)

PPTX
Another Side of Hacking
PPTX
Billions & Billions of Logs
DOC
SEC 572 Inspiring Innovation / tutorialrank.com
PDF
La Quadrature Du Cercle - The APTs That Weren't
DOC
Sec 572 Effective Communication / snaptutorial.com
DOC
Sec 572 Education Specialist-snaptutorial.com
DOCX
SEC 572 Entire Course NEW
DOCX
Sec 572 Enhance teaching / snaptutorial.com
Another Side of Hacking
Billions & Billions of Logs
SEC 572 Inspiring Innovation / tutorialrank.com
La Quadrature Du Cercle - The APTs That Weren't
Sec 572 Effective Communication / snaptutorial.com
Sec 572 Education Specialist-snaptutorial.com
SEC 572 Entire Course NEW
Sec 572 Enhance teaching / snaptutorial.com

Similar to ETCSS: Into the Mind of a Hacker (20)

PPTX
Anatomy of a Buffer Overflow Attack
PDF
Dive into exploit development
PDF
Fuzzing: Finding Your Own Bugs and 0days! 1.0
PDF
stackconf 2021 | Fuzzing: Finding Your Own Bugs and 0days!
PDF
Fuzzing: Finding Your Own Bugs and 0days! at Arab Security Conference
PPT
Writing Metasploit Plugins
PPTX
Buffer Overflows Shesh Jun 3 09
PDF
Buffer Overflow Attacks
PDF
Buffer overflow Attacks
PPTX
Tranning-2
ODP
Introduction to Binary Exploitation
PPTX
Fuzzing | Null OWASP Mumbai | 2016 June
PDF
Unix executable buffer overflow
PPTX
Sending a for ahuh. win32 exploit development old school
PDF
From SEH Overwrite with Egg Hunter to Get a Shell_by_RodolphoConcurde
PDF
From SEH Overwrite with Egg Hunter to Get a Shell!
PDF
Buffer overflow tutorial
PDF
Penetration Testing for Easy RM to MP3 Converter Application and Post Exploit
PPTX
Vulnerability, exploit to metasploit
PPTX
Buffer overflow attacks
Anatomy of a Buffer Overflow Attack
Dive into exploit development
Fuzzing: Finding Your Own Bugs and 0days! 1.0
stackconf 2021 | Fuzzing: Finding Your Own Bugs and 0days!
Fuzzing: Finding Your Own Bugs and 0days! at Arab Security Conference
Writing Metasploit Plugins
Buffer Overflows Shesh Jun 3 09
Buffer Overflow Attacks
Buffer overflow Attacks
Tranning-2
Introduction to Binary Exploitation
Fuzzing | Null OWASP Mumbai | 2016 June
Unix executable buffer overflow
Sending a for ahuh. win32 exploit development old school
From SEH Overwrite with Egg Hunter to Get a Shell_by_RodolphoConcurde
From SEH Overwrite with Egg Hunter to Get a Shell!
Buffer overflow tutorial
Penetration Testing for Easy RM to MP3 Converter Application and Post Exploit
Vulnerability, exploit to metasploit
Buffer overflow attacks

More from Rob Gillen (20)

PDF
CodeStock14: Hiding in Plain Sight
PDF
What's in a password
PPTX
How well do you know your runtime
PPTX
Software defined radio and the hacker
PPTX
So whats in a password
PPTX
Hiding in plain sight
PPTX
DevLink - WiFu: You think your wireless is secure?
PPTX
You think your WiFi is safe?
PPTX
Intro to GPGPU with CUDA (DevLink)
PPTX
AWS vs. Azure
PPTX
A Comparison of AWS and Azure - Part2
PPTX
A Comparison of AWS and Azure - Part 1
PPTX
Intro to GPGPU Programming with Cuda
PPTX
Windows Azure: Lessons From The Field
PPTX
Amazon Web Services for the .NET Developer
PPT
05561 Xfer Research 02
PPT
05561 Xfer Research 01
PPT
05561 Xfer Consumer 01
PPT
Cloud Storage Upload Tests 02
PPTX
Cloud Storage Cross Test
CodeStock14: Hiding in Plain Sight
What's in a password
How well do you know your runtime
Software defined radio and the hacker
So whats in a password
Hiding in plain sight
DevLink - WiFu: You think your wireless is secure?
You think your WiFi is safe?
Intro to GPGPU with CUDA (DevLink)
AWS vs. Azure
A Comparison of AWS and Azure - Part2
A Comparison of AWS and Azure - Part 1
Intro to GPGPU Programming with Cuda
Windows Azure: Lessons From The Field
Amazon Web Services for the .NET Developer
05561 Xfer Research 02
05561 Xfer Research 01
05561 Xfer Consumer 01
Cloud Storage Upload Tests 02
Cloud Storage Cross Test

Recently uploaded (20)

PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
DOCX
The AUB Centre for AI in Media Proposal.docx
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Empathic Computing: Creating Shared Understanding
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
NewMind AI Monthly Chronicles - July 2025
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Review of recent advances in non-invasive hemoglobin estimation
Digital-Transformation-Roadmap-for-Companies.pptx
Unlocking AI with Model Context Protocol (MCP)
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
The AUB Centre for AI in Media Proposal.docx
Understanding_Digital_Forensics_Presentation.pptx
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Empathic Computing: Creating Shared Understanding
Reach Out and Touch Someone: Haptics and Empathic Computing
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
NewMind AI Monthly Chronicles - July 2025
Mobile App Security Testing_ A Comprehensive Guide.pdf
Encapsulation_ Review paper, used for researhc scholars
Advanced methodologies resolving dimensionality complications for autism neur...
Agricultural_Statistics_at_a_Glance_2022_0.pdf
20250228 LYD VKU AI Blended-Learning.pptx
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Review of recent advances in non-invasive hemoglobin estimation

ETCSS: Into the Mind of a Hacker

  • 1. Anatomy of a Buffer Overflow Attack Rob Gillen @argodev
  • 2. Don’t Be Stupid The following presentation describes real attacks on real systems. Please note that most of the attacks described would be considered ILLEGAL if attempted on machines that you do not have explicit permission to test and attack. I assume no responsibility for any actions you perform based on the content of this presentation or subsequent conversations. Please remember this basic guideline: With knowledge comes responsibility.
  • 3. Disclaimer The content of this presentation represents my personal views and thoughts at the present time. This content is not endorsed by, or representative in any way of my employer nor is it intended to be a view into my work or a reflection on the type of work that I or my group performs. It is simply a hobby and personal interest and should be considered as such.
  • 4. Credits The vulnerability that we’ll be discussing was initially discovered by C4SS!0 G0M3S (louredo_@hotmail.com) and was published on June 17, 2011. http://www.exploit-db.com/exploits/17539/ James Fitts created a MetaSploit module that I also reviewed while building this module http://www.exploit-db.com/exploits/17540/
  • 5. Overview • Scenario – Machine 1: Kali Linux (BackTrack) – Machine 2: • Windows 7 Professional x64, SP1 • Freefloat FTP Server v1.0 • Tasks – Discover a vulnerability exists – Craft & test an exploit • Goal: Obtain reverse shell
  • 6. Attack Process • Identify target of interest • Identify software/versions being used • Setup local Instance • Fuzz to identify vulnerability • Design/Develop Exploit • Test • Package/Weaponize
  • 8. CPU Registers (8086) • • • • • • • • EAX EBX ECX EDX ESI EDI EBP ESP – – – – – – – – Accumulator Register Base Register Counter Register Data Register Source Index Destination Index Base Pointer Stack Pointer Content from: http://www.swansontec.com/sregisters.html
  • 9. CPU Registers (8086) • EIP – program counter or commonly “instruction pointer” – a processor register that indicates where a computer is in its program sequence. • Holds the memory address of (“points to”) the next instruction that would be executed. • Any thoughts on why this specific register is particularly interesting? Content from: http://en.wikipedia.org/wiki/Instruction_pointer
  • 11. Buffer Overflow Content from: http://en.wikipedia.org/wiki/Buffer_overflow
  • 12. Fuzzing • Identify points where application or service accepts data • Send varying lengths/types of data until we crash the service and/or overwrite key buffers. • Increase buffer length until no longer successful (identify upper bounds of memory space available for exploit)
  • 13. Shellcode • Small piece of code used as the payload in the exploitation of a software vulnerability • Name comes from the purpose – usually spawns a shell and performs some action • Often written in assembly code • Types: – “normal”, Staged, Egg-hunt, Omelette Content from: http://en.wikipedia.org/wiki/Shellcode
  • 14. Shellcode Example [BITS 32] mov ebx, 0x00424F52 push ebx mov esi, esp xor eax, eax push eax push esi push esi push eax mov eax, 0x7E45058A call eax
  • 15. [BITS 32] mov ebx, 0x00424F52 ; Loads a null-terminated string “ROB” to ebx push ebx ; pushes ebx to the stack mov esi, esp ; saves null-terminated string “ROB” in esi xor eax, eax ; Zero our eax (eax=0) push eax ; Push the fourth parameter (uType) to the stack (value 0) push esi ; Push the third parameter (lpCaption) to the stack (value ROB00) push esi ; Push the second parameter (lpText) to the stack (value ROB00) push eax ; Push the first parameter (hWnd) to the stack (value 0) mov eax, 0x7E45058A ; Move the MessageBoxA address in to eax call eax ; Call the MessageBoxA function with all parameters supplied.
  • 16. Shellcode Example BB 52 4F 42 00 53 89 E6 31 C0 50 56 56 50 B8 8A 05 45 7E FF D0
  • 17. Encoding • There are often restrictions as to what data can be sent via the exploit (NULLs, etc.) • Self-extracting (smaller shellcode) • Self-decrypting (avoid IDS signatures) • Tools such as msfencode offer many options.
  • 19. Bind Shell/Reverse Shell • Bind Shell – Target exposes a shell on a given port – Attacker connects to that port and executes commands – Remote Administration • Reverse Shell – Attacker listens for connections on a given port – Shell code on target connects to attacker and sends a shell – NAT-safe!
  • 20. Bind Shell Code executes on target and exposes a listener on a specific port (i.e. 4444) Attacker connects (Binds) to client ip:4444 Attacker Target Target sends shell to attacker
  • 21. Reverse Shell Code executes on target and connects to the attacker ip:4444 Attacker exposes a listener on a specific port (i.e. 4444) Attacker Target Target sends shell to attacker
  • 22. Fuzzing Pseudo-Code • Build array of increasing length strings (“A”) • Build array of valid commands • For each command in arrayOfCommands – For each string in arrayOfStrings • Establish FTP connection • Submit command + string • Watch for application hang/crash • Inspect register values/pointers
  • 24. Design The Exploit • Iterate with various malicious buffer sizes to see how much space is available • Locate where within the evil buffer we actually overwrite EIP • Locate where within the evil buffer we can locate our shellcode (pointed to by other register)
  • 25. Design The Exploit • Select / configure / encode shellcode • Integrate into exploit script (NOP slide, breakpoints, etc) • Identify reusable jump address to consistently move to shellcode • Test with breakpoints • Test in “real world” scenario
  • 27. Solutions? • • • • This was an “easy” scenario Bounds checking is critical! Fuzz your own applications Address Space Layout Randomization (ASLR) makes life harder • Operating System Support – Data Execution Prevention