SlideShare a Scribd company logo
Nibin Varghese iViZ Security, Kolkata Reverse Engineering for Exploit Writers
Agenda Exploitation Overview Reverse Engineering Tools Case Study MS08-067
Exploitation   Overview Software vulnerabilities exist Reliable exploitation techniques exist Stack overflow Heap overflow Exploit mitigation Prevent or impede a class of vulnerabilities Patch the vulnerability Disable the service Generic mitigations
Reverse Engineering Tools IDA Pro Bindiff Plugin for IDA Ollydbg or Immunity Debugger or Windbg Debugging Symbols Sysinternals tool suite Any scripting language to write PoC (Python, Ruby etc)
MS08-067 Windows Server Service Vulnerability Out of band release Details: Error in netapi32.dll when processing directory traversal character sequence in path names. This can be exploited to corrupt stack memory by example sending RPC requests containing specially crafted path names to the Server service component – secunia.com
 
Structure of X86 stack frame Stack grows towards lower addresses Local Variables Saved EBP Saved IP Arguments
Classical Overflow Return address overwritten with address of shellcode Local Variables Saved EBP Saved IP Arguments
Reverse engineering the patch Demo
The Bug Decompiled by Alexander Sotirov Visual demo of the bug
The Bug(contd..) ptr_path \\computername\\..\\..\\AAAAAAAAAAAAAAAAAAAAAAAAA ptr_previous_slash ptr_current_slash ptr_path points to the beginning of the buffer Parses to find current slash and previous slash‘\\’ Finds “..”, so the current slash pointer moves forward Data from Current slash pointer is copied to ptr_path If the pointer is at the beginning of the buffer, a pointer moves backward to find previous slash“\\”. 5a. Results in access violation if no “\\” are found 5b. Copies to the new destination if  “\\” is found \\..\\AAAAAAAAAAAAAAAAAAAAAAAAA Lower Address Higher Address
path Return Address of vulnerable_function Saved EBP Netapi32!NetpwPathCanonicalize vulnerable_function( wchar *path ) wcscpy(dst,src) Return Address of wcscpy Saved EBP ptr_path points to the beginning of the buffer Parses to find current slash and previous slash‘\\’ Finds “..”, so the current slash pointer moves forward Data from Current slash pointer is copied to ptr_path If the pointer is at the beginning of the buffer, a pointer moves backward to find previous slash“\\”. 5a. Results in access violation if no “\\” are found 5b. Copies to the new destination if  “\\” is found \\..\\AAAAAA \\..\\AAAAAAAAAAA (ptr1 – 1) ptr2 ptr1 ptr_path \\c\\..\\.. \\AAAAAAAAAAA AAAA AAAA AAAA Shell Code
The Bug (contd..) Not a classical buffer overflow The destination buffer is large enough to copy the contents from source The hunt for “\\” if the pointer points to the beginning of the buffer makes it a BUG
Ready for PoC Identify the vector of exploitation 3 possible ways wcslen of path Predictable location of  “\\”  in the stack after repeated interaction Metasploit way of calculating the device_length
Mass Exploitation If no NX, return to stack and execute shellcode If NX enabled, disable DEP/NX by abusing Win32 API NtSetInformationProcess and return to stack and execute shellcode. Refer Skape and Skywing paper on Uninformed Journal “Bypassing Windows Hardware-enforced Data Execution Prevention” In Vista, ASLR makes return addresses unpredictable.
Thank You Thanks to Research Team@iViZ Security  Thanks to Clubhack 08 organizers Thanks to all the attendees
Ready for Phase 2 ?

More Related Content

PPT
2008 11 13 Hcls Call
PDF
OpenCon2014 - Sumatra as an Open Science tool
PDF
Return oriented programming
PDF
EKAW - Triple Pattern Fragments
PPT
Indic threads pune12-apache-crunch
PDF
YAPC::Europe 2008 - Mike Astle - Profiling
PPTX
0.5mln packets per second with Erlang
ODP
Php Site Optimization
2008 11 13 Hcls Call
OpenCon2014 - Sumatra as an Open Science tool
Return oriented programming
EKAW - Triple Pattern Fragments
Indic threads pune12-apache-crunch
YAPC::Europe 2008 - Mike Astle - Profiling
0.5mln packets per second with Erlang
Php Site Optimization

Viewers also liked (20)

PPTX
Socialising Media: How To Activate Social
PPS
Her yere TÜRKİYE yazın
PPTX
Презентация
PPS
öDüllü düsündüren karikatürler
PPS
Kizilderili kitabesi
PPT
3d. power point otto dix
PPS
Brunei sultanlığı
PDF
Certificate_Rahimi
PPT
практикум по выполнению блока с (с1)
PPS
Su koprusu
PDF
Nuovi mercati danno la spinta all'export
PPS
Nel photos superbes
PPT
1. ququrama
PDF
23ประชาคมอาเซียนมีผลอย่างไรต่อชีวิตของเรา
PPT
Бизнес-вселенная (b8u.ru)
PPT
Florais araretama e_acupuntura_estetica
PPTX
Bantuan perniagaan KHB
PPTX
tabaco y alcohol en la enfermedad periodontal
PPTX
How to understand and challenge your property taxes in Michigan
PDF
Case study dipecho v upca
Socialising Media: How To Activate Social
Her yere TÜRKİYE yazın
Презентация
öDüllü düsündüren karikatürler
Kizilderili kitabesi
3d. power point otto dix
Brunei sultanlığı
Certificate_Rahimi
практикум по выполнению блока с (с1)
Su koprusu
Nuovi mercati danno la spinta all'export
Nel photos superbes
1. ququrama
23ประชาคมอาเซียนมีผลอย่างไรต่อชีวิตของเรา
Бизнес-вселенная (b8u.ru)
Florais araretama e_acupuntura_estetica
Bantuan perniagaan KHB
tabaco y alcohol en la enfermedad periodontal
How to understand and challenge your property taxes in Michigan
Case study dipecho v upca

Similar to Nibin - Reverse Engineering for exploit writers - ClubHack2008 (20)

PPTX
Reversing malware analysis training part10 exploit development basics
PDF
Writing simple buffer_overflow_exploits
PDF
Penetration Testing for Easy RM to MP3 Converter Application and Post Exploit
PPTX
Buffer overflow attacks
PDF
Software Security
PDF
Esage on non-existent 0-days, stable binary exploits and user interaction
PDF
2011-03 Developing Windows Exploits
PDF
Advanced Windows Exploitation
PPTX
On non existent 0-days, stable binary exploits and
PPTX
ETCSS: Into the Mind of a Hacker
PDF
Advanced Arm Exploitation
PPTX
Vulnerability, exploit to metasploit
PPTX
Anatomy of a Buffer Overflow Attack
PDF
Fuzzing: Finding Your Own Bugs and 0days! at Arab Security Conference
PPTX
Buffer overflow – Smashing The Stack
PPTX
fjfh mjgkj jkhglkjh jhlkh lhlkkhl kjhjkhjk
PPT
Exploiting stack overflow 101
PDF
Buffer Overflow Attacks
PDF
Buffer overflow Attacks
PDF
stackconf 2021 | Fuzzing: Finding Your Own Bugs and 0days!
Reversing malware analysis training part10 exploit development basics
Writing simple buffer_overflow_exploits
Penetration Testing for Easy RM to MP3 Converter Application and Post Exploit
Buffer overflow attacks
Software Security
Esage on non-existent 0-days, stable binary exploits and user interaction
2011-03 Developing Windows Exploits
Advanced Windows Exploitation
On non existent 0-days, stable binary exploits and
ETCSS: Into the Mind of a Hacker
Advanced Arm Exploitation
Vulnerability, exploit to metasploit
Anatomy of a Buffer Overflow Attack
Fuzzing: Finding Your Own Bugs and 0days! at Arab Security Conference
Buffer overflow – Smashing The Stack
fjfh mjgkj jkhglkjh jhlkh lhlkkhl kjhjkhjk
Exploiting stack overflow 101
Buffer Overflow Attacks
Buffer overflow Attacks
stackconf 2021 | Fuzzing: Finding Your Own Bugs and 0days!

More from ClubHack (20)

PDF
India legal 31 october 2014
PPTX
Cyberlaw by Mr. Pavan Duggal at ClubHack Infosec KeyNote @ Bangalore
PPT
Cyber Insurance
PPTX
Summarising Snowden and Snowden as internal threat
PPTX
Fatcat Automatic Web SQL Injector by Sandeep Kamble
PDF
The Difference Between the Reality and Feeling of Security by Thomas Kurian
PDF
Stand Close to Me & You're pwned! Owning Smart Phones using NFC by Aditya Gup...
PPTX
Smart Grid Security by Falgun Rathod
PPTX
Legal Nuances to the Cloud by Ritambhara Agrawal
PPT
Infrastructure Security by Sivamurthy Hiremath
PDF
Hybrid Analyzer for Web Application Security (HAWAS) by Lavakumar Kuppan
PPTX
Hacking and Securing iOS Applications by Satish Bomisstty
PPTX
Critical Infrastructure Security by Subodh Belgi
PPTX
Content Type Attack Dark Hole in the Secure Environment by Raman Gupta
PDF
XSS Shell by Vandan Joshi
PDF
Clubhack Magazine Issue February 2012
PDF
ClubHack Magazine issue 26 March 2012
PDF
ClubHack Magazine issue April 2012
PDF
ClubHack Magazine Issue May 2012
PDF
ClubHack Magazine – December 2011
India legal 31 october 2014
Cyberlaw by Mr. Pavan Duggal at ClubHack Infosec KeyNote @ Bangalore
Cyber Insurance
Summarising Snowden and Snowden as internal threat
Fatcat Automatic Web SQL Injector by Sandeep Kamble
The Difference Between the Reality and Feeling of Security by Thomas Kurian
Stand Close to Me & You're pwned! Owning Smart Phones using NFC by Aditya Gup...
Smart Grid Security by Falgun Rathod
Legal Nuances to the Cloud by Ritambhara Agrawal
Infrastructure Security by Sivamurthy Hiremath
Hybrid Analyzer for Web Application Security (HAWAS) by Lavakumar Kuppan
Hacking and Securing iOS Applications by Satish Bomisstty
Critical Infrastructure Security by Subodh Belgi
Content Type Attack Dark Hole in the Secure Environment by Raman Gupta
XSS Shell by Vandan Joshi
Clubhack Magazine Issue February 2012
ClubHack Magazine issue 26 March 2012
ClubHack Magazine issue April 2012
ClubHack Magazine Issue May 2012
ClubHack Magazine – December 2011

Recently uploaded (20)

PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Approach and Philosophy of On baking technology
PDF
cuic standard and advanced reporting.pdf
PPTX
Spectroscopy.pptx food analysis technology
PDF
Electronic commerce courselecture one. Pdf
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Empathic Computing: Creating Shared Understanding
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
KodekX | Application Modernization Development
Building Integrated photovoltaic BIPV_UPV.pdf
MIND Revenue Release Quarter 2 2025 Press Release
Approach and Philosophy of On baking technology
cuic standard and advanced reporting.pdf
Spectroscopy.pptx food analysis technology
Electronic commerce courselecture one. Pdf
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Network Security Unit 5.pdf for BCA BBA.
Chapter 3 Spatial Domain Image Processing.pdf
Review of recent advances in non-invasive hemoglobin estimation
Empathic Computing: Creating Shared Understanding
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
The Rise and Fall of 3GPP – Time for a Sabbatical?
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Reach Out and Touch Someone: Haptics and Empathic Computing
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
KodekX | Application Modernization Development

Nibin - Reverse Engineering for exploit writers - ClubHack2008

  • 1. Nibin Varghese iViZ Security, Kolkata Reverse Engineering for Exploit Writers
  • 2. Agenda Exploitation Overview Reverse Engineering Tools Case Study MS08-067
  • 3. Exploitation Overview Software vulnerabilities exist Reliable exploitation techniques exist Stack overflow Heap overflow Exploit mitigation Prevent or impede a class of vulnerabilities Patch the vulnerability Disable the service Generic mitigations
  • 4. Reverse Engineering Tools IDA Pro Bindiff Plugin for IDA Ollydbg or Immunity Debugger or Windbg Debugging Symbols Sysinternals tool suite Any scripting language to write PoC (Python, Ruby etc)
  • 5. MS08-067 Windows Server Service Vulnerability Out of band release Details: Error in netapi32.dll when processing directory traversal character sequence in path names. This can be exploited to corrupt stack memory by example sending RPC requests containing specially crafted path names to the Server service component – secunia.com
  • 6.  
  • 7. Structure of X86 stack frame Stack grows towards lower addresses Local Variables Saved EBP Saved IP Arguments
  • 8. Classical Overflow Return address overwritten with address of shellcode Local Variables Saved EBP Saved IP Arguments
  • 10. The Bug Decompiled by Alexander Sotirov Visual demo of the bug
  • 11. The Bug(contd..) ptr_path \\computername\\..\\..\\AAAAAAAAAAAAAAAAAAAAAAAAA ptr_previous_slash ptr_current_slash ptr_path points to the beginning of the buffer Parses to find current slash and previous slash‘\\’ Finds “..”, so the current slash pointer moves forward Data from Current slash pointer is copied to ptr_path If the pointer is at the beginning of the buffer, a pointer moves backward to find previous slash“\\”. 5a. Results in access violation if no “\\” are found 5b. Copies to the new destination if “\\” is found \\..\\AAAAAAAAAAAAAAAAAAAAAAAAA Lower Address Higher Address
  • 12. path Return Address of vulnerable_function Saved EBP Netapi32!NetpwPathCanonicalize vulnerable_function( wchar *path ) wcscpy(dst,src) Return Address of wcscpy Saved EBP ptr_path points to the beginning of the buffer Parses to find current slash and previous slash‘\\’ Finds “..”, so the current slash pointer moves forward Data from Current slash pointer is copied to ptr_path If the pointer is at the beginning of the buffer, a pointer moves backward to find previous slash“\\”. 5a. Results in access violation if no “\\” are found 5b. Copies to the new destination if “\\” is found \\..\\AAAAAA \\..\\AAAAAAAAAAA (ptr1 – 1) ptr2 ptr1 ptr_path \\c\\..\\.. \\AAAAAAAAAAA AAAA AAAA AAAA Shell Code
  • 13. The Bug (contd..) Not a classical buffer overflow The destination buffer is large enough to copy the contents from source The hunt for “\\” if the pointer points to the beginning of the buffer makes it a BUG
  • 14. Ready for PoC Identify the vector of exploitation 3 possible ways wcslen of path Predictable location of “\\” in the stack after repeated interaction Metasploit way of calculating the device_length
  • 15. Mass Exploitation If no NX, return to stack and execute shellcode If NX enabled, disable DEP/NX by abusing Win32 API NtSetInformationProcess and return to stack and execute shellcode. Refer Skape and Skywing paper on Uninformed Journal “Bypassing Windows Hardware-enforced Data Execution Prevention” In Vista, ASLR makes return addresses unpredictable.
  • 16. Thank You Thanks to Research Team@iViZ Security Thanks to Clubhack 08 organizers Thanks to all the attendees