SlideShare uma empresa Scribd logo
1 de 55
Baixar para ler offline
Exploit Your Java Native
Vulnerabilities on Win7/JRE7 in One
Minute
Or how to exploit a single java vulnerability
in three different ways
Today we are not talking about how to
find 0day java native vulnerabilities, but
how to “cook” them
About me
• Architect, Trend Micro China
Development Center
• Interested in vulnerabilities,
sandbox technique, anti-APT
solution
• Hardcore ACG otaku
Agenda
• Background
• The vulnerability
• Exploit method 1
• Exploit method 2
• Exploit method 3
• Conclusion
What is java native vulnerability?
• Vulnerability which exists in JRE native code
(C/C++ code)
– Stack overflow
– Heap overflow
– Buffer overflow/underflow
– …
• Aka, java memory corruption vulnerability
Trends of Java native vulnerability
Exploit Java native vulnerability
• JRE 6
– No DEP, ASLR
– Find a schoolchild and teach him Heap Spray
• JRE 7
– Opt-in DEP, ASLR, windows 7, windows 8 …
– Hmmm, seems much harder ?
– Actually not so hard, we will show you how to in
this presentation
Agenda
• Background
• The vulnerability
• Exploit method 1
• Exploit method 2
• Exploit method 3
• Conclusion
CVE-2013-1491
• Found by Joshua J. Drake (jduck)
• Used on Pwn2013, defeated JRE 7 +
Windows8 (Accuvant Lab's White Paper)
• We also discovered the same issue in Feb
2013, via our java font fuzzer, and finished the
exploits in April 2013
CFF Font Instructions
• Compact Font Format, or Type2 font
• You can write instructions (byte codes) to help
building a character at runtime
private static native long
0A: call sub routine
0B: return from sub routine
0C 0A: add
0C 0B: sub
0C 0C: div
0C 0D: load
stack
Related Data Structures
• TopDictInfo
– buildCharArray – dynamic allocated array
– reg_WeightVector – static array in the structure
The two vulnerable instructions
• store [0, j, index, count]
• load [0, index, count]
No array boundary checks on store/load !
What can we do with it
• Read/Write arbitrary 16-bit range in the
buildCharArray and regWeightVector
• By over writing the buildCharArray pointer,
we can achieve arbitrary address read/write
Example
Initial State
T->topDictData
…
buildCharArray
…
reg_WeightVector
0x2000000
0x200087c
0x20007b4
0x2100000
Step1
put(0, 0x0c0c0c0c)
T->topDictData
…
buildCharArray
…
reg_WeightVector
0x2000000
0x200087c
0x20007b4
0x2100000
0c0c0c0c
buildCharArray[0] = 0x0c0c0c0c;
Step2
store(0, -18, 0, 1)
T->topDictData
…
buildCharArray
…
reg_WeightVector
0x2000000
0x200087c
0x20007b4 0x2100000
0c0c0c0c
reg_WeightVector[-18] = buildCharArray[0];
Step3
put(0, 0x41414141)
T->topDictData
…
buildCharArray
…
reg_WeightVector
0x2000000
0x200087c
0x20007b4
0x0c0c0c0c
41414141
buildCharArray[0] = 0x41414141;
Agenda
• Background
• The vulnerability
• Exploit method 1
• Exploit method 2
• Exploit method 3
• Conclusion
Information Leak + ROP
Information Leak
• Read a function pointer from the structure
• Sub a pre-computed offset from the function
pointer address, to get base address of t2k.dll
• Get other dll base (e.g. msvcrt) from IAT of
t2k.dll
ROP
1. Write ROP gadgets into buildCharArray
2. Set jmp_buf->eip to the first ROP instruction
3. Set jmp_buf->esp to buildCharArray
4. Trig an internal error to call longjmp
struct TopDictInfo {
tsiMemObject *mem;
…
}
struct
tsiMemObject {
…
jmp_buf env;
…
}
…
esp
…
…
eip
Agenda
• Background
• The vulnerability
• Exploit method 1
• Exploit method 2
• Exploit method 3
• Conclusion
Overwrite Array Length +
Statement
Java Array in memory
Object
Head length a[0] a[1] … a[n]
8 bytes 4 bytes
If we can overwrite the length field, then we can read/write
out of the bound of this java array
Array Spray
Overwrite Array length
• Set buildCharArray to 0x23ad27d8 (this address may
vary in different OS)
• Write “0x7fffffff” to 0x23ad27d8, which will be the
new array length
Overwrite ACC in Statement Object
• Statement: call method on a target object
• AccessControlContext: check permission on
privileged operations
Overwrite ACC in Statement Object
• When a new statement is created, the acc is set to
the “snapshot” of current calling context
• If you created the statement in low privileged code,
the acc will be a low privileged ACC
• We can replace the acc with a powerful ACC in
memory
Object
Head acc target … ……
Statement Object memory layout
Powerful
ACC
Method 2 – Exploit Procedure
length
data
1. Allocate arrays
acc
statement2. Allocate statement
object right after the array
Memory Space
3. Overwrite array length
new length
4. Overwrite acc in statement
powerful acc
Demo
• Exploit CVE-2013-1491 using Array length
overwriting + Statement
Method2 - Limitation
• You need to be able to overwrite memory of
Java Object Heap
JVM
java object heapjava native heap
Java
object
Java
Array
Default heap
of JRE native
code
Agenda
• Background
• The vulnerability
• Exploit method 1
• Exploit method 2
• Exploit method 3
• Conclusion
JIT Spray
History of JIT Spray
• Dion Blazakis - interpreter exploitation:
pointer inference and spraying
• Alexey Sintsov- Writing JIT shellcode for fun
and profit
• TT Tsai - The Flash JIT Spraying is Back
History of JIT Spray
• Mostly focus on flash
• No practical POC & Guide on Java
Java JIT Compiler
Java compiler,
into byte code in class file
JIT compiler, into native code
Java JIT Compiler (.cont)
• View JIT generated code
– -XX:+UnlockDiagnosticVMOptions -
XX:+PrintAssembly
• CompileThreshold
– Only when a function is called > CompileThreshold
times, it will be JITed
– Default value: 1500 for client JVM
XOR in java JIT compiler
public int spray(int a) {
int b = a;
b ^= 0x90909090;
b ^= 0x90909090;
b ^= 0x90909090;
return b;
}
0x01c21507: cmp 0x4(%ecx),%eax
0x01c2150a: jne 0x01bbd100 ;
0x01c21510: mov %eax,0xffffc000(%esp)
0x01c21517: push %ebp
0x01c21518: sub $0x18,%esp
0x01c2151b: xor $0x90909090,%edx
0x01c21521: xor $0x90909090,%edx
0x01c21527: xor $0x90909090,%edx
…
0x01c21539: ret
XOR in java JIT compiler (.cont)
• The XOR statement is compiled to an instruction of
six bytes
– 81 F2 90 90 90 3C xor edx, 0x3C909090
• We can replace the 3 NOP bytes with our shellcode
Set EIP in the middle
$0: 81 F2 90 90 90 3C : xor edx, 0x3C909090
$6: 81 F2 90 90 90 3C : xor edx, 0x3C909090
$12: 81 F2 90 90 90 3C : xor edx, 0x3C909090
$0: 81 F2
$2: 90 nop
$3: 90 nop
$4: 90 nop
$5: 3C 81 cmp al, 81
$7: F2 repne
$8: 90 nop
$9: 90 nop
$10: 90 nop
$11: 3C 81 cmp al, 81
EIP
EIP
Find a reliable EIP to jump to
• 0x02cd70b7
– Fairly reliable on the tested systems:
– windows xp sp3, windows 7 home edition,
windows 7 enterprise edition, windows 8 home
edition
Spray multiple functions at runtime
• ClassLoader.loadClass
JIT00002.classJIT00001.class …
Exploit.class
Performance
• First version: 20 ~ 40s to spray 2400 functions
– Because we have to call a function 1500 times
before it can be JITed
• Use pre warm up: 7 ~ 9s
Shellcode
• Two-Staged
– Stage0: Sprayed by JIT functions, will search for
Stage1 shellcode and execute it (egg-hunt)
– Stage1: Defined in java string, do the real work
Demo
• Exploit CVE-2013-1491 using JIT Spray
Add JIT Spray to your POC in one
minute
• Demo
– Add JIT Spray to CVE-2013-0809 POC
– We will public all related code after the
presentation
Optional Demo
• JRE 7 native 0day + Win8 + Java JIT Spray
Java JIT Spray - Limitation
• Currently only works on 32bits platform
• You need to be able to control EIP precisely
Agenda
• Background
• The vulnerability
• Exploit method 1
• Exploit method 2
• Exploit method 3
• Conclusion
Conclusion
• We introduced 3 different methods to exploit
a java native vulnerability and bypass
DEP/ASLR
• You need to choose the one that fit your
vulnerability
Conclusion
• Choose JIT Spray if 32bits & you can control
the EIP
• Choose Array + Statement if you can overwrite
a java array on java object heap
• Choose Information Leak + ROP if you are
Vupen
"Heapsprays are for the 99%"
“And so are JIT sprays."
Thank you!
Q & A

Mais conteúdo relacionado

Mais procurados

Serial Killer - Silently Pwning your Java Endpoints // OWASP BeNeLux Day 2016
Serial Killer - Silently Pwning your Java Endpoints // OWASP BeNeLux Day 2016Serial Killer - Silently Pwning your Java Endpoints // OWASP BeNeLux Day 2016
Serial Killer - Silently Pwning your Java Endpoints // OWASP BeNeLux Day 2016Christian Schneider
 
Building a java tracer
Building a java tracerBuilding a java tracer
Building a java tracerrahulrevo
 
Object Oriented Exploitation: New techniques in Windows mitigation bypass
Object Oriented Exploitation: New techniques in Windows mitigation bypassObject Oriented Exploitation: New techniques in Windows mitigation bypass
Object Oriented Exploitation: New techniques in Windows mitigation bypassSam Thomas
 
How to write clean & testable code without losing your mind
How to write clean & testable code without losing your mindHow to write clean & testable code without losing your mind
How to write clean & testable code without losing your mindAndreas Czakaj
 
Surviving the Java Deserialization Apocalypse // OWASP AppSecEU 2016
Surviving the Java Deserialization Apocalypse // OWASP AppSecEU 2016Surviving the Java Deserialization Apocalypse // OWASP AppSecEU 2016
Surviving the Java Deserialization Apocalypse // OWASP AppSecEU 2016Christian Schneider
 
Java Deserialization Vulnerabilities - The Forgotten Bug Class (DeepSec Edition)
Java Deserialization Vulnerabilities - The Forgotten Bug Class (DeepSec Edition)Java Deserialization Vulnerabilities - The Forgotten Bug Class (DeepSec Edition)
Java Deserialization Vulnerabilities - The Forgotten Bug Class (DeepSec Edition)CODE WHITE GmbH
 
Defending against Java Deserialization Vulnerabilities
 Defending against Java Deserialization Vulnerabilities Defending against Java Deserialization Vulnerabilities
Defending against Java Deserialization VulnerabilitiesLuca Carettoni
 
The definitive guide to java agents
The definitive guide to java agentsThe definitive guide to java agents
The definitive guide to java agentsRafael Winterhalter
 
Ruxmon cve 2012-2661
Ruxmon cve 2012-2661Ruxmon cve 2012-2661
Ruxmon cve 2012-2661snyff
 
Monitoring distributed (micro-)services
Monitoring distributed (micro-)servicesMonitoring distributed (micro-)services
Monitoring distributed (micro-)servicesRafael Winterhalter
 
The old is new, again. CVE-2011-2461 is back!
The old is new, again. CVE-2011-2461 is back!The old is new, again. CVE-2011-2461 is back!
The old is new, again. CVE-2011-2461 is back!Luca Carettoni
 
Java Deserialization Vulnerabilities - The Forgotten Bug Class (RuhrSec Edition)
Java Deserialization Vulnerabilities - The Forgotten Bug Class (RuhrSec Edition)Java Deserialization Vulnerabilities - The Forgotten Bug Class (RuhrSec Edition)
Java Deserialization Vulnerabilities - The Forgotten Bug Class (RuhrSec Edition)CODE WHITE GmbH
 
Analysis of bugs in Orchard CMS
Analysis of bugs in Orchard CMSAnalysis of bugs in Orchard CMS
Analysis of bugs in Orchard CMSPVS-Studio
 
Getting started with Java 9 modules
Getting started with Java 9 modulesGetting started with Java 9 modules
Getting started with Java 9 modulesRafael Winterhalter
 
Abusing Java Remote Interfaces
Abusing Java Remote InterfacesAbusing Java Remote Interfaces
Abusing Java Remote Interfacesjuanvazquezslides
 
Recon2016 shooting the_osx_el_capitan_kernel_like_a_sniper_chen_he
Recon2016 shooting the_osx_el_capitan_kernel_like_a_sniper_chen_heRecon2016 shooting the_osx_el_capitan_kernel_like_a_sniper_chen_he
Recon2016 shooting the_osx_el_capitan_kernel_like_a_sniper_chen_heLiang Chen
 

Mais procurados (20)

Serial Killer - Silently Pwning your Java Endpoints // OWASP BeNeLux Day 2016
Serial Killer - Silently Pwning your Java Endpoints // OWASP BeNeLux Day 2016Serial Killer - Silently Pwning your Java Endpoints // OWASP BeNeLux Day 2016
Serial Killer - Silently Pwning your Java Endpoints // OWASP BeNeLux Day 2016
 
Fixing the Java Serialization Mess
Fixing the Java Serialization Mess Fixing the Java Serialization Mess
Fixing the Java Serialization Mess
 
Building a java tracer
Building a java tracerBuilding a java tracer
Building a java tracer
 
Object Oriented Exploitation: New techniques in Windows mitigation bypass
Object Oriented Exploitation: New techniques in Windows mitigation bypassObject Oriented Exploitation: New techniques in Windows mitigation bypass
Object Oriented Exploitation: New techniques in Windows mitigation bypass
 
How to write clean & testable code without losing your mind
How to write clean & testable code without losing your mindHow to write clean & testable code without losing your mind
How to write clean & testable code without losing your mind
 
Surviving the Java Deserialization Apocalypse // OWASP AppSecEU 2016
Surviving the Java Deserialization Apocalypse // OWASP AppSecEU 2016Surviving the Java Deserialization Apocalypse // OWASP AppSecEU 2016
Surviving the Java Deserialization Apocalypse // OWASP AppSecEU 2016
 
Java 10, Java 11 and beyond
Java 10, Java 11 and beyondJava 10, Java 11 and beyond
Java 10, Java 11 and beyond
 
Celery
CeleryCelery
Celery
 
Byte code field report
Byte code field reportByte code field report
Byte code field report
 
Java Deserialization Vulnerabilities - The Forgotten Bug Class (DeepSec Edition)
Java Deserialization Vulnerabilities - The Forgotten Bug Class (DeepSec Edition)Java Deserialization Vulnerabilities - The Forgotten Bug Class (DeepSec Edition)
Java Deserialization Vulnerabilities - The Forgotten Bug Class (DeepSec Edition)
 
Defending against Java Deserialization Vulnerabilities
 Defending against Java Deserialization Vulnerabilities Defending against Java Deserialization Vulnerabilities
Defending against Java Deserialization Vulnerabilities
 
The definitive guide to java agents
The definitive guide to java agentsThe definitive guide to java agents
The definitive guide to java agents
 
Ruxmon cve 2012-2661
Ruxmon cve 2012-2661Ruxmon cve 2012-2661
Ruxmon cve 2012-2661
 
Monitoring distributed (micro-)services
Monitoring distributed (micro-)servicesMonitoring distributed (micro-)services
Monitoring distributed (micro-)services
 
The old is new, again. CVE-2011-2461 is back!
The old is new, again. CVE-2011-2461 is back!The old is new, again. CVE-2011-2461 is back!
The old is new, again. CVE-2011-2461 is back!
 
Java Deserialization Vulnerabilities - The Forgotten Bug Class (RuhrSec Edition)
Java Deserialization Vulnerabilities - The Forgotten Bug Class (RuhrSec Edition)Java Deserialization Vulnerabilities - The Forgotten Bug Class (RuhrSec Edition)
Java Deserialization Vulnerabilities - The Forgotten Bug Class (RuhrSec Edition)
 
Analysis of bugs in Orchard CMS
Analysis of bugs in Orchard CMSAnalysis of bugs in Orchard CMS
Analysis of bugs in Orchard CMS
 
Getting started with Java 9 modules
Getting started with Java 9 modulesGetting started with Java 9 modules
Getting started with Java 9 modules
 
Abusing Java Remote Interfaces
Abusing Java Remote InterfacesAbusing Java Remote Interfaces
Abusing Java Remote Interfaces
 
Recon2016 shooting the_osx_el_capitan_kernel_like_a_sniper_chen_he
Recon2016 shooting the_osx_el_capitan_kernel_like_a_sniper_chen_heRecon2016 shooting the_osx_el_capitan_kernel_like_a_sniper_chen_he
Recon2016 shooting the_osx_el_capitan_kernel_like_a_sniper_chen_he
 

Destaque

а2 лист 2
а2 лист 2а2 лист 2
а2 лист 2GRIGORYEVA
 
а2 лист 4
а2 лист 4а2 лист 4
а2 лист 4GRIGORYEVA
 
ДЛЯ МОБИЛЬНЫХ РАЗРАБОТЧИКОВ
ДЛЯ МОБИЛЬНЫХ РАЗРАБОТЧИКОВДЛЯ МОБИЛЬНЫХ РАЗРАБОТЧИКОВ
ДЛЯ МОБИЛЬНЫХ РАЗРАБОТЧИКОВEmpatika
 
дбн а.2.2 3-2012 редакція остаточна
дбн а.2.2 3-2012 редакція остаточнадбн а.2.2 3-2012 редакція остаточна
дбн а.2.2 3-2012 редакція остаточнаYegor Shulyk
 
ЕКТ QlikView конференция Минск 2014 А2 Консалтинг
ЕКТ QlikView конференция Минск 2014 А2 Консалтинг ЕКТ QlikView конференция Минск 2014 А2 Консалтинг
ЕКТ QlikView конференция Минск 2014 А2 Консалтинг a2consulting
 
Гараж QlikView конференция Минск 2014 А2 Консалтинг
Гараж QlikView конференция Минск 2014  А2 Консалтинг Гараж QlikView конференция Минск 2014  А2 Консалтинг
Гараж QlikView конференция Минск 2014 А2 Консалтинг a2consulting
 
Сердечна В.В
Сердечна В.ВСердечна В.В
Сердечна В.Вymcmb_ua
 
алгебра 7 класс дорофеев гдз
алгебра 7 класс дорофеев гдзалгебра 7 класс дорофеев гдз
алгебра 7 класс дорофеев гдзИван Иванов
 
台湾趴趴走
台湾趴趴走台湾趴趴走
台湾趴趴走Limbo Wong
 
Cheng_Wang_resume
Cheng_Wang_resumeCheng_Wang_resume
Cheng_Wang_resumeCheng Wang
 
CV_Shilidong
CV_ShilidongCV_Shilidong
CV_Shilidong?? ?
 
前端规范(初稿)
前端规范(初稿)前端规范(初稿)
前端规范(初稿)EnLei-Cai
 
冯宏华:H base在小米的应用与扩展
冯宏华:H base在小米的应用与扩展冯宏华:H base在小米的应用与扩展
冯宏华:H base在小米的应用与扩展hdhappy001
 
Fast flux domain detection
Fast flux domain detectionFast flux domain detection
Fast flux domain detectionNi Zhiqiang
 

Destaque (20)

Bilge12 zero day
Bilge12 zero dayBilge12 zero day
Bilge12 zero day
 
а2 лист 2
а2 лист 2а2 лист 2
а2 лист 2
 
а2 лист 4
а2 лист 4а2 лист 4
а2 лист 4
 
ДЛЯ МОБИЛЬНЫХ РАЗРАБОТЧИКОВ
ДЛЯ МОБИЛЬНЫХ РАЗРАБОТЧИКОВДЛЯ МОБИЛЬНЫХ РАЗРАБОТЧИКОВ
ДЛЯ МОБИЛЬНЫХ РАЗРАБОТЧИКОВ
 
дбн а.2.2 3-2012 редакція остаточна
дбн а.2.2 3-2012 редакція остаточнадбн а.2.2 3-2012 редакція остаточна
дбн а.2.2 3-2012 редакція остаточна
 
ЕКТ QlikView конференция Минск 2014 А2 Консалтинг
ЕКТ QlikView конференция Минск 2014 А2 Консалтинг ЕКТ QlikView конференция Минск 2014 А2 Консалтинг
ЕКТ QlikView конференция Минск 2014 А2 Консалтинг
 
Гараж QlikView конференция Минск 2014 А2 Консалтинг
Гараж QlikView конференция Минск 2014  А2 Консалтинг Гараж QlikView конференция Минск 2014  А2 Консалтинг
Гараж QlikView конференция Минск 2014 А2 Консалтинг
 
Сердечна В.В
Сердечна В.ВСердечна В.В
Сердечна В.В
 
алгебра 7 класс дорофеев гдз
алгебра 7 класс дорофеев гдзалгебра 7 класс дорофеев гдз
алгебра 7 класс дорофеев гдз
 
dpdp
dpdpdpdp
dpdp
 
Cv 12112015
Cv 12112015Cv 12112015
Cv 12112015
 
台湾趴趴走
台湾趴趴走台湾趴趴走
台湾趴趴走
 
Cheng_Wang_resume
Cheng_Wang_resumeCheng_Wang_resume
Cheng_Wang_resume
 
CV_Shilidong
CV_ShilidongCV_Shilidong
CV_Shilidong
 
前端规范(初稿)
前端规范(初稿)前端规范(初稿)
前端规范(初稿)
 
周士云的简历
周士云的简历周士云的简历
周士云的简历
 
冯宏华:H base在小米的应用与扩展
冯宏华:H base在小米的应用与扩展冯宏华:H base在小米的应用与扩展
冯宏华:H base在小米的应用与扩展
 
Fast flux domain detection
Fast flux domain detectionFast flux domain detection
Fast flux domain detection
 
CV-YacineRhalmi
CV-YacineRhalmiCV-YacineRhalmi
CV-YacineRhalmi
 
Hung DO-DUY - Spikenet
Hung DO-DUY - Spikenet Hung DO-DUY - Spikenet
Hung DO-DUY - Spikenet
 

Semelhante a 2013 syscan360 yuki_chen_syscan360_exploit your java native vulnerabilities on win7jre7 in one minute

Building High Performance Android Applications in Java and C++
Building High Performance Android Applications in Java and C++Building High Performance Android Applications in Java and C++
Building High Performance Android Applications in Java and C++Kenneth Geisshirt
 
HES2011 - Aaron Portnoy and Logan Brown - Black Box Auditing Adobe Shockwave
HES2011 - Aaron Portnoy and Logan Brown - Black Box Auditing Adobe ShockwaveHES2011 - Aaron Portnoy and Logan Brown - Black Box Auditing Adobe Shockwave
HES2011 - Aaron Portnoy and Logan Brown - Black Box Auditing Adobe ShockwaveHackito Ergo Sum
 
Tips and tricks for building high performance android apps using native code
Tips and tricks for building high performance android apps using native codeTips and tricks for building high performance android apps using native code
Tips and tricks for building high performance android apps using native codeKenneth Geisshirt
 
Fast as C: How to Write Really Terrible Java
Fast as C: How to Write Really Terrible JavaFast as C: How to Write Really Terrible Java
Fast as C: How to Write Really Terrible JavaCharles Nutter
 
It's always sunny with OpenJ9
It's always sunny with OpenJ9It's always sunny with OpenJ9
It's always sunny with OpenJ9DanHeidinga
 
Know your platform. 7 things every scala developer should know about jvm
Know your platform. 7 things every scala developer should know about jvmKnow your platform. 7 things every scala developer should know about jvm
Know your platform. 7 things every scala developer should know about jvmPawel Szulc
 
Sista: Improving Cog’s JIT performance
Sista: Improving Cog’s JIT performanceSista: Improving Cog’s JIT performance
Sista: Improving Cog’s JIT performanceESUG
 
The Performance Engineer's Guide To HotSpot Just-in-Time Compilation
The Performance Engineer's Guide To HotSpot Just-in-Time CompilationThe Performance Engineer's Guide To HotSpot Just-in-Time Compilation
The Performance Engineer's Guide To HotSpot Just-in-Time CompilationMonica Beckwith
 
Ahead-Of-Time Compilation of Java Applications
Ahead-Of-Time Compilation of Java ApplicationsAhead-Of-Time Compilation of Java Applications
Ahead-Of-Time Compilation of Java ApplicationsNikita Lipsky
 
자바 성능 강의
자바 성능 강의자바 성능 강의
자바 성능 강의Terry Cho
 
JRuby 9000 - Taipei Ruby User's Group 2015
JRuby 9000 - Taipei Ruby User's Group 2015JRuby 9000 - Taipei Ruby User's Group 2015
JRuby 9000 - Taipei Ruby User's Group 2015Charles Nutter
 
2013.02.02 지앤선 테크니컬 세미나 - Xcode를 활용한 디버깅 팁(OSXDEV)
2013.02.02 지앤선 테크니컬 세미나 - Xcode를 활용한 디버깅 팁(OSXDEV)2013.02.02 지앤선 테크니컬 세미나 - Xcode를 활용한 디버깅 팁(OSXDEV)
2013.02.02 지앤선 테크니컬 세미나 - Xcode를 활용한 디버깅 팁(OSXDEV)JiandSon
 
owasp lithuania chapter - exploit vs anti-exploit
owasp lithuania chapter - exploit vs anti-exploitowasp lithuania chapter - exploit vs anti-exploit
owasp lithuania chapter - exploit vs anti-exploitKęstutis Meškonis
 
Writing Metasploit Plugins
Writing Metasploit PluginsWriting Metasploit Plugins
Writing Metasploit Pluginsamiable_indian
 
Node.js - Advanced Basics
Node.js - Advanced BasicsNode.js - Advanced Basics
Node.js - Advanced BasicsDoug Jones
 

Semelhante a 2013 syscan360 yuki_chen_syscan360_exploit your java native vulnerabilities on win7jre7 in one minute (20)

Building High Performance Android Applications in Java and C++
Building High Performance Android Applications in Java and C++Building High Performance Android Applications in Java and C++
Building High Performance Android Applications in Java and C++
 
HES2011 - Aaron Portnoy and Logan Brown - Black Box Auditing Adobe Shockwave
HES2011 - Aaron Portnoy and Logan Brown - Black Box Auditing Adobe ShockwaveHES2011 - Aaron Portnoy and Logan Brown - Black Box Auditing Adobe Shockwave
HES2011 - Aaron Portnoy and Logan Brown - Black Box Auditing Adobe Shockwave
 
Tips and tricks for building high performance android apps using native code
Tips and tricks for building high performance android apps using native codeTips and tricks for building high performance android apps using native code
Tips and tricks for building high performance android apps using native code
 
Jvm internals
Jvm internalsJvm internals
Jvm internals
 
Fast as C: How to Write Really Terrible Java
Fast as C: How to Write Really Terrible JavaFast as C: How to Write Really Terrible Java
Fast as C: How to Write Really Terrible Java
 
It's always sunny with OpenJ9
It's always sunny with OpenJ9It's always sunny with OpenJ9
It's always sunny with OpenJ9
 
Know your platform. 7 things every scala developer should know about jvm
Know your platform. 7 things every scala developer should know about jvmKnow your platform. 7 things every scala developer should know about jvm
Know your platform. 7 things every scala developer should know about jvm
 
Surge2012
Surge2012Surge2012
Surge2012
 
Sista: Improving Cog’s JIT performance
Sista: Improving Cog’s JIT performanceSista: Improving Cog’s JIT performance
Sista: Improving Cog’s JIT performance
 
DIY Java Profiling
DIY Java ProfilingDIY Java Profiling
DIY Java Profiling
 
The Performance Engineer's Guide To HotSpot Just-in-Time Compilation
The Performance Engineer's Guide To HotSpot Just-in-Time CompilationThe Performance Engineer's Guide To HotSpot Just-in-Time Compilation
The Performance Engineer's Guide To HotSpot Just-in-Time Compilation
 
Ahead-Of-Time Compilation of Java Applications
Ahead-Of-Time Compilation of Java ApplicationsAhead-Of-Time Compilation of Java Applications
Ahead-Of-Time Compilation of Java Applications
 
자바 성능 강의
자바 성능 강의자바 성능 강의
자바 성능 강의
 
JRuby 9000 - Taipei Ruby User's Group 2015
JRuby 9000 - Taipei Ruby User's Group 2015JRuby 9000 - Taipei Ruby User's Group 2015
JRuby 9000 - Taipei Ruby User's Group 2015
 
2013.02.02 지앤선 테크니컬 세미나 - Xcode를 활용한 디버깅 팁(OSXDEV)
2013.02.02 지앤선 테크니컬 세미나 - Xcode를 활용한 디버깅 팁(OSXDEV)2013.02.02 지앤선 테크니컬 세미나 - Xcode를 활용한 디버깅 팁(OSXDEV)
2013.02.02 지앤선 테크니컬 세미나 - Xcode를 활용한 디버깅 팁(OSXDEV)
 
Eusecwest
EusecwestEusecwest
Eusecwest
 
owasp lithuania chapter - exploit vs anti-exploit
owasp lithuania chapter - exploit vs anti-exploitowasp lithuania chapter - exploit vs anti-exploit
owasp lithuania chapter - exploit vs anti-exploit
 
Writing Metasploit Plugins
Writing Metasploit PluginsWriting Metasploit Plugins
Writing Metasploit Plugins
 
12 virtualmachine
12 virtualmachine12 virtualmachine
12 virtualmachine
 
Node.js - Advanced Basics
Node.js - Advanced BasicsNode.js - Advanced Basics
Node.js - Advanced Basics
 

Último

How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...AliaaTarek5
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...panagenda
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesThousandEyes
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditSkynet Technologies
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 

Último (20)

How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
Manual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance AuditManual 508 Accessibility Compliance Audit
Manual 508 Accessibility Compliance Audit
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 

2013 syscan360 yuki_chen_syscan360_exploit your java native vulnerabilities on win7jre7 in one minute

  • 1. Exploit Your Java Native Vulnerabilities on Win7/JRE7 in One Minute Or how to exploit a single java vulnerability in three different ways
  • 2. Today we are not talking about how to find 0day java native vulnerabilities, but how to “cook” them
  • 3. About me • Architect, Trend Micro China Development Center • Interested in vulnerabilities, sandbox technique, anti-APT solution • Hardcore ACG otaku
  • 4. Agenda • Background • The vulnerability • Exploit method 1 • Exploit method 2 • Exploit method 3 • Conclusion
  • 5. What is java native vulnerability? • Vulnerability which exists in JRE native code (C/C++ code) – Stack overflow – Heap overflow – Buffer overflow/underflow – … • Aka, java memory corruption vulnerability
  • 6. Trends of Java native vulnerability
  • 7. Exploit Java native vulnerability • JRE 6 – No DEP, ASLR – Find a schoolchild and teach him Heap Spray • JRE 7 – Opt-in DEP, ASLR, windows 7, windows 8 … – Hmmm, seems much harder ? – Actually not so hard, we will show you how to in this presentation
  • 8. Agenda • Background • The vulnerability • Exploit method 1 • Exploit method 2 • Exploit method 3 • Conclusion
  • 9. CVE-2013-1491 • Found by Joshua J. Drake (jduck) • Used on Pwn2013, defeated JRE 7 + Windows8 (Accuvant Lab's White Paper) • We also discovered the same issue in Feb 2013, via our java font fuzzer, and finished the exploits in April 2013
  • 10. CFF Font Instructions • Compact Font Format, or Type2 font • You can write instructions (byte codes) to help building a character at runtime private static native long 0A: call sub routine 0B: return from sub routine 0C 0A: add 0C 0B: sub 0C 0C: div 0C 0D: load stack
  • 11. Related Data Structures • TopDictInfo – buildCharArray – dynamic allocated array – reg_WeightVector – static array in the structure
  • 12. The two vulnerable instructions • store [0, j, index, count] • load [0, index, count] No array boundary checks on store/load !
  • 13. What can we do with it • Read/Write arbitrary 16-bit range in the buildCharArray and regWeightVector • By over writing the buildCharArray pointer, we can achieve arbitrary address read/write
  • 16. Step2 store(0, -18, 0, 1) T->topDictData … buildCharArray … reg_WeightVector 0x2000000 0x200087c 0x20007b4 0x2100000 0c0c0c0c reg_WeightVector[-18] = buildCharArray[0];
  • 18. Agenda • Background • The vulnerability • Exploit method 1 • Exploit method 2 • Exploit method 3 • Conclusion
  • 20. Information Leak • Read a function pointer from the structure • Sub a pre-computed offset from the function pointer address, to get base address of t2k.dll • Get other dll base (e.g. msvcrt) from IAT of t2k.dll
  • 21. ROP 1. Write ROP gadgets into buildCharArray 2. Set jmp_buf->eip to the first ROP instruction 3. Set jmp_buf->esp to buildCharArray 4. Trig an internal error to call longjmp struct TopDictInfo { tsiMemObject *mem; … } struct tsiMemObject { … jmp_buf env; … } … esp … … eip
  • 22. Agenda • Background • The vulnerability • Exploit method 1 • Exploit method 2 • Exploit method 3 • Conclusion
  • 23. Overwrite Array Length + Statement
  • 24. Java Array in memory Object Head length a[0] a[1] … a[n] 8 bytes 4 bytes If we can overwrite the length field, then we can read/write out of the bound of this java array
  • 26. Overwrite Array length • Set buildCharArray to 0x23ad27d8 (this address may vary in different OS) • Write “0x7fffffff” to 0x23ad27d8, which will be the new array length
  • 27. Overwrite ACC in Statement Object • Statement: call method on a target object • AccessControlContext: check permission on privileged operations
  • 28. Overwrite ACC in Statement Object • When a new statement is created, the acc is set to the “snapshot” of current calling context • If you created the statement in low privileged code, the acc will be a low privileged ACC • We can replace the acc with a powerful ACC in memory Object Head acc target … …… Statement Object memory layout Powerful ACC
  • 29. Method 2 – Exploit Procedure length data 1. Allocate arrays acc statement2. Allocate statement object right after the array Memory Space 3. Overwrite array length new length 4. Overwrite acc in statement powerful acc
  • 30. Demo • Exploit CVE-2013-1491 using Array length overwriting + Statement
  • 31. Method2 - Limitation • You need to be able to overwrite memory of Java Object Heap JVM java object heapjava native heap Java object Java Array Default heap of JRE native code
  • 32. Agenda • Background • The vulnerability • Exploit method 1 • Exploit method 2 • Exploit method 3 • Conclusion
  • 34. History of JIT Spray • Dion Blazakis - interpreter exploitation: pointer inference and spraying • Alexey Sintsov- Writing JIT shellcode for fun and profit • TT Tsai - The Flash JIT Spraying is Back
  • 35. History of JIT Spray • Mostly focus on flash • No practical POC & Guide on Java
  • 36. Java JIT Compiler Java compiler, into byte code in class file JIT compiler, into native code
  • 37. Java JIT Compiler (.cont) • View JIT generated code – -XX:+UnlockDiagnosticVMOptions - XX:+PrintAssembly • CompileThreshold – Only when a function is called > CompileThreshold times, it will be JITed – Default value: 1500 for client JVM
  • 38. XOR in java JIT compiler public int spray(int a) { int b = a; b ^= 0x90909090; b ^= 0x90909090; b ^= 0x90909090; return b; } 0x01c21507: cmp 0x4(%ecx),%eax 0x01c2150a: jne 0x01bbd100 ; 0x01c21510: mov %eax,0xffffc000(%esp) 0x01c21517: push %ebp 0x01c21518: sub $0x18,%esp 0x01c2151b: xor $0x90909090,%edx 0x01c21521: xor $0x90909090,%edx 0x01c21527: xor $0x90909090,%edx … 0x01c21539: ret
  • 39. XOR in java JIT compiler (.cont) • The XOR statement is compiled to an instruction of six bytes – 81 F2 90 90 90 3C xor edx, 0x3C909090 • We can replace the 3 NOP bytes with our shellcode
  • 40. Set EIP in the middle $0: 81 F2 90 90 90 3C : xor edx, 0x3C909090 $6: 81 F2 90 90 90 3C : xor edx, 0x3C909090 $12: 81 F2 90 90 90 3C : xor edx, 0x3C909090 $0: 81 F2 $2: 90 nop $3: 90 nop $4: 90 nop $5: 3C 81 cmp al, 81 $7: F2 repne $8: 90 nop $9: 90 nop $10: 90 nop $11: 3C 81 cmp al, 81 EIP EIP
  • 41.
  • 42. Find a reliable EIP to jump to • 0x02cd70b7 – Fairly reliable on the tested systems: – windows xp sp3, windows 7 home edition, windows 7 enterprise edition, windows 8 home edition
  • 43. Spray multiple functions at runtime • ClassLoader.loadClass JIT00002.classJIT00001.class … Exploit.class
  • 44. Performance • First version: 20 ~ 40s to spray 2400 functions – Because we have to call a function 1500 times before it can be JITed • Use pre warm up: 7 ~ 9s
  • 45. Shellcode • Two-Staged – Stage0: Sprayed by JIT functions, will search for Stage1 shellcode and execute it (egg-hunt) – Stage1: Defined in java string, do the real work
  • 47. Add JIT Spray to your POC in one minute • Demo – Add JIT Spray to CVE-2013-0809 POC – We will public all related code after the presentation
  • 48. Optional Demo • JRE 7 native 0day + Win8 + Java JIT Spray
  • 49. Java JIT Spray - Limitation • Currently only works on 32bits platform • You need to be able to control EIP precisely
  • 50. Agenda • Background • The vulnerability • Exploit method 1 • Exploit method 2 • Exploit method 3 • Conclusion
  • 51.
  • 52. Conclusion • We introduced 3 different methods to exploit a java native vulnerability and bypass DEP/ASLR • You need to choose the one that fit your vulnerability
  • 53. Conclusion • Choose JIT Spray if 32bits & you can control the EIP • Choose Array + Statement if you can overwrite a java array on java object heap • Choose Information Leak + ROP if you are Vupen
  • 54. "Heapsprays are for the 99%" “And so are JIT sprays."