SlideShare a Scribd company logo
SEH BASED BUFFER OVERFLOWS
Mohsen Ahmadi
My motto is : "Give a man an exploit and you make him a hacker for a day
; teach a man to exploit bugs and you make him a hacker for a lifetime."
DISCLAIMER
If you’re someone that wants to
build exploits to partake in illegal
or immoral activity, please go
elsewhere
ACKNOWLEDGMENTS
• Nothing worthwhile in my life could be achieved without two very
important people. A huge thank you to my beautiful fiancée, CMCM,
for her inexhaustible support and immeasurable inspiration
And also
• My Mama, Without her continually showing that every life challenge is best
confronted with a grin firmly planted from ear to ear, all obstacles would be
so much greater.
WHAT IS EXCEPTION HANDLER?
(CONT)
• An exception handler is a piece of code that is written inside an application,
with the purpose of dealing with the fact that the application throws an
exception
Try{
//if exception occurs go to exception handler
}
Catch{
//run some code when exception occurs
}
EXCEPTION HANDLER
__try {
// guarded body
...
}
__except (exception filter) {
// exception handler
...
}
SEH DS(CONT)
typedef struct _EXCEPTION_REGISTRATION_RECORD {
struct _EXCEPTION_REGISTRATION_RECORD *Next;
PEXCEPTION_ROUTINE Handler;
} EXCEPTION_REGISTRATION_RECORD, *PEXCEPTION_REGISTRATION_RECORD;
EXCEPTION_DISPOSITION
__cdecl _except_handler(
struct _EXCEPTION_RECORD *ExceptionRecord,
oid EstablisherFrame,
struct _CONTEXT *ContextRecord,
void * DispatcherContext
);
SEH DS
typedef struct _EXCEPTION_RECORD {
DWORD ExceptionCode;
DWORD ExceptionFlags;
struct _EXCEPTION_RECORD *ExceptionRecord;
PVOID ExceptionAddress;
DWORD NumberParameters;
ULONG_PTR ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS];
} EXCEPTION_RECORD, *PEXCEPTION_RECORD;
DEPTH ANALYSIS
• When an exception occurs, the OS starts at the top of the chain and checks
the first _EXCEPTION_REGISTRATION_RECORD Handler function to see if it can
handle the given error (based on the information passed in the
ExceptionRecord and ContextRecord parameters)
• If return value _except_handler equals ExceptionContinueSearch then it will
move to the next _EXCEPTION_REGISTRATION_RECORD using the address
pointed to by *Next
• If return value _except_handler equals ExceptionContinueExecution then it
will handle the exception successfully
DEFAULT EXCEPTION HANDLER WINDOWS
• Windows places a default/generic exception
handler at the end of the chain to help
ensure the exception will be handled
in some manner (represented by FFFFFFFF)
at which point you’ll likely see the
“…has encountered a problem and needs to close”
message.
SEH based buffer overflow vulnerability exploitation
STACK VIEW OF SEH
• “Address of exception handler” is just one part of a SEH record
• If Windows catches an exception, you’ll see a “xxx has
encountered a problem and needs to close” popup
• To write stable software, one should try to use development
language specific exception handlers, and only rely on the
windows default SEH as a last resort
• UnhandledExceptionFilter ~ Send Error Report to MS
FRAME BASED SHE(CONT)
• Each function/procedure gets a stack frame
• If an exception handler is implement in this function/procedure, the
exception handler gets its own stack frame
• Information about the frame-based exception handler is stored in an
exception_registration structure on the stack
• SEH record is 8 bytes and has 2 (4 byte) elements
• Next SEH record
• SE Handler
• See SEH components…
SEH COMPONENTS
FS:[0]
• At the top of main structure, TEB or TIB there’s a pointer to top of SEH chain
which points to the first EXCEPTION_REGISTRATION_RECORD which often calls
FS:[0] chain
MOV DWORD PTR FS:[0]
• This ensures that the exception handler is set up for the thread and will be
able to catch errors when they occur
• The opcode for this instruction is 64A100000000. If you cannot find this
opcode in TEB/TIB, the application/thread may not have exception handling
at all, but remember there’s always windows default exception handler
SEE EXCEPTION REGISTRATION BLOCK
• I wanna use OllyGraph plugin for OllyDBG to create a Function Flowchart
• See an example in windbg
ANY QUESTION?!
THANK YOU 
Ad

Recommended

Dive into exploit development
Dive into exploit development
Payampardaz
 
Basic buffer overflow part1
Basic buffer overflow part1
Payampardaz
 
Reversing malware analysis training part4 assembly programming basics
Reversing malware analysis training part4 assembly programming basics
Cysinfo Cyber Security Community
 
Exploit techniques and mitigation
Exploit techniques and mitigation
Yaniv Shani
 
Writing simple buffer_overflow_exploits
Writing simple buffer_overflow_exploits
D4rk357 a
 
CNIT 127 Ch 4: Introduction to format string bugs
CNIT 127 Ch 4: Introduction to format string bugs
Sam Bowne
 
Tranning-2
Tranning-2
Ali Hussain
 
OTP application (with gen server child) - simple example
OTP application (with gen server child) - simple example
YangJerng Hwa
 
Reverse engineering - Shellcodes techniques
Reverse engineering - Shellcodes techniques
Eran Goldstein
 
Buffer overflow attacks
Buffer overflow attacks
Japneet Singh
 
Anatomy of a Buffer Overflow Attack
Anatomy of a Buffer Overflow Attack
Rob Gillen
 
CNIT 127: 4: Format string bugs
CNIT 127: 4: Format string bugs
Sam Bowne
 
Concurrency in Elixir with OTP
Concurrency in Elixir with OTP
Justin Reese
 
Task parallel library presentation
Task parallel library presentation
ahmed sayed
 
CNIT 126 13: Data Encoding
CNIT 126 13: Data Encoding
Sam Bowne
 
Seh based attack
Seh based attack
Mihir Shah
 
Source Boston 2009 - Anti-Debugging A Developers Viewpoint
Source Boston 2009 - Anti-Debugging A Developers Viewpoint
Tyler Shields
 
Gift-VT Tools Development Overview
Gift-VT Tools Development Overview
stn_tkiller
 
Elixir and OTP
Elixir and OTP
Pedro Medeiros
 
Using OTP and gen_server Effectively
Using OTP and gen_server Effectively
Ken Pratt
 
Python Basics
Python Basics
primeteacher32
 
Smash the Stack: Writing a Buffer Overflow Exploit (Win32)
Smash the Stack: Writing a Buffer Overflow Exploit (Win32)
Elvin Gentiles
 
Structured Exception Handler Exploitation
Structured Exception Handler Exploitation
High-Tech Bridge SA (HTBridge)
 
Planet of the AOPs
Planet of the AOPs
James Ward
 
Analytics tools and Instruments
Analytics tools and Instruments
Krunal Soni
 
Concurrency, Robustness & Elixir SoCraTes 2015
Concurrency, Robustness & Elixir SoCraTes 2015
steffenbauer
 
CNIT 127: Ch 18: Source Code Auditing
CNIT 127: Ch 18: Source Code Auditing
Sam Bowne
 
Advanced malware analysis training session5 reversing automation
Advanced malware analysis training session5 reversing automation
Cysinfo Cyber Security Community
 
CNIT 127: Ch 8: Windows overflows (Part 1)
CNIT 127: Ch 8: Windows overflows (Part 1)
Sam Bowne
 
CNIT 127 Ch 8: Windows overflows (Part 1)
CNIT 127 Ch 8: Windows overflows (Part 1)
Sam Bowne
 

More Related Content

What's hot (20)

Reverse engineering - Shellcodes techniques
Reverse engineering - Shellcodes techniques
Eran Goldstein
 
Buffer overflow attacks
Buffer overflow attacks
Japneet Singh
 
Anatomy of a Buffer Overflow Attack
Anatomy of a Buffer Overflow Attack
Rob Gillen
 
CNIT 127: 4: Format string bugs
CNIT 127: 4: Format string bugs
Sam Bowne
 
Concurrency in Elixir with OTP
Concurrency in Elixir with OTP
Justin Reese
 
Task parallel library presentation
Task parallel library presentation
ahmed sayed
 
CNIT 126 13: Data Encoding
CNIT 126 13: Data Encoding
Sam Bowne
 
Seh based attack
Seh based attack
Mihir Shah
 
Source Boston 2009 - Anti-Debugging A Developers Viewpoint
Source Boston 2009 - Anti-Debugging A Developers Viewpoint
Tyler Shields
 
Gift-VT Tools Development Overview
Gift-VT Tools Development Overview
stn_tkiller
 
Elixir and OTP
Elixir and OTP
Pedro Medeiros
 
Using OTP and gen_server Effectively
Using OTP and gen_server Effectively
Ken Pratt
 
Python Basics
Python Basics
primeteacher32
 
Smash the Stack: Writing a Buffer Overflow Exploit (Win32)
Smash the Stack: Writing a Buffer Overflow Exploit (Win32)
Elvin Gentiles
 
Structured Exception Handler Exploitation
Structured Exception Handler Exploitation
High-Tech Bridge SA (HTBridge)
 
Planet of the AOPs
Planet of the AOPs
James Ward
 
Analytics tools and Instruments
Analytics tools and Instruments
Krunal Soni
 
Concurrency, Robustness & Elixir SoCraTes 2015
Concurrency, Robustness & Elixir SoCraTes 2015
steffenbauer
 
CNIT 127: Ch 18: Source Code Auditing
CNIT 127: Ch 18: Source Code Auditing
Sam Bowne
 
Advanced malware analysis training session5 reversing automation
Advanced malware analysis training session5 reversing automation
Cysinfo Cyber Security Community
 
Reverse engineering - Shellcodes techniques
Reverse engineering - Shellcodes techniques
Eran Goldstein
 
Buffer overflow attacks
Buffer overflow attacks
Japneet Singh
 
Anatomy of a Buffer Overflow Attack
Anatomy of a Buffer Overflow Attack
Rob Gillen
 
CNIT 127: 4: Format string bugs
CNIT 127: 4: Format string bugs
Sam Bowne
 
Concurrency in Elixir with OTP
Concurrency in Elixir with OTP
Justin Reese
 
Task parallel library presentation
Task parallel library presentation
ahmed sayed
 
CNIT 126 13: Data Encoding
CNIT 126 13: Data Encoding
Sam Bowne
 
Seh based attack
Seh based attack
Mihir Shah
 
Source Boston 2009 - Anti-Debugging A Developers Viewpoint
Source Boston 2009 - Anti-Debugging A Developers Viewpoint
Tyler Shields
 
Gift-VT Tools Development Overview
Gift-VT Tools Development Overview
stn_tkiller
 
Using OTP and gen_server Effectively
Using OTP and gen_server Effectively
Ken Pratt
 
Smash the Stack: Writing a Buffer Overflow Exploit (Win32)
Smash the Stack: Writing a Buffer Overflow Exploit (Win32)
Elvin Gentiles
 
Planet of the AOPs
Planet of the AOPs
James Ward
 
Analytics tools and Instruments
Analytics tools and Instruments
Krunal Soni
 
Concurrency, Robustness & Elixir SoCraTes 2015
Concurrency, Robustness & Elixir SoCraTes 2015
steffenbauer
 
CNIT 127: Ch 18: Source Code Auditing
CNIT 127: Ch 18: Source Code Auditing
Sam Bowne
 
Advanced malware analysis training session5 reversing automation
Advanced malware analysis training session5 reversing automation
Cysinfo Cyber Security Community
 

Similar to SEH based buffer overflow vulnerability exploitation (20)

CNIT 127: Ch 8: Windows overflows (Part 1)
CNIT 127: Ch 8: Windows overflows (Part 1)
Sam Bowne
 
CNIT 127 Ch 8: Windows overflows (Part 1)
CNIT 127 Ch 8: Windows overflows (Part 1)
Sam Bowne
 
Post-mortem Debugging of Windows Applications
Post-mortem Debugging of Windows Applications
GlobalLogic Ukraine
 
Abusing SEH For Fun
Abusing SEH For Fun
Digital Echidna
 
Exploit Development: EzServer Buffer Overflow oleh Tom Gregory
Exploit Development: EzServer Buffer Overflow oleh Tom Gregory
zakiakhmad
 
Exploit Development with Python
Exploit Development with Python
Thomas Gregory
 
Seh based exploitation
Seh based exploitation
Raghunath G
 
SEH overwrite and its exploitability
SEH overwrite and its exploitability
FFRI, Inc.
 
Low Level Exploits
Low Level Exploits
hughpearse
 
eh
eh
Morten M. Christensen
 
Unmasking the Dark Art of Vectored Exception Handling: Bypassing XDR and EDR ...
Unmasking the Dark Art of Vectored Exception Handling: Bypassing XDR and EDR ...
Donato Onofri
 
exploiting heap overflows
exploiting heap overflows
primelude
 
Riding the Overflow - Then and Now
Riding the Overflow - Then and Now
Miroslav Stampar
 
Exception handling
Exception handling
Abhishek Pachisia
 
Exception handling in c programming
Exception handling in c programming
Raza Najam
 
Heap overflows for humans – 101
Heap overflows for humans – 101
Craft Symbol
 
CyberLink LabelPrint 2.5 Exploitation Process
CyberLink LabelPrint 2.5 Exploitation Process
Thomas Gregory
 
Exploring the x64
Exploring the x64
FFRI, Inc.
 
CNIT 127: 8: Windows overflows (Part 2)
CNIT 127: 8: Windows overflows (Part 2)
Sam Bowne
 
CNIT 127: Ch 8: Windows overflows (Part 2)
CNIT 127: Ch 8: Windows overflows (Part 2)
Sam Bowne
 
CNIT 127: Ch 8: Windows overflows (Part 1)
CNIT 127: Ch 8: Windows overflows (Part 1)
Sam Bowne
 
CNIT 127 Ch 8: Windows overflows (Part 1)
CNIT 127 Ch 8: Windows overflows (Part 1)
Sam Bowne
 
Post-mortem Debugging of Windows Applications
Post-mortem Debugging of Windows Applications
GlobalLogic Ukraine
 
Exploit Development: EzServer Buffer Overflow oleh Tom Gregory
Exploit Development: EzServer Buffer Overflow oleh Tom Gregory
zakiakhmad
 
Exploit Development with Python
Exploit Development with Python
Thomas Gregory
 
Seh based exploitation
Seh based exploitation
Raghunath G
 
SEH overwrite and its exploitability
SEH overwrite and its exploitability
FFRI, Inc.
 
Low Level Exploits
Low Level Exploits
hughpearse
 
Unmasking the Dark Art of Vectored Exception Handling: Bypassing XDR and EDR ...
Unmasking the Dark Art of Vectored Exception Handling: Bypassing XDR and EDR ...
Donato Onofri
 
exploiting heap overflows
exploiting heap overflows
primelude
 
Riding the Overflow - Then and Now
Riding the Overflow - Then and Now
Miroslav Stampar
 
Exception handling in c programming
Exception handling in c programming
Raza Najam
 
Heap overflows for humans – 101
Heap overflows for humans – 101
Craft Symbol
 
CyberLink LabelPrint 2.5 Exploitation Process
CyberLink LabelPrint 2.5 Exploitation Process
Thomas Gregory
 
Exploring the x64
Exploring the x64
FFRI, Inc.
 
CNIT 127: 8: Windows overflows (Part 2)
CNIT 127: 8: Windows overflows (Part 2)
Sam Bowne
 
CNIT 127: Ch 8: Windows overflows (Part 2)
CNIT 127: Ch 8: Windows overflows (Part 2)
Sam Bowne
 
Ad

Recently uploaded (20)

Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik
 
War_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdf
War_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdf
biswajitbanerjee38
 
ENERGY CONSUMPTION CALCULATION IN ENERGY-EFFICIENT AIR CONDITIONER.pdf
ENERGY CONSUMPTION CALCULATION IN ENERGY-EFFICIENT AIR CONDITIONER.pdf
Muhammad Rizwan Akram
 
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
Safe Software
 
ReSTIR [DI]: Spatiotemporal reservoir resampling for real-time ray tracing ...
ReSTIR [DI]: Spatiotemporal reservoir resampling for real-time ray tracing ...
revolcs10
 
OpenPOWER Foundation & Open-Source Core Innovations
OpenPOWER Foundation & Open-Source Core Innovations
IBM
 
OWASP Barcelona 2025 Threat Model Library
OWASP Barcelona 2025 Threat Model Library
PetraVukmirovic
 
Python Conference Singapore - 19 Jun 2025
Python Conference Singapore - 19 Jun 2025
ninefyi
 
FME for Distribution & Transmission Integrity Management Program (DIMP & TIMP)
FME for Distribution & Transmission Integrity Management Program (DIMP & TIMP)
Safe Software
 
9-1-1 Addressing: End-to-End Automation Using FME
9-1-1 Addressing: End-to-End Automation Using FME
Safe Software
 
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC
 
MuleSoft for AgentForce : Topic Center and API Catalog
MuleSoft for AgentForce : Topic Center and API Catalog
shyamraj55
 
You are not excused! How to avoid security blind spots on the way to production
You are not excused! How to avoid security blind spots on the way to production
Michele Leroux Bustamante
 
“From Enterprise to Makers: Driving Vision AI Innovation at the Extreme Edge,...
“From Enterprise to Makers: Driving Vision AI Innovation at the Extreme Edge,...
Edge AI and Vision Alliance
 
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Alliance
 
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Alliance
 
The Future of Data, AI, and AR: Innovation Inspired by You.pdf
The Future of Data, AI, and AR: Innovation Inspired by You.pdf
Safe Software
 
Enabling BIM / GIS integrations with Other Systems with FME
Enabling BIM / GIS integrations with Other Systems with FME
Safe Software
 
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
caoyixuan2019
 
“Key Requirements to Successfully Implement Generative AI in Edge Devices—Opt...
“Key Requirements to Successfully Implement Generative AI in Edge Devices—Opt...
Edge AI and Vision Alliance
 
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik
 
War_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdf
War_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdf
biswajitbanerjee38
 
ENERGY CONSUMPTION CALCULATION IN ENERGY-EFFICIENT AIR CONDITIONER.pdf
ENERGY CONSUMPTION CALCULATION IN ENERGY-EFFICIENT AIR CONDITIONER.pdf
Muhammad Rizwan Akram
 
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
Safe Software
 
ReSTIR [DI]: Spatiotemporal reservoir resampling for real-time ray tracing ...
ReSTIR [DI]: Spatiotemporal reservoir resampling for real-time ray tracing ...
revolcs10
 
OpenPOWER Foundation & Open-Source Core Innovations
OpenPOWER Foundation & Open-Source Core Innovations
IBM
 
OWASP Barcelona 2025 Threat Model Library
OWASP Barcelona 2025 Threat Model Library
PetraVukmirovic
 
Python Conference Singapore - 19 Jun 2025
Python Conference Singapore - 19 Jun 2025
ninefyi
 
FME for Distribution & Transmission Integrity Management Program (DIMP & TIMP)
FME for Distribution & Transmission Integrity Management Program (DIMP & TIMP)
Safe Software
 
9-1-1 Addressing: End-to-End Automation Using FME
9-1-1 Addressing: End-to-End Automation Using FME
Safe Software
 
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC
 
MuleSoft for AgentForce : Topic Center and API Catalog
MuleSoft for AgentForce : Topic Center and API Catalog
shyamraj55
 
You are not excused! How to avoid security blind spots on the way to production
You are not excused! How to avoid security blind spots on the way to production
Michele Leroux Bustamante
 
“From Enterprise to Makers: Driving Vision AI Innovation at the Extreme Edge,...
“From Enterprise to Makers: Driving Vision AI Innovation at the Extreme Edge,...
Edge AI and Vision Alliance
 
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Alliance
 
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Seminar: Perspectives on Passkeys & Consumer Adoption.pptx
FIDO Alliance
 
The Future of Data, AI, and AR: Innovation Inspired by You.pdf
The Future of Data, AI, and AR: Innovation Inspired by You.pdf
Safe Software
 
Enabling BIM / GIS integrations with Other Systems with FME
Enabling BIM / GIS integrations with Other Systems with FME
Safe Software
 
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
Tech-ASan: Two-stage check for Address Sanitizer - Yixuan Cao.pdf
caoyixuan2019
 
“Key Requirements to Successfully Implement Generative AI in Edge Devices—Opt...
“Key Requirements to Successfully Implement Generative AI in Edge Devices—Opt...
Edge AI and Vision Alliance
 
Ad

SEH based buffer overflow vulnerability exploitation

  • 1. SEH BASED BUFFER OVERFLOWS Mohsen Ahmadi My motto is : "Give a man an exploit and you make him a hacker for a day ; teach a man to exploit bugs and you make him a hacker for a lifetime."
  • 2. DISCLAIMER If you’re someone that wants to build exploits to partake in illegal or immoral activity, please go elsewhere
  • 3. ACKNOWLEDGMENTS • Nothing worthwhile in my life could be achieved without two very important people. A huge thank you to my beautiful fiancée, CMCM, for her inexhaustible support and immeasurable inspiration And also • My Mama, Without her continually showing that every life challenge is best confronted with a grin firmly planted from ear to ear, all obstacles would be so much greater.
  • 4. WHAT IS EXCEPTION HANDLER? (CONT) • An exception handler is a piece of code that is written inside an application, with the purpose of dealing with the fact that the application throws an exception Try{ //if exception occurs go to exception handler } Catch{ //run some code when exception occurs }
  • 5. EXCEPTION HANDLER __try { // guarded body ... } __except (exception filter) { // exception handler ... }
  • 6. SEH DS(CONT) typedef struct _EXCEPTION_REGISTRATION_RECORD { struct _EXCEPTION_REGISTRATION_RECORD *Next; PEXCEPTION_ROUTINE Handler; } EXCEPTION_REGISTRATION_RECORD, *PEXCEPTION_REGISTRATION_RECORD; EXCEPTION_DISPOSITION __cdecl _except_handler( struct _EXCEPTION_RECORD *ExceptionRecord, oid EstablisherFrame, struct _CONTEXT *ContextRecord, void * DispatcherContext );
  • 7. SEH DS typedef struct _EXCEPTION_RECORD { DWORD ExceptionCode; DWORD ExceptionFlags; struct _EXCEPTION_RECORD *ExceptionRecord; PVOID ExceptionAddress; DWORD NumberParameters; ULONG_PTR ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS]; } EXCEPTION_RECORD, *PEXCEPTION_RECORD;
  • 8. DEPTH ANALYSIS • When an exception occurs, the OS starts at the top of the chain and checks the first _EXCEPTION_REGISTRATION_RECORD Handler function to see if it can handle the given error (based on the information passed in the ExceptionRecord and ContextRecord parameters) • If return value _except_handler equals ExceptionContinueSearch then it will move to the next _EXCEPTION_REGISTRATION_RECORD using the address pointed to by *Next • If return value _except_handler equals ExceptionContinueExecution then it will handle the exception successfully
  • 9. DEFAULT EXCEPTION HANDLER WINDOWS • Windows places a default/generic exception handler at the end of the chain to help ensure the exception will be handled in some manner (represented by FFFFFFFF) at which point you’ll likely see the “…has encountered a problem and needs to close” message.
  • 11. STACK VIEW OF SEH • “Address of exception handler” is just one part of a SEH record • If Windows catches an exception, you’ll see a “xxx has encountered a problem and needs to close” popup • To write stable software, one should try to use development language specific exception handlers, and only rely on the windows default SEH as a last resort • UnhandledExceptionFilter ~ Send Error Report to MS
  • 12. FRAME BASED SHE(CONT) • Each function/procedure gets a stack frame • If an exception handler is implement in this function/procedure, the exception handler gets its own stack frame • Information about the frame-based exception handler is stored in an exception_registration structure on the stack • SEH record is 8 bytes and has 2 (4 byte) elements • Next SEH record • SE Handler • See SEH components…
  • 14. FS:[0] • At the top of main structure, TEB or TIB there’s a pointer to top of SEH chain which points to the first EXCEPTION_REGISTRATION_RECORD which often calls FS:[0] chain MOV DWORD PTR FS:[0] • This ensures that the exception handler is set up for the thread and will be able to catch errors when they occur • The opcode for this instruction is 64A100000000. If you cannot find this opcode in TEB/TIB, the application/thread may not have exception handling at all, but remember there’s always windows default exception handler
  • 15. SEE EXCEPTION REGISTRATION BLOCK • I wanna use OllyGraph plugin for OllyDBG to create a Function Flowchart • See an example in windbg