SlideShare una empresa de Scribd logo
1 de 43
ToorConX - The Ultimate Deobfuscator
Stephan Chenette, Principle Security Researcher
Websense Security Labs
Agenda

The Ultimate Deobfuscator: Hooking versus Simulation

 The Obfuscation “Problem”
 The “Simulated Solution”
 The Ultimate Deobfuscator
 Concluding remarks




                                                       2
The Obfuscation “Problem”

 Most malicious webpages today are obfuscated.




                                                  3
An obvious malicious redirect




                                4
What we actually see in the source




                                     5
DeObfuscation…how far we’ve come…


 Replacing all occurrences of "document.write" with alert.
 Replacing eval with document.write
 Forcing document.write to write between
  <textarea></textarea> tags

 But malcode authors added anti-debugging traps like
  arguments.callee.toString() to break the flow of execution
  if code were changed in anyway.




                                                               6
Script Debuggers…

 Microsoft Script Editor (MSE)

 Rhino (Mozilla’s JavaScript debugger)

 IE Developer’s Toolbar

 Firebug




                                          7
The “Simulated” solution

 Various toolkits have been released to Safely
  Investigating Malicious JavaScript

  – HTML Parser
  – DOM Implementation
  – Scripting Engine(s)/Interpreter(s)




                                                  8
The “Simulated” solution

Recent Presentations:

 Websense
  – (Alex Rice & Stephan Chenette) PacSec


 Arbor
  – (Jose Nazario) CanSecWest


 SecureWorks - CaffeineMonkey
  – (Ben Feinstein & Daniel Peck ) Blackhat




                                              9
10
11
12
13
14
15
16
17
18
19
20
21
Objects/functions that must be provided

           Native JavaScript      Browser Supplied
                 eval()                 alert()
          String.fromCharCode()    document.write()
                escape()             location.href
             Math.random()          window.status




                                                      22
Incomplete simulator




                       23
The ultimate goal would be….

 A headless browser basically….

 Non-graphical browser that would give us all the details
  internally of what’s going on without rendering the content.

 That wouldn’t allow successful exploitation.




                                                             24
The Dream…

 Deobfuscation results
    – eval, document.write
 Navigation to a new page
 Pop-ups prompting user to install an exe
 DNS errors
 Changes to the DOM, additional iframe elements or image
    elements
   Loading of ActiveX controls, success or failure and CLSID
   Iteration of the DOM whenever we wanted.

 All to do this automatically without a debugger

                                                                25
Another solution…

The “Ultimate” Deobfuscator…

 What better to use to deobfuscate content than the full
  browser itself?

 This presentation focuses on Internet Explorer, but this
  technique works for every browser.




                                                             26
Is it really that easy?

 Hook the right functions insides the browser and just sit
  back.




                                                              27
Hooking is a dirty job

 Especially when you’re functions that are neither exported
  or documented.

 Requires changes if browser dlls are updated




                                                               28
What’s hooked…the basics

 mshtml.dll
   – document.write
 jscript.dll
   – eval




                           29
Other interesting events to hook

 URL redirection
 Object creation
 DOM Element additions, removals
 DOM Attribute additions
 Etc.




                                    30
In action…

 Inject the DecoderHook DLL




                               31
In action…




             32
Output now resembles browser




                               33
Malicious deobfuscation example




                                  34
Malicious deobfuscation example




                                  35
Malicious obfuscated source code




                                   36
Malicious deobfuscation log




                              37
Malicious deobfuscation log




                              38
39
Suspended, but still malicious




                                 40
Hooking has multiple advantages




                                  41
Conclusion

 Obfuscation != Malicious

 Security Researchers analyzing web content must have a
  solid deobfuscation tools to deal with today’s malicious
  webscape.

 Hooking the browser is one more solution for manual
  reversing of obfuscated content.




                                                             42
Thank you.

 Any questions?

 I will be releasing POC code for this in a blog next week.

 Also…We’re hiring! One intern and One-Full time position
  open! San Diego position - Research/Dev skills, C, PERL,
  etc.!

 Check out our website and blogs
 http://securitylabs.websense.com/content/blogs.aspx
 http://securitylabs.websense.com/

                                                               43

Más contenido relacionado

La actualidad más candente

Devoops: DoJ Annual Cybersecurity Training Symposium Edition 2015
Devoops: DoJ Annual Cybersecurity Training Symposium Edition 2015Devoops: DoJ Annual Cybersecurity Training Symposium Edition 2015
Devoops: DoJ Annual Cybersecurity Training Symposium Edition 2015Chris Gates
 
[CB16] Invoke-Obfuscation: PowerShell obFUsk8tion Techniques & How To (Try To...
[CB16] Invoke-Obfuscation: PowerShell obFUsk8tion Techniques & How To (Try To...[CB16] Invoke-Obfuscation: PowerShell obFUsk8tion Techniques & How To (Try To...
[CB16] Invoke-Obfuscation: PowerShell obFUsk8tion Techniques & How To (Try To...CODE BLUE
 
Getting root with benign app store apps vsecurityfest
Getting root with benign app store apps vsecurityfestGetting root with benign app store apps vsecurityfest
Getting root with benign app store apps vsecurityfestCsaba Fitzl
 
PowerShell for Cyber Warriors - Bsides Knoxville 2016
PowerShell for Cyber Warriors - Bsides Knoxville 2016PowerShell for Cyber Warriors - Bsides Knoxville 2016
PowerShell for Cyber Warriors - Bsides Knoxville 2016Russel Van Tuyl
 
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
 
Raúl Siles - Browser Exploitation for Fun and Profit Revolutions [RootedCON 2...
Raúl Siles - Browser Exploitation for Fun and Profit Revolutions [RootedCON 2...Raúl Siles - Browser Exploitation for Fun and Profit Revolutions [RootedCON 2...
Raúl Siles - Browser Exploitation for Fun and Profit Revolutions [RootedCON 2...RootedCON
 
Attacker Ghost Stories (CarolinaCon / Area41 / RVASec)
Attacker Ghost Stories (CarolinaCon / Area41 / RVASec)Attacker Ghost Stories (CarolinaCon / Area41 / RVASec)
Attacker Ghost Stories (CarolinaCon / Area41 / RVASec)Rob Fuller
 
Dirty Little Secrets They Didn't Teach You In Pentest Class v2
Dirty Little Secrets They Didn't Teach You In Pentest Class v2Dirty Little Secrets They Didn't Teach You In Pentest Class v2
Dirty Little Secrets They Didn't Teach You In Pentest Class v2Rob Fuller
 
Appsec DC - wXf -2010
Appsec DC - wXf  -2010Appsec DC - wXf  -2010
Appsec DC - wXf -2010Chris Gates
 
"A rootkits writer’s guide to defense" - Michal Purzynski
"A rootkits writer’s guide to defense" - Michal Purzynski"A rootkits writer’s guide to defense" - Michal Purzynski
"A rootkits writer’s guide to defense" - Michal PurzynskiPROIDEA
 
Exploiting XPC in AntiVirus
Exploiting XPC in AntiVirusExploiting XPC in AntiVirus
Exploiting XPC in AntiVirusCsaba Fitzl
 
Attacking Oracle with the Metasploit Framework
Attacking Oracle with the Metasploit FrameworkAttacking Oracle with the Metasploit Framework
Attacking Oracle with the Metasploit FrameworkChris Gates
 
DevOOPS: Attacks and Defenses for DevOps Toolchains
DevOOPS: Attacks and Defenses for DevOps ToolchainsDevOOPS: Attacks and Defenses for DevOps Toolchains
DevOOPS: Attacks and Defenses for DevOps ToolchainsChris Gates
 
(130119) #fitalk apt, cyber espionage threat
(130119) #fitalk   apt, cyber espionage threat(130119) #fitalk   apt, cyber espionage threat
(130119) #fitalk apt, cyber espionage threatINSIGHT FORENSIC
 
Advanced JS Deobfuscation
Advanced JS DeobfuscationAdvanced JS Deobfuscation
Advanced JS DeobfuscationMinded Security
 
Think Like a Hacker - Database Attack Vectors
Think Like a Hacker - Database Attack VectorsThink Like a Hacker - Database Attack Vectors
Think Like a Hacker - Database Attack VectorsMark Ginnebaugh
 
Writing malware while the blue team is staring at you
Writing malware while the blue team is staring at youWriting malware while the blue team is staring at you
Writing malware while the blue team is staring at youRob Fuller
 
Exploiting Directory Permissions on macOS
Exploiting Directory Permissions on macOSExploiting Directory Permissions on macOS
Exploiting Directory Permissions on macOSCsaba Fitzl
 

La actualidad más candente (20)

Devoops: DoJ Annual Cybersecurity Training Symposium Edition 2015
Devoops: DoJ Annual Cybersecurity Training Symposium Edition 2015Devoops: DoJ Annual Cybersecurity Training Symposium Edition 2015
Devoops: DoJ Annual Cybersecurity Training Symposium Edition 2015
 
[CB16] Invoke-Obfuscation: PowerShell obFUsk8tion Techniques & How To (Try To...
[CB16] Invoke-Obfuscation: PowerShell obFUsk8tion Techniques & How To (Try To...[CB16] Invoke-Obfuscation: PowerShell obFUsk8tion Techniques & How To (Try To...
[CB16] Invoke-Obfuscation: PowerShell obFUsk8tion Techniques & How To (Try To...
 
Getting root with benign app store apps vsecurityfest
Getting root with benign app store apps vsecurityfestGetting root with benign app store apps vsecurityfest
Getting root with benign app store apps vsecurityfest
 
PowerShell for Cyber Warriors - Bsides Knoxville 2016
PowerShell for Cyber Warriors - Bsides Knoxville 2016PowerShell for Cyber Warriors - Bsides Knoxville 2016
PowerShell for Cyber Warriors - Bsides Knoxville 2016
 
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!
 
Raúl Siles - Browser Exploitation for Fun and Profit Revolutions [RootedCON 2...
Raúl Siles - Browser Exploitation for Fun and Profit Revolutions [RootedCON 2...Raúl Siles - Browser Exploitation for Fun and Profit Revolutions [RootedCON 2...
Raúl Siles - Browser Exploitation for Fun and Profit Revolutions [RootedCON 2...
 
Attacker Ghost Stories (CarolinaCon / Area41 / RVASec)
Attacker Ghost Stories (CarolinaCon / Area41 / RVASec)Attacker Ghost Stories (CarolinaCon / Area41 / RVASec)
Attacker Ghost Stories (CarolinaCon / Area41 / RVASec)
 
Dirty Little Secrets They Didn't Teach You In Pentest Class v2
Dirty Little Secrets They Didn't Teach You In Pentest Class v2Dirty Little Secrets They Didn't Teach You In Pentest Class v2
Dirty Little Secrets They Didn't Teach You In Pentest Class v2
 
Appsec DC - wXf -2010
Appsec DC - wXf  -2010Appsec DC - wXf  -2010
Appsec DC - wXf -2010
 
"A rootkits writer’s guide to defense" - Michal Purzynski
"A rootkits writer’s guide to defense" - Michal Purzynski"A rootkits writer’s guide to defense" - Michal Purzynski
"A rootkits writer’s guide to defense" - Michal Purzynski
 
Wielding a cortana
Wielding a cortanaWielding a cortana
Wielding a cortana
 
Exploiting XPC in AntiVirus
Exploiting XPC in AntiVirusExploiting XPC in AntiVirus
Exploiting XPC in AntiVirus
 
Attacking Oracle with the Metasploit Framework
Attacking Oracle with the Metasploit FrameworkAttacking Oracle with the Metasploit Framework
Attacking Oracle with the Metasploit Framework
 
DevOOPS: Attacks and Defenses for DevOps Toolchains
DevOOPS: Attacks and Defenses for DevOps ToolchainsDevOOPS: Attacks and Defenses for DevOps Toolchains
DevOOPS: Attacks and Defenses for DevOps Toolchains
 
(130119) #fitalk apt, cyber espionage threat
(130119) #fitalk   apt, cyber espionage threat(130119) #fitalk   apt, cyber espionage threat
(130119) #fitalk apt, cyber espionage threat
 
Advanced JS Deobfuscation
Advanced JS DeobfuscationAdvanced JS Deobfuscation
Advanced JS Deobfuscation
 
Think Like a Hacker - Database Attack Vectors
Think Like a Hacker - Database Attack VectorsThink Like a Hacker - Database Attack Vectors
Think Like a Hacker - Database Attack Vectors
 
Writing malware while the blue team is staring at you
Writing malware while the blue team is staring at youWriting malware while the blue team is staring at you
Writing malware while the blue team is staring at you
 
Exploiting Directory Permissions on macOS
Exploiting Directory Permissions on macOSExploiting Directory Permissions on macOS
Exploiting Directory Permissions on macOS
 
Pwnstaller
PwnstallerPwnstaller
Pwnstaller
 

Similar a The Ultimate Deobfuscator - ToorCON San Diego 2008

Automated JavaScript Deobfuscation - PacSec 2007
Automated JavaScript Deobfuscation - PacSec 2007Automated JavaScript Deobfuscation - PacSec 2007
Automated JavaScript Deobfuscation - PacSec 2007Stephan Chenette
 
.NET MALWARE THREAT: INTERNALS AND REVERSING DEF CON USA 2019
.NET MALWARE THREAT: INTERNALS AND REVERSING DEF CON USA 2019.NET MALWARE THREAT: INTERNALS AND REVERSING DEF CON USA 2019
.NET MALWARE THREAT: INTERNALS AND REVERSING DEF CON USA 2019Alexandre Borges
 
Docker Platform and Ecosystem
Docker Platform and EcosystemDocker Platform and Ecosystem
Docker Platform and EcosystemPatrick Chanezon
 
SecTor '09 - When Web 2.0 Attacks!
SecTor '09 - When Web 2.0 Attacks!SecTor '09 - When Web 2.0 Attacks!
SecTor '09 - When Web 2.0 Attacks!Rafal Los
 
DockerCon SF 2015: Keynote Day 1
DockerCon SF 2015: Keynote Day 1DockerCon SF 2015: Keynote Day 1
DockerCon SF 2015: Keynote Day 1Docker, Inc.
 
DevOps and the Death & Rebirth of Childhood Innocence
DevOps and the Death & Rebirth of Childhood InnocenceDevOps and the Death & Rebirth of Childhood Innocence
DevOps and the Death & Rebirth of Childhood InnocenceRobert Douglass
 
DevSecCon SG 2018 Fabian Presentation Slides
DevSecCon SG 2018 Fabian Presentation SlidesDevSecCon SG 2018 Fabian Presentation Slides
DevSecCon SG 2018 Fabian Presentation SlidesFab L
 
WebGL games with Minko - Next Game Frontier 2014
WebGL games with Minko - Next Game Frontier 2014WebGL games with Minko - Next Game Frontier 2014
WebGL games with Minko - Next Game Frontier 2014Minko3D
 
Software Architecture Erosion and Modernization
Software Architecture Erosion and ModernizationSoftware Architecture Erosion and Modernization
Software Architecture Erosion and Modernizationbmerkle
 
DEFCON 27 - ALEXANDRE BORGES - dot net malware threats
DEFCON 27 - ALEXANDRE BORGES - dot net malware threatsDEFCON 27 - ALEXANDRE BORGES - dot net malware threats
DEFCON 27 - ALEXANDRE BORGES - dot net malware threatsFelipe Prado
 
Joxean Koret - Database Security Paradise [Rooted CON 2011]
Joxean Koret - Database Security Paradise [Rooted CON 2011]Joxean Koret - Database Security Paradise [Rooted CON 2011]
Joxean Koret - Database Security Paradise [Rooted CON 2011]RootedCON
 
How to really obfuscate your pdf malware
How to really obfuscate   your pdf malwareHow to really obfuscate   your pdf malware
How to really obfuscate your pdf malwarezynamics GmbH
 
How to really obfuscate your pdf malware
How to really obfuscate your pdf malwareHow to really obfuscate your pdf malware
How to really obfuscate your pdf malwarezynamics GmbH
 
10 Reasons Your Software Sucks 2014 - Tax Day Edition!
10 Reasons Your Software Sucks 2014 - Tax Day Edition!10 Reasons Your Software Sucks 2014 - Tax Day Edition!
10 Reasons Your Software Sucks 2014 - Tax Day Edition!Caleb Jenkins
 
MunichJS - 2011-04-06
MunichJS - 2011-04-06MunichJS - 2011-04-06
MunichJS - 2011-04-06Mike West
 
Android : How Do I Code Thee?
Android : How Do I Code Thee?Android : How Do I Code Thee?
Android : How Do I Code Thee?Viswanath J
 
DEVOPS & THE DEATH AND REBIRTH OF CHILDHOOD INNOCENCE
DEVOPS & THE DEATH AND REBIRTH OF CHILDHOOD INNOCENCEDEVOPS & THE DEATH AND REBIRTH OF CHILDHOOD INNOCENCE
DEVOPS & THE DEATH AND REBIRTH OF CHILDHOOD INNOCENCEDrupalCamp Kyiv
 
Being Amazon for Software Developers - IDE 2.0: Crowdsourcing mal anders #Jav...
Being Amazon for Software Developers - IDE 2.0: Crowdsourcing mal anders #Jav...Being Amazon for Software Developers - IDE 2.0: Crowdsourcing mal anders #Jav...
Being Amazon for Software Developers - IDE 2.0: Crowdsourcing mal anders #Jav...Marcel Bruch
 
Java Programming
Java ProgrammingJava Programming
Java ProgrammingTracy Clark
 

Similar a The Ultimate Deobfuscator - ToorCON San Diego 2008 (20)

Automated JavaScript Deobfuscation - PacSec 2007
Automated JavaScript Deobfuscation - PacSec 2007Automated JavaScript Deobfuscation - PacSec 2007
Automated JavaScript Deobfuscation - PacSec 2007
 
.NET MALWARE THREAT: INTERNALS AND REVERSING DEF CON USA 2019
.NET MALWARE THREAT: INTERNALS AND REVERSING DEF CON USA 2019.NET MALWARE THREAT: INTERNALS AND REVERSING DEF CON USA 2019
.NET MALWARE THREAT: INTERNALS AND REVERSING DEF CON USA 2019
 
Docker Platform and Ecosystem
Docker Platform and EcosystemDocker Platform and Ecosystem
Docker Platform and Ecosystem
 
SecTor '09 - When Web 2.0 Attacks!
SecTor '09 - When Web 2.0 Attacks!SecTor '09 - When Web 2.0 Attacks!
SecTor '09 - When Web 2.0 Attacks!
 
DockerCon SF 2015: Keynote Day 1
DockerCon SF 2015: Keynote Day 1DockerCon SF 2015: Keynote Day 1
DockerCon SF 2015: Keynote Day 1
 
DevOps and the Death & Rebirth of Childhood Innocence
DevOps and the Death & Rebirth of Childhood InnocenceDevOps and the Death & Rebirth of Childhood Innocence
DevOps and the Death & Rebirth of Childhood Innocence
 
DevSecCon SG 2018 Fabian Presentation Slides
DevSecCon SG 2018 Fabian Presentation SlidesDevSecCon SG 2018 Fabian Presentation Slides
DevSecCon SG 2018 Fabian Presentation Slides
 
Need 4 Speed FI
Need 4 Speed FINeed 4 Speed FI
Need 4 Speed FI
 
WebGL games with Minko - Next Game Frontier 2014
WebGL games with Minko - Next Game Frontier 2014WebGL games with Minko - Next Game Frontier 2014
WebGL games with Minko - Next Game Frontier 2014
 
Software Architecture Erosion and Modernization
Software Architecture Erosion and ModernizationSoftware Architecture Erosion and Modernization
Software Architecture Erosion and Modernization
 
DEFCON 27 - ALEXANDRE BORGES - dot net malware threats
DEFCON 27 - ALEXANDRE BORGES - dot net malware threatsDEFCON 27 - ALEXANDRE BORGES - dot net malware threats
DEFCON 27 - ALEXANDRE BORGES - dot net malware threats
 
Joxean Koret - Database Security Paradise [Rooted CON 2011]
Joxean Koret - Database Security Paradise [Rooted CON 2011]Joxean Koret - Database Security Paradise [Rooted CON 2011]
Joxean Koret - Database Security Paradise [Rooted CON 2011]
 
How to really obfuscate your pdf malware
How to really obfuscate   your pdf malwareHow to really obfuscate   your pdf malware
How to really obfuscate your pdf malware
 
How to really obfuscate your pdf malware
How to really obfuscate your pdf malwareHow to really obfuscate your pdf malware
How to really obfuscate your pdf malware
 
10 Reasons Your Software Sucks 2014 - Tax Day Edition!
10 Reasons Your Software Sucks 2014 - Tax Day Edition!10 Reasons Your Software Sucks 2014 - Tax Day Edition!
10 Reasons Your Software Sucks 2014 - Tax Day Edition!
 
MunichJS - 2011-04-06
MunichJS - 2011-04-06MunichJS - 2011-04-06
MunichJS - 2011-04-06
 
Android : How Do I Code Thee?
Android : How Do I Code Thee?Android : How Do I Code Thee?
Android : How Do I Code Thee?
 
DEVOPS & THE DEATH AND REBIRTH OF CHILDHOOD INNOCENCE
DEVOPS & THE DEATH AND REBIRTH OF CHILDHOOD INNOCENCEDEVOPS & THE DEATH AND REBIRTH OF CHILDHOOD INNOCENCE
DEVOPS & THE DEATH AND REBIRTH OF CHILDHOOD INNOCENCE
 
Being Amazon for Software Developers - IDE 2.0: Crowdsourcing mal anders #Jav...
Being Amazon for Software Developers - IDE 2.0: Crowdsourcing mal anders #Jav...Being Amazon for Software Developers - IDE 2.0: Crowdsourcing mal anders #Jav...
Being Amazon for Software Developers - IDE 2.0: Crowdsourcing mal anders #Jav...
 
Java Programming
Java ProgrammingJava Programming
Java Programming
 

Más de Stephan Chenette

2013 Toorcon San Diego Building Custom Android Malware for Penetration Testing
2013 Toorcon San Diego Building Custom Android Malware for Penetration Testing2013 Toorcon San Diego Building Custom Android Malware for Penetration Testing
2013 Toorcon San Diego Building Custom Android Malware for Penetration TestingStephan Chenette
 
Building Custom Android Malware BruCON 2013
Building Custom Android Malware BruCON 2013Building Custom Android Malware BruCON 2013
Building Custom Android Malware BruCON 2013Stephan Chenette
 
B-Sides Seattle 2012 Offensive Defense
B-Sides Seattle 2012 Offensive DefenseB-Sides Seattle 2012 Offensive Defense
B-Sides Seattle 2012 Offensive DefenseStephan Chenette
 
The Future of Automated Malware Generation
The Future of Automated Malware GenerationThe Future of Automated Malware Generation
The Future of Automated Malware GenerationStephan Chenette
 
Detecting Web Browser Heap Corruption Attacks - Stephan Chenette, Moti Joseph...
Detecting Web Browser Heap Corruption Attacks - Stephan Chenette, Moti Joseph...Detecting Web Browser Heap Corruption Attacks - Stephan Chenette, Moti Joseph...
Detecting Web Browser Heap Corruption Attacks - Stephan Chenette, Moti Joseph...Stephan Chenette
 
Web Wreck-utation - CanSecWest 2008
Web Wreck-utation - CanSecWest 2008Web Wreck-utation - CanSecWest 2008
Web Wreck-utation - CanSecWest 2008Stephan Chenette
 
Watchtowers of the Internet - Source Boston 2012
Watchtowers of the Internet - Source Boston 2012Watchtowers of the Internet - Source Boston 2012
Watchtowers of the Internet - Source Boston 2012Stephan Chenette
 

Más de Stephan Chenette (8)

Landing on Jupyter
Landing on JupyterLanding on Jupyter
Landing on Jupyter
 
2013 Toorcon San Diego Building Custom Android Malware for Penetration Testing
2013 Toorcon San Diego Building Custom Android Malware for Penetration Testing2013 Toorcon San Diego Building Custom Android Malware for Penetration Testing
2013 Toorcon San Diego Building Custom Android Malware for Penetration Testing
 
Building Custom Android Malware BruCON 2013
Building Custom Android Malware BruCON 2013Building Custom Android Malware BruCON 2013
Building Custom Android Malware BruCON 2013
 
B-Sides Seattle 2012 Offensive Defense
B-Sides Seattle 2012 Offensive DefenseB-Sides Seattle 2012 Offensive Defense
B-Sides Seattle 2012 Offensive Defense
 
The Future of Automated Malware Generation
The Future of Automated Malware GenerationThe Future of Automated Malware Generation
The Future of Automated Malware Generation
 
Detecting Web Browser Heap Corruption Attacks - Stephan Chenette, Moti Joseph...
Detecting Web Browser Heap Corruption Attacks - Stephan Chenette, Moti Joseph...Detecting Web Browser Heap Corruption Attacks - Stephan Chenette, Moti Joseph...
Detecting Web Browser Heap Corruption Attacks - Stephan Chenette, Moti Joseph...
 
Web Wreck-utation - CanSecWest 2008
Web Wreck-utation - CanSecWest 2008Web Wreck-utation - CanSecWest 2008
Web Wreck-utation - CanSecWest 2008
 
Watchtowers of the Internet - Source Boston 2012
Watchtowers of the Internet - Source Boston 2012Watchtowers of the Internet - Source Boston 2012
Watchtowers of the Internet - Source Boston 2012
 

The Ultimate Deobfuscator - ToorCON San Diego 2008

  • 1. ToorConX - The Ultimate Deobfuscator Stephan Chenette, Principle Security Researcher Websense Security Labs
  • 2. Agenda The Ultimate Deobfuscator: Hooking versus Simulation  The Obfuscation “Problem”  The “Simulated Solution”  The Ultimate Deobfuscator  Concluding remarks 2
  • 3. The Obfuscation “Problem”  Most malicious webpages today are obfuscated. 3
  • 4. An obvious malicious redirect 4
  • 5. What we actually see in the source 5
  • 6. DeObfuscation…how far we’ve come…  Replacing all occurrences of "document.write" with alert.  Replacing eval with document.write  Forcing document.write to write between <textarea></textarea> tags  But malcode authors added anti-debugging traps like arguments.callee.toString() to break the flow of execution if code were changed in anyway. 6
  • 7. Script Debuggers…  Microsoft Script Editor (MSE)  Rhino (Mozilla’s JavaScript debugger)  IE Developer’s Toolbar  Firebug 7
  • 8. The “Simulated” solution  Various toolkits have been released to Safely Investigating Malicious JavaScript – HTML Parser – DOM Implementation – Scripting Engine(s)/Interpreter(s) 8
  • 9. The “Simulated” solution Recent Presentations:  Websense – (Alex Rice & Stephan Chenette) PacSec  Arbor – (Jose Nazario) CanSecWest  SecureWorks - CaffeineMonkey – (Ben Feinstein & Daniel Peck ) Blackhat 9
  • 10. 10
  • 11. 11
  • 12. 12
  • 13. 13
  • 14. 14
  • 15. 15
  • 16. 16
  • 17. 17
  • 18. 18
  • 19. 19
  • 20. 20
  • 21. 21
  • 22. Objects/functions that must be provided Native JavaScript Browser Supplied eval() alert() String.fromCharCode() document.write() escape() location.href Math.random() window.status 22
  • 24. The ultimate goal would be….  A headless browser basically….  Non-graphical browser that would give us all the details internally of what’s going on without rendering the content.  That wouldn’t allow successful exploitation. 24
  • 25. The Dream…  Deobfuscation results – eval, document.write  Navigation to a new page  Pop-ups prompting user to install an exe  DNS errors  Changes to the DOM, additional iframe elements or image elements  Loading of ActiveX controls, success or failure and CLSID  Iteration of the DOM whenever we wanted.  All to do this automatically without a debugger 25
  • 26. Another solution… The “Ultimate” Deobfuscator…  What better to use to deobfuscate content than the full browser itself?  This presentation focuses on Internet Explorer, but this technique works for every browser. 26
  • 27. Is it really that easy?  Hook the right functions insides the browser and just sit back. 27
  • 28. Hooking is a dirty job  Especially when you’re functions that are neither exported or documented.  Requires changes if browser dlls are updated 28
  • 29. What’s hooked…the basics  mshtml.dll – document.write  jscript.dll – eval 29
  • 30. Other interesting events to hook  URL redirection  Object creation  DOM Element additions, removals  DOM Attribute additions  Etc. 30
  • 31. In action…  Inject the DecoderHook DLL 31
  • 33. Output now resembles browser 33
  • 39. 39
  • 40. Suspended, but still malicious 40
  • 41. Hooking has multiple advantages 41
  • 42. Conclusion  Obfuscation != Malicious  Security Researchers analyzing web content must have a solid deobfuscation tools to deal with today’s malicious webscape.  Hooking the browser is one more solution for manual reversing of obfuscated content. 42
  • 43. Thank you.  Any questions?  I will be releasing POC code for this in a blog next week.  Also…We’re hiring! One intern and One-Full time position open! San Diego position - Research/Dev skills, C, PERL, etc.!  Check out our website and blogs  http://securitylabs.websense.com/content/blogs.aspx  http://securitylabs.websense.com/ 43

Notas del editor

  1. http://www.designersmind.com/images/JavaScript-Web.jpg
  2. http://www.linuxquestions.org/linux/answers/Security/Decoding_obfuscated_javascript_Simple_wayhttp://handlers.sans.org/dwesemann/decode/index.htmlhttp://handlers.sans.org/dwesemann/decode/https://isc2.sans.org/diary.html?storyid=2268properties of arguments.callee.toString() and how this makes analysis harder. This method allows a function to reference itself, and hence allows a function to detect modifications to its own code. Changing eval() to print() changes the function string, and with it the result. This can usually be defeated by re-defining the eval() function into a simple call to print(), but not so in this case. So let&apos;s take a look at some of the protection features in detail.http://yaisb.blogspot.com/2006/10/defeating-dean-edwards-javascript.html
  3. Too high level, need to see results at a lower level.
  4. http://handlers.sans.org/dwesemann/decode/http://asert.arbornetworks.com/2006/04/safely-investigating-malicious-javascript/https://www.blackhat.com/presentations/bh-usa-07/Feinstein_and_Peck/Whitepaper/bh-usa-07-feinstein_and_peck-WP.pdf
  5. There have been several presentations on building JavaScript simulators in the last two years.Let me show you how our simulator within Websense Security Labs works…
  6. When creating a simulator, the simulator must implement all the objects and functions that would be available by the browserSuch as document.write, alert, location.href, navigator, screen, etc.Also you have to load external pages. And all the js code from them, simple to break! Also have to deal with the transaction.If any of you have attempted to write any cross-browser JavaScript you’ll also know that there are lots of differences between them and how they interact with the Document Object Model or DOM inside the browser. Imagine the number of methods to test against to make sure the simulator has implemented everything necessary as well as how it has implemented it.
  7. Lacking any object or function will result in an error in deobfuscation process
  8. We want to see CreateElement for iframeOr SetAtribute for clsid, etc.CreateObjecte.g msxml2.XMLHTTP, Shell.Application, ADODB.stream, etc.
  9. Cover this slide in detail…
  10. codes that employed one or several of the &quot;document.referrer&quot;, &quot;document.location&quot; and &quot;location.href&quot; properties as part of the decoding process.http://myitforum.com/cs2/blogs/cmosby/archive/2008/07/17/obfuscated-javascript-redux-sans-internet-storm-center.aspxhttp://parentnode.org/javascript/obfuscated-javascript-challenge/http://hype-free.blogspot.com/2007/02/decoding-obfuscated-javascript.html
  11. Also doesn’t work for vista or 2003 due to aslr, and the dll base addresses being randomized.We have it working on 2000 and XP.
  12. document.write – write to a webpageeval – evaluates a string and executes it as if it were script codeDocument.write was pretty straight forward to hook.Eval wasn’t as straight forward. I had to hook it in the middle of the functon in order to get access to the buffer I wanted to output…kindadity, but it works.But there are tons of other functions within these two dlls that would be interesting to hook and log for analysis.
  13. Let’s take a non-malicious example to start.We see x*y or 10*20 which we see in the browser outputs as 200We see 2+2 which we see in the browser as 27And we see 10+17 which makes 27.The hooking has been done in such as way that a dll has been injected inside of IE, hooked document.write and eval and has outputted The results to a DbgView window.
  14. So lookng at DebugView we can see the same output that was computed for the browser.
  15. Now let’s look at a malicious example.Left off here…
  16. Where before an incomplete simulator would failA hooked decoder will have no trouble logging dynamic content.
  17. Obfuscation does not equal malicious, we must be able to tell the difference.Malicious files, exploits and content is found on the webAnd security researchers who don’t have the tools needed to analyze web content are going to be missing out on A key ability
  18. I will be releasing a blog next week where I’ll release the hooking code that accomplishes what I’ve talked about in this presentationAnd is a subset of what we’ve written for our infrastructure that works on a much larger scale.I also want to mention that we have two open positions, so if you’re interested drop your CV or card my way.