Kali 5
Kali 5
Kali 5
This is the process ID number that our shell is using. If I type “ps” I can see all the processes:
If we go further down the list, looking for our pid number of 3824 we see this:
3824 3796 powershell.exe x86 1 WIN-LOANLOTDQLU\Fred
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
This shows our process ID of 3824. It also shows that we are running under a powershell.exe process
as the user “Fred”.
This information comes in handy when we want to “migrate” out of this low level process and into a
process with a higher level access. We can move our shell off of this PID to a process that has higher
level access.
Migrating also allows us to merge and hide our shell into another more common process, in essence
hiding our connection. Explorer.exe is one of the more common processes to migrate to.
Simply find the PID# of the process you want to use (1736 on our system) and type, “migrate
<PID#>”
We will talk about migrating and some of the other Meterpreter commands more in later sections. For
now let’s talk about screenshots and using the remote webcam!
Then just type “run webcam” and add any options that you want. This will remotely display the
webcam from the target system.
If you use the “-l” option it will continuously grab webcam snaps until you hit “CNTRL-C”.
The only hint you get on the target machine that something is wrong is that your webcam recording
light (if yours has one) comes on. Other than that, you cannot tell that someone is remotely viewing
your webcam.
The webcam screenshot above is an actual image I got one day of my cat. Not sure why cats must
sleep on laptop keyboards, but I do know now who has been ordering all that Tuna fish online…
SCREENSHOTS
You can grab a snapshot of whatever is currently being displayed on your target’s monitor using the
“screenshot” command:
Well, along with getting his system infected with a backdoor exploit, it seems that our star employee
also spends his valuable time at work playing video games online.
Nice…
SOUND RECORDING
Recording sound is very similar, just type, “run sound_recorder -h” for options, or if you want to
grab a 30 second sound clip, run the command without any options:
You can then open the saved file on your Kali system to listen to it:
Running Scripts
The last topic we will cover in this section is running scripts. Meterpreter has over 200 scripts that
you can run to further expand your exploitation toolset.
We actually have already touched on these. We used the “ run” command to use the sound and
webcam script attacks. We will take a moment and cover a couple more of them.
To see a list of all the available scripts just type “Run <tab><tab>”:
Then just type, “run” with the script name that you want to try.
Here are a couple of the more interesting ones:
CHECKVM:
Sometimes when you get a remote shell you are not sure if you are in a Virtual Machine or a
standalone computer. You can check with this command.
As you can see it correctly determined that our target was a VMware VM.
GETGUI:
Getgui is a neat little script that will allow you to enable remote desktop on a Windows machine (if it
isn’t already enabled) and create a remote desktop user.
The user is added to both the remote desktop user group and the administrators group. This makes it
handy if you want to connect back to the machine at a later date.
First type, “run getgui -e” to enable remote desktop:
Then just run the program again and give it a username and password to use:
Now we just need to open a terminal and run the “rdesktop” command that comes with Kali to
connect to the Windows Remote Desktop:
The “-p -” switch tells rdesktop to prompts you to enter a password. This is a bit more secure as you
are not sending clear text passwords over the wire.
Once we login we will get a graphical Windows desktop on our Kali machine:
There are additional scripts to try to turn off Anti-Virus, disable the target’s firewall, grab artifacts
and credentials from multiple programs like Firefox, ftp programs, etc., plus many more.
Take some time and check them out.
Remote Shell
Lastly, let’s see how to get an actual C:\ prompt. This is extremely easy once we have a Meterpreter
session. Just type the command, “shell”.
That’s it! We can now run any DOS command that we want.
As you can see in the screenshot above, there are a couple settings that need to be set.
If you just want to see what files are there, you only need to set the “Drive” and “Session” settings as
shown above.
Then just run the exploit:
The exploit ran and found four files that it could recover, the two that we deleted and two other ones.
Now, say we only wanted to recover the txt files. Simply type, “set FILES txt” and run the exploit
again:
It recovered the text files and stored them in the /root/.msf4/loot directory. If we surf to that directory
we can find and open the text files that were saved:
As last time the recovered files were stored in the loot directory. We can open the PDF to verify that
it worked:
You can also set the module to recover multiple file types at once by simply listing what you want in
the FILES variable and separate them with a comma.
Lastly, the files can also be recovered by the ID number (not shown).
But then again, how many people actually record and analyze their data traffic?
The module does function extremely well though on smaller drives that don’t have an enormous
amount of deleted files. It was lightning fast and worked very well.
Conclusion
In this chapter we learned a lot about Metasploit’s Meterpreter shell. Though we covered some of the
basics of getting around and using the shell, we only touched on a fraction of its capabilities.
Hopefully you can see why getting a Meterpreter shell gives you a whole lot more functionality than
just getting a straight remote access shell.
Grabbing video and sound may seem to be a bit theatrical, but social engineers could use information
they glean. For instance from video they could grab images of people’s badges, and have a glimpse
into the target’s physical environment.
Sound is interesting too. A social engineer could learn a lot about the target facility by being able to
have a live microphone inside the building. And not too long ago “Sinn3r” from the Metasploit
development team showed how you could grab recorded audio and search it using AT&T’s Watson
speech program and Metasploit to look for keywords like “password” or “social security number”.
(See “Resources” above for link to article)