SlideShare a Scribd company logo
1 of 21
BUFFER OVERFLOW
Mihir Shah
20th Apr 2019
ABOUT TODAY
x32 Arch Basic
- Basics of Buffer Overflow
- Basics of Immunity Debugger
- Vanilla Buffer Overflow
X32 ARCH BASIC(ASSEMBLY BASIC)
System Organization Basics
CPU
Execution UnitControl Unit
Registers
Flags
Control Unit : Retrieve/Decode instructions, Retrieve/Store data in memory
Execution Unit : Actual execution of instruction happens here
Registers : Internal memory locations used as “variables”
Flags : Used to indicate various “event” when execution is happening
CPU REGISTERS
EAX EBX ECX EDX ESI EDI ESP EBP
General Purpose Registers
CS DS SS ES FS GS
Segment Registers
EIP
Instruction Pointer Register
CR0 CR1 CR2 CR3 CR4
Control Registers
EAX Accumulator Register – used for storing operands and result
data
EBX Base Register – Pointer to data
ECX Counter Register – Loop Operations
EDX Data Register – I/O Pointer
ESI EDI Data Pointer Registers for memory operations
ESP Stack Pointer Register
EBP Stack Data Pointer Register
EAX
31 0
AX
31 16 15 0
AH AL
15 8 7 0
EAX
EBX
31 0
BX
31 16 15 0
BH BL
15 8 7 0
EBX
ECX
31 0
CX
31 16 15 0
CH CL
15 8 7 0
ECX
EDX
31 0
DX
31 16 15 0
DH DL
15 8 7 0
EDX
 Four 32-bit data registers are used for arithmetic, logical, and other operations.
 These 32-bit registers can be used in three ways −
a) As complete 32-bit data registers: EAX, EBX, ECX, EDX
b) Lower halves of the 32-bit registers can be used as four 16-bit data registers: AX, BX, CX and DX
c) Lower and higher halves of the above-mentioned four 16-bit registers can be used as eight 8-bit data
registers: AH, AL, BH, BL, CH, CL, DH, and DL
 Some of these data registers have specific use in arithmetical operations.
AX is the primary accumulator; it is used in input/output and most arithmetic instructions. For example, in
multiplication operation, one operand is stored in EAX or AX or AL register according to the size of the
operand.
BX is known as the base register, as it could be used in indexed addressing.
CX is known as the count register, as the ECX, CX registers store the loop count in iterative operations.
DX is known as the data register. It is also used in input/output operations. It is also used with AX register
along with DX for multiply and divide operations involving large values.
BASIC OF BUFFER OVERFLOW
BUFFER
 Small memory allocated for a specific input
System memory
Buffer
void main()
{
char source[ ] = “HELLO”; // HELLO assigned to source
char destination[2]; // destination is 3 bytes
strcpy(destination, source); // copy source to destination
return 0;
}
Buffer (3 bytes) Overflow
H E L L O
0 1 2 3 4
STACK
ESP (Extended Stack Pointer
(top))
Buffer Space
EBP (Extended Base Pointer
(base))
Return Address
Parent Routine’s Stack
StackGrowth
MemoryAddresses
STACK IS LIFO (LAST IN FIRST OUT)
0xAAAAAAAA
0x10203040
High Memory
Low Memory
ESP
ESP – Should point to top of Stack
STACK IS LIFO (LAST IN FIRST OUT)
0xAAAAAAAA
0x10203040
0xA0203040
High Memory
Low Memory
ESP
ESP – Should point to top of
Stack
Push – Pushes a value onto the
Stack
STACK IS LIFO (LAST IN FIRST OUT)
0xAAAAAAAA
0x10203040
High Memory
Low Memory
ESP
ESP – Should point to top of
Stack
Push – Pushes a value onto the
Stack
Pop – Removes the topmost value
from the Stack
Buffer overflow

More Related Content

Similar to Buffer overflow

computer organization and assembly Regitster.ppt
computer organization and assembly Regitster.pptcomputer organization and assembly Regitster.ppt
computer organization and assembly Regitster.ppt
ssuser7b3003
 
Unit 3 assembler and processor
Unit 3   assembler and processorUnit 3   assembler and processor
Unit 3 assembler and processor
Abha Damani
 
8086 microprocessor-architecture-120207111857-phpapp01
8086 microprocessor-architecture-120207111857-phpapp018086 microprocessor-architecture-120207111857-phpapp01
8086 microprocessor-architecture-120207111857-phpapp01
destaw belay
 
8086 microprocessor-architecture-120207111857-phpapp01
8086 microprocessor-architecture-120207111857-phpapp018086 microprocessor-architecture-120207111857-phpapp01
8086 microprocessor-architecture-120207111857-phpapp01
Siva Raman
 

Similar to Buffer overflow (20)

Computer Organization and 8085 microprocessor notes
Computer Organization and 8085 microprocessor notesComputer Organization and 8085 microprocessor notes
Computer Organization and 8085 microprocessor notes
 
computer organization and assembly Regitster.ppt
computer organization and assembly Regitster.pptcomputer organization and assembly Regitster.ppt
computer organization and assembly Regitster.ppt
 
Unit 3 assembler and processor
Unit 3   assembler and processorUnit 3   assembler and processor
Unit 3 assembler and processor
 
intel 8086 introduction
intel 8086 introductionintel 8086 introduction
intel 8086 introduction
 
other-architectures.ppt
other-architectures.pptother-architectures.ppt
other-architectures.ppt
 
register and iits type explain here
register and iits type explain hereregister and iits type explain here
register and iits type explain here
 
It322 intro 1
It322 intro 1It322 intro 1
It322 intro 1
 
8086
8086 8086
8086
 
Registers
RegistersRegisters
Registers
 
INTEL 8086 MP Architecture
INTEL 8086 MP ArchitectureINTEL 8086 MP Architecture
INTEL 8086 MP Architecture
 
8086 Register organization and Architecture details
8086 Register organization and Architecture details8086 Register organization and Architecture details
8086 Register organization and Architecture details
 
Introduction of 8086 micro processor .
Introduction of 8086 micro processor .Introduction of 8086 micro processor .
Introduction of 8086 micro processor .
 
8086 Architecture by Er. Swapnil Kaware
8086 Architecture by Er. Swapnil Kaware8086 Architecture by Er. Swapnil Kaware
8086 Architecture by Er. Swapnil Kaware
 
8086 architecture By Er. Swapnil Kaware
8086 architecture By Er. Swapnil Kaware8086 architecture By Er. Swapnil Kaware
8086 architecture By Er. Swapnil Kaware
 
Register & Memory
Register & MemoryRegister & Memory
Register & Memory
 
8086 microprocessor-architecture-120207111857-phpapp01
8086 microprocessor-architecture-120207111857-phpapp018086 microprocessor-architecture-120207111857-phpapp01
8086 microprocessor-architecture-120207111857-phpapp01
 
8086 microprocessor-architecture-120207111857-phpapp01
8086 microprocessor-architecture-120207111857-phpapp018086 microprocessor-architecture-120207111857-phpapp01
8086 microprocessor-architecture-120207111857-phpapp01
 
Microprocessor Architecture.pptx
Microprocessor Architecture.pptxMicroprocessor Architecture.pptx
Microprocessor Architecture.pptx
 
Advanced micro -processor
Advanced micro -processorAdvanced micro -processor
Advanced micro -processor
 
MPMC Microprocessor
MPMC MicroprocessorMPMC Microprocessor
MPMC Microprocessor
 

More from Mihir Shah

More from Mihir Shah (13)

Windows custom shellcoding
Windows custom shellcodingWindows custom shellcoding
Windows custom shellcoding
 
Seh based attack
Seh based attackSeh based attack
Seh based attack
 
Kubernetes
KubernetesKubernetes
Kubernetes
 
Post exploitation using powershell
Post exploitation using powershellPost exploitation using powershell
Post exploitation using powershell
 
Securing docker containers
Securing docker containersSecuring docker containers
Securing docker containers
 
Cracking the crypto
Cracking the cryptoCracking the crypto
Cracking the crypto
 
Stego.ppt
Stego.pptStego.ppt
Stego.ppt
 
Wi fi pentesting
Wi fi pentestingWi fi pentesting
Wi fi pentesting
 
Reversing with gdb
Reversing with gdbReversing with gdb
Reversing with gdb
 
ROP
ROPROP
ROP
 
Return Oriented Programming - ROP
Return Oriented Programming - ROPReturn Oriented Programming - ROP
Return Oriented Programming - ROP
 
PMKID ATTACK!!
PMKID ATTACK!!PMKID ATTACK!!
PMKID ATTACK!!
 
OAuth 2.0
OAuth 2.0OAuth 2.0
OAuth 2.0
 

Recently uploaded

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Recently uploaded (20)

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 

Buffer overflow

  • 2. ABOUT TODAY x32 Arch Basic - Basics of Buffer Overflow - Basics of Immunity Debugger - Vanilla Buffer Overflow
  • 5. CPU Execution UnitControl Unit Registers Flags Control Unit : Retrieve/Decode instructions, Retrieve/Store data in memory Execution Unit : Actual execution of instruction happens here Registers : Internal memory locations used as “variables” Flags : Used to indicate various “event” when execution is happening
  • 6. CPU REGISTERS EAX EBX ECX EDX ESI EDI ESP EBP General Purpose Registers CS DS SS ES FS GS Segment Registers EIP Instruction Pointer Register CR0 CR1 CR2 CR3 CR4 Control Registers
  • 7. EAX Accumulator Register – used for storing operands and result data EBX Base Register – Pointer to data ECX Counter Register – Loop Operations EDX Data Register – I/O Pointer ESI EDI Data Pointer Registers for memory operations ESP Stack Pointer Register EBP Stack Data Pointer Register
  • 8. EAX 31 0 AX 31 16 15 0 AH AL 15 8 7 0 EAX
  • 9. EBX 31 0 BX 31 16 15 0 BH BL 15 8 7 0 EBX
  • 10. ECX 31 0 CX 31 16 15 0 CH CL 15 8 7 0 ECX
  • 11. EDX 31 0 DX 31 16 15 0 DH DL 15 8 7 0 EDX
  • 12.  Four 32-bit data registers are used for arithmetic, logical, and other operations.  These 32-bit registers can be used in three ways − a) As complete 32-bit data registers: EAX, EBX, ECX, EDX b) Lower halves of the 32-bit registers can be used as four 16-bit data registers: AX, BX, CX and DX c) Lower and higher halves of the above-mentioned four 16-bit registers can be used as eight 8-bit data registers: AH, AL, BH, BL, CH, CL, DH, and DL  Some of these data registers have specific use in arithmetical operations. AX is the primary accumulator; it is used in input/output and most arithmetic instructions. For example, in multiplication operation, one operand is stored in EAX or AX or AL register according to the size of the operand. BX is known as the base register, as it could be used in indexed addressing. CX is known as the count register, as the ECX, CX registers store the loop count in iterative operations. DX is known as the data register. It is also used in input/output operations. It is also used with AX register along with DX for multiply and divide operations involving large values.
  • 13. BASIC OF BUFFER OVERFLOW
  • 14. BUFFER  Small memory allocated for a specific input System memory Buffer
  • 15. void main() { char source[ ] = “HELLO”; // HELLO assigned to source char destination[2]; // destination is 3 bytes strcpy(destination, source); // copy source to destination return 0; } Buffer (3 bytes) Overflow H E L L O 0 1 2 3 4
  • 16. STACK
  • 17. ESP (Extended Stack Pointer (top)) Buffer Space EBP (Extended Base Pointer (base)) Return Address Parent Routine’s Stack StackGrowth MemoryAddresses
  • 18. STACK IS LIFO (LAST IN FIRST OUT) 0xAAAAAAAA 0x10203040 High Memory Low Memory ESP ESP – Should point to top of Stack
  • 19. STACK IS LIFO (LAST IN FIRST OUT) 0xAAAAAAAA 0x10203040 0xA0203040 High Memory Low Memory ESP ESP – Should point to top of Stack Push – Pushes a value onto the Stack
  • 20. STACK IS LIFO (LAST IN FIRST OUT) 0xAAAAAAAA 0x10203040 High Memory Low Memory ESP ESP – Should point to top of Stack Push – Pushes a value onto the Stack Pop – Removes the topmost value from the Stack