SANS Penetration Testing

Got Meterpreter? Pivot!

[Editor's note: Cliff Janzen wrote this nice article highlighting some of the pivoting options available to penetration testers who have exploited a target box. Metasploit supports a variety of ways to attack targets through an already-exploited system, and Cliff's summarizes of some of the most valuable ways of doing this. What's more, for each Metasploit technique he discusses, Cliff also offers alternative tools and techniques if you aren't using Metasploit. By pivoting, we can get a much better understanding of the security risk of a target organization based on the vulnerabilities we discover and successfully exploit — a critical aspect of high-value penetration testing. Thanks, Cliff! -Ed.]


Got Meterpreter? Pivot!

by Cliff Janzen

So you did got a Metasploit Meterpreter prompt on an in-scope target Windows box in the DMZ or internal network. You did your root dance and pillaged the heck out of it. Now what?


There are many ways to leverage the exploited system to discover, scan, and enumerate devices in the target network now available to you. This article will discuss some ways to leverage the Metasploit Framework (hereafter referred to as Metasploit) to accomplish various kinds of pivots, although there will be some non-Metasploit tips scattered throughout as well. This article is based on the premise that the compromised host is dual homed, but the same techniques can be used for VLANs or physically separate networks that have a route to a different network.



It's amazing what you can learn by watching how a device interacts with other devices on the network. Metasploit includes a sniffer Meterpreter module than can be used to do packet captures without the need to install any software on the remote machine, giving you a great idea of what you may want to pivot to, based on the traffic other potential targets are sending. Consider this example:


Already we can see at least one more potential target.

Not using Metasploit? When you pillaged the machine, did you notice if Microsoft Network Monitor was installed? If so, depending on which version, you may have to run netmon, netcap, or nmcap, each of which has slightly different features and syntax. For example, if Network Monitor 3 is installed running, you could execute the following command at a shell prompt:

C:\> NMCap /network 1 /capture /file c:\windows\temp\capt.cap /timeafter 10 minutes

... which starts a capture on network 1 writing to the specified location for ten minutes.

If the target machine has Microsoft .NET Framework on it and uploading a file is approved in the rules of engagement, give the RAWCAP program from a try. It's a tiny command-line sniffer for Windows (only 17KB) that doesn't require any special drivers to be installed. In fact, it requires no installation itself — just kick it off at a shell prompt. If you are running it in a shell, use the -f option to write to the file and ensure you have a way to stop the task (such as another command prompt with the Windows "taskkill" command).


Route and Auxiliary scan

The msf console route command can be used to tunnel outbound TCP connections from Metasploit running on your machine through the Meterpreter running on the exploited host and into the target network.

From the Meterpreter session, type a ctrl-z to place it in the background. Add the new route in Metasploit at the msf console prompt. As mentioned above, only TCP is supported, so we will do a TCP scan:

It's a good idea to limit the number of hosts and ports being scanned to limit the amount of time the scan will take. Most of the other TCP-based scanning auxiliary modules available in Metasploit, like SMBENUM, can also be used.

Not using Metasploit? Use the software available on the exploited host. Windows cmd.exe "FOR" loops and Telnet can be coerced into doing some amazing things. See some great examples at



Metasploit can act as a SOCKS4 proxy server, allowing you to carry the traffic from any socksified client program through Metasploit across your Meterpreter session to other targets. As above, set up Metasploit so that it can route to the target network through the Meterpreter session, and then run the socks4a auxiliary module in Metasploit.

With the socks module running, open a terminal and use ProxyChains to run a scan. ProxyChains is a great tool that allows us to take any TCP-based program and socksify it. Thus, we can pivot the traffic from any TCP-based program across our Meterpreter session.

Not using Metasploit? SSH tunnelling is ideal for this type of scanning, but unfortunately, most Windows machines don't have an SSH server (or even a client) installed by default. If, by chance, the system already has an SSH service listening with TCP forwarding enabled , or you can install something like OpenSSH for Windows (see the references below for a way to automate the install), then from your machine, start up a dynamic SSH tunnel.

Then modify the ProxyChains config file to use port 444 and run Nmap through ProxyChains as above.



If you use the techniques for port scanning described above, you will likely notice how SLOW some of these scans are. Fortunately for us, SecureState has come up with a very fast alternative, MSFMap. The MSFMap tool implements a subset of Nmap functionality in an easily loadable Meterpreter extension. The details behind MSFMap can be found at

Since MSFMap is a Meterpreter extension, no routing has to be done. Simply load the extension and let it fly... and fly it will, as shown below.

Not using Metasploit? The only thing I have found to compare to the speed and results of MSFmap is to install Nmap right on the victim machine, if allowed as per the rules of engagement.



What if you want to gather more information about a specific port? We already mentioned that with the route command, we could use any of the Metasploit TCP modules, but what if you want to use a tool not available in Metasploit itself? The Meterpreter portfwd command is yet another great Meterpreter feature. It can forward a single TCP port from your Metasploit machine tunneling traffic through the Meterpreter session on your exploited target to other target systems. No route or chaining required.


Not using Metasploit? Plink or the venerable Netcat may be an option. In fact, you can't talk about pivoting without mentioning Netcat. Ed Skoudis shows some interesting ways to use it at

Alternatively, Plink (from the maker of Putty - can be used to create an SSH tunnel from the exploited machine to the penetration tester's machine.



This article was meant as an overview of some tactics available to use pivot to further explore a target network and increase your understanding of the business impact of exploited vulnerabilities. As with most things in penetration testing, there are many ways to do any give task. We welcome your feedback and input.

-Cliff Janzen

Other References:

Upcoming SANS Special Event - 2018 Holiday Hack Challenge


SANS Holiday Hack Challenge - KringleCon 2018

  • Free SANS Online Capture-the-Flag Challenge
  • Our annual gift to the entire Information Security Industry
  • Designed for novice to advanced InfoSec professionals
  • Fun for the whole family!!
  • Build and hone your skills in a fun and festive roleplaying like video game, by the makers of SANS NetWars
  • Learn more:
  • Play previous versions from free 24/7/365:

Player Feedback!

  • "On to level 4 of the #holidayhackchallenge. Thanks again @edskoudis / @SANSPenTest team." - @mikehodges
  • "#SANSHolidayHack Confession — I have never used python or scapy before. I got started with both today because of this game! Yay!" - @tww2b
  • "Happiness is watching my 12 yo meet @edskoudis at the end of #SANSHolidayHack quest. Now the gnomes #ProudHackerPapa" - @dnlongen


Posted April 26, 2012 at 8:39 PM | Permalink | Reply

Jake Garlie

There was a new update to SecureState's MSFMap recently to now offer experimental support for SYN scans, port randomizations, and output sorting. This helps speed up the scans even more. Additionally, MSFMap now supports Windows 2000, and Windows XP Pre-SP2.

Posted April 27, 2012 at 12:17 PM | Permalink | Reply

Ed Skoudis

Good input, Jake. Thanks! MSFMap is darn cool stuff, and it's nice to see these added features.

Posted April 27, 2012 at 2:09 PM | Permalink | Reply

Cliff Janzen

That's excellent, Jake. Those are wonderful new features that are going to come in very handy. I am glad that work continues on MSFMap. It is a powerful must-have addition to the pentesters tool belt, in my opinion.

Posted April 27, 2012 at 11:01 PM | Permalink | Reply


I personally like to use the socks.exe proxy from if uploading tools is allowed. Its less than half a mb in size and then you can use nmap or whatever tool you want on your local machine. Plus its open source.

Posted April 28, 2012 at 2:02 PM | Permalink | Reply

Cliff Janzen

Thanks for the sharing, John. I know what I'm going to be playing with, er i mean researching, today.

Posted December 1, 2015 at 9:37 PM | Permalink | Reply


I enjoy, lead to I discovered exactly what I used to be having a look for.
You have ended my four day lengthy hunt! God Bless you man. Have a great day.
Rosaura site Nicoleddavidson.Wix.Com portal

Posted February 6, 2017 at 6:39 PM | Permalink | Reply

install telnet linux server os

I am in fact glad to read this webpage posts which
contains plenty of useful data, thanks for providing these kinds of statistics.

Post a Comment


* Indicates a required field.