Welcome!

Microservices Expo Authors: Yeshim Deniz, Pat Romanski, Todd Matters, Mark Leake, Stefana Muller

Related Topics: Microservices Expo, Cloud Security

Microservices Expo: Article

Scanning Tools: The Target Environment

The useful scanning tools freely available today and how best to use them

The goal of the scanning phase is to learn more information about the target environment and discover openings by interacting with that target environment. This article will look at some of the most useful scanning tools freely available today and how to best use them. During this process we'll perform a number of scans.

Scan Types

  • Network sweeping - Basic technique used to determine which of a range of IP addresses map to live hosts.
  • Network tracing – A facility for tracing the route of a computer that is connected to the Internet.
  • Port scanning – software application designed to probe a network host for open ports.
  • OS fingerprinting – analysis of the TCP/IP stack to determine target operating system.
  • Version scanning – Interacting with different ports to determine protocols they speak and possibly the version of service listening on given port.
  • Vulnerability scanning – used to determine a list of potential unpatched systems, misconfiguration, etc.

While performing your scans run a sniffer to monitor your network activity. This will let you know if your scan hangs or if the connection goes down.

# tcpdump -nnX tcp and dst <target>

We are not looking to catch all the packets just to make sure the connection is up and the tool we use
doesn't hang.

Hping
In performing a network sweep of your target area consider using Hping which is a great general-purpose packet generation tool. Hping will ping a target IP address by sending TCP packets with no control bits set (SYN, ACK, FIN, RST, PSH, and URG set to zero).

# hping3 <target> -S -A -F -V -p 443

This will send TCP packets to the port 443 on host <target> with the SYN+ACK+FIN flags set.

# hping3 –rand-dest 192.168.1.x –interface eth0

This will send packets to random targets in the 192.168.1 network using interface eth0.

# hping3 –scan 80-445 -S target.com -V

This will portscan TCP port 80 to 445 on host target.com. (see Figure #1)

Figure 1: port scanning TCP port 80 to 445 on host target.com

Scapy
Scapy is a powerful interactive packet manipulation program written in python. It can replace hping and a number of other tools such as arping, tcpdump, tethereal, and p0f. Scapy's interactive shell is run in a terminal session. Root privileges are needed to send the packets or sudo.

>>> res,unans=traceroute([“www.google.com”,”www.packetstormsecurity.org”,
”pbnetworks.net”,”www.dnsstuff.co m”],dport=[80,443],maxttl=20,retry=-2)

The above is all on one line. (see Figure 2).

>>> res.graph()

Figure 2: Scapy in Action

This will output a graph in ImageMagick that will display your traceroute. (see Figure 3)

Figure 3: Syn Scanning a target

This is just a small portion of what Scapy can do for the pen-tester. I have two in depth videos on my site describing the many uses of Scapy <http://pbnetworks.net/?cmd=bbs&id=42>, <http://pbnetworks.net/?cmd=bbs&id=43> they are about 10 and 13 min in length.

Scapy can provide a valuable scanning tool as well. We will use scapy and its ability to SYN scan a target and look for open, closed, or filtered ports. We will scan an internal and external IP address below.

>>> sr(IP(dst=”192.168.1.111”)/TCP(sport=RandShort(),
dport=[21,22,80,443,445],flags=”S”))

This command will send a SYN scan on target 192.168.1.111 to destination ports 21,22,80,443, and 445. If we would like to scan a whole range use the () around the port numbers instead of the [ ].

Next we look at the response by issuing a request summary >>> ans,unans =_ and >>> ans.summary()

We can display only the information that we are interested in by using a simple loop

>>> ans.summary( lambda(s,r): r.sprintf(“%TCP.sport% \t %TCP.flags%”) )

Still a better table can be built with the make_table() function. Fist lets add some targets to scan.

>>> ans,unans = sr(IP(dst=[“192.168.1.111”,”192.168.1.121”,
”pbnetworks.net”])/TCP(dport=[21,22,80,443,445],flags=”S”))
>>> ans.make_table(
… lambda(s,r): (s.dst, s.dport,
… r.sprintf(“{TCP:%TCP.flags%}{ICMP:%IP.src% - %ICMP.type%}”)))


The output of the above can be seen in Figure 4

Figure 4: showing open ports using Scapy

Taking a look at the output of the above SYN scan we see that 69.64.155.180 has port 21 open, port 22 filtered or closed, ports 80 & 443 open, and port 445 filtered or closed. IP address 192.168.1.111 has port 21 open, ports 22,80, & 443 closed, and port 445 open. IP address 192.168.1.121 has port 21 closed, port 22 open, ports 80 & 443 closed, and port 445 open. The same scan can be done with ACK using flags=”A”)) & Xmas scan using flags=”FPU”)).

TCP port scanning sends a TCP SYN on each port and wait for a SYN-ACK or a RST or an ICMP error.

>>> res,unans = sr( IP(dst=”target”)
… /TCP(flags=”S”, dport=(1,1024)) )

This will send out a TCP SYN on ports 1-1024. To view the results use this command

>>> res.nsummary( lfilter=lambda (s,r): (r.haslayer(TCP) and (r.getlayer(TCP).flags & 2)) )

The output from above can be seen in Figure 5

Figure 5: TCP SYN on ports 1-1024

UDP Ping

To use UDP ping to produce ICMP port unreachable errors from a live host use the following cmd:

>>> ans,unans=sr( IP(dst="192.168.1.121")/UDP(dport=0) )

Begin emission:

.Finished to send 1 packets.

*

Received 2 packets, got 1 answers, remaining 0 packets

>>> ans.summary( lambda(s,r) : r.sprintf("%IP.src% is alive") )

192.168.1.121 is alive

Scapy is very good at two things sending packets and receiving answers. You can define your set of packets, it will send them, get answers back, match requests with answers, and list the unmatched packets.  Scapy is not designed for fast throughput.  It is written in Python, has many layers of abstraction (memory intensive).  Do not expect a packet rate higher than 6 Mbs per second.  You can easily design something that sniffs, mangles, and sends and this is exactly what is needed for the pentester.

Defense
It is possible to prevent port scans before they happen. In the case of FIN, Null, and X-mas scans can be prevented by simple kernel modification. If the kernel never sends a reset packet then the scan will turn up nothing. Lets take a look at the kernel code responsible for sending reset packets:

$ grep -n -A -20 "void.*send_reset" /usr/src/linux/net/ipv4/tcp_ipv4.c

Add a return command at line 581 (see Figure #6 may be different line on your system) with this:

return; // Modification: Never send RST, always return.

Figure 6: changing the code responsible for sending reset packets.

Nmap
Nmap is a free open source utility for network security auditing. This tool is useful once we've got a list of open ports and need to determine which services are using those ports. Finding these services running on ports we can use the Nmap version scanning functionality.

# nmap -n -O -sT -sV -p 1-1024 <target>

When using the -sV option you invoke the version scanning functionality. This will allow you to find services that are running on non-standard ports such as a web server running on TCP 90 or sshd on TCP 4444.

$ sudo nmap –spoof-mac Apple –traceroute –data-length 9 \ -f -D <victim>,
RND:5,ME -v -n -O -sS -sV -p T:1-1024 \ --randomize-hosts <target>

Now this is an interesting port scan we are spoofing our mac with the –spoof-mac option to appear to be a Apple OS. We complete a traceroute with the –traceroute and append the data length to 9 with –data-length 9 which will fill an entire TCP packet. We follow this with the -f which will cut up the data packets into 8 bit segments. The -D will allow us to add a decoy which is labeled <victim>. The RND:5 tells nmap to come up with 5 IP random IP address, ME tells nmap to put our IP in as the 7th IP address which in some IDS's will never be logged. Followed by -v to increase verbosity level -n no DNS resolution, -O OS detection, -sS TCP SYN stealth scan, -sV version scan, -p T:1-1024 specifies to only scan ports 1-1024 TCP and then randomize the hosts –randomize-hosts. While this will not completely provide anonymity it throws enough random IP at the host you are scanning to create a lot of work on the hosts intrusion detection team. Using the -f fragment packet option causes the requested scan to use tiny fragmented IP packets which makes it harder for packet filters, IDS, and other annoyances to detect what you are doing. The -D decoy scan which makes it appear to the remote host you specify as decoys are scanning the target network too. When you put ME in the list of decoys to represent the position for your real IP address in the sixth position or later, some common port scan detectors are unlikely to show your IP address at all. The –randomize-hosts tells nmap to shuffle each group of up to 16384 hosts before it scans them making the scan less obvious to various network monitoring systems.

Nmap Scriping Engine Scripts
Nmaps scripts are written in the Lua scripting language is fast, flexible, and free, with a small interpreter that works across platforms and is easily embedded inside of other applications. To invoke the nmap scripting engine, a user would use the -sC option to run all scripts in the 'default' category or with the –script optin to choose specific scripts.

# nmap -sC <target> -p 1-1024

Script categories consist of safe, intrusive, auth, malware, version, discovery, vulnerability, and default.  Scripts are located in /usr/share/nmap/scripts/script.db.  The following example is using the NSE script on a targets web applications:

# nmap –script “http-*” <target> -p 80,443

This will use all the NSE scripts that apply to http against the target box on ports 80 and 443.

To run a specific script use the --script parameter followed by the name of the script or a group of scripts:

# nmap –script Intrusive <target>

UDP Scan Types
UDP stands for User Datagram Protocol, very basic and lightweight, with few safeguards built into it. UDP uses datagram sockets on the transport layer (4), is one-way only and unreliable, just a basic method for sending data from one point to another. Nmap and unicornscan are tools that use UDP protocols. There are two types: empty packet scans and protocol data scans.

Empty packet scans – send UDP packets without any data to a port and wait to see whether a result is returned. If no response is seen then the port is considered open or filtered. If port unreachable is returned it can be assumed that the port is closed.

Protocol data scans – sending valid application protocol data in UDP packets to ports to see whether an application responds. Since this involves talking to the application it is more likely to be logged.

For nmap to perform an empty packet scan use the -sU flag:

# nmap -sU <target>

Unicornscan supports protocol data scans only, use the -mU flag to perform this scan:

# unicornscan -mU <target>

Nmap can use the applicaiotn fingerprint to perform protocol data scan:

# nmap -sU -sV <target>

Mixing UDP and application fingerprinting scans in Nmap can be very slow, if used limit the ports to be scanned.

Nessus Vulnerability Scanner
The Nessus Vulnerability Scanner is distributed by Tenable Network Security. It is available for download in Nessus for Business and Nessus for Home. I will not go into the installation or integration with Metasploit as I wrote another article on the subject for ClubHack earlier this year. I will go over the interface and demo a couple of scans on windows boxes looking for vulnerabilities.

First lets update the version of nessus by issuing the following command:

/opt/nessus/sbin/nessus-updateplugins

then start nessusd

# ./nessusd

Next we will open up a web-browser to https://localhost:8834 and login. There you can create policies, review reports, launch scans, etc. To begin a scan choose add and specify a target in this case its 192.168.1.111 and select a type of scan and this one we select Internal Network Scan. The scan is completed in short order notice I have tcpdump running when I launch the scan. (see Figure #7)

Figure 7: Nessus Scan

Nessus results include an estimate of the risk level associated with the finding (High, Medium, or Low) along with a brief description of each flaw along with recommendations for remedy (see Figure 8)

Figure 8: Nessus Scan Report

Conclusion
During the scanning phase a penetration tester will acquire useful information about the target environment that will be critical in the following stages where we use it to exploit our target. I have analyzed some tools used in determining many things about the target environment such as open ports, operating system types, and vulnerabilities.

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.

Comments (0)

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


@MicroservicesExpo Stories
Cloud Expo, Inc. has announced today that Andi Mann and Aruna Ravichandran have been named Co-Chairs of @DevOpsSummit at Cloud Expo Silicon Valley which will take place Oct. 31-Nov. 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. "DevOps is at the intersection of technology and business-optimizing tools, organizations and processes to bring measurable improvements in productivity and profitability," said Aruna Ravichandran, vice president, DevOps product and solutions marketing...
"When we talk about cloud without compromise what we're talking about is that when people think about 'I need the flexibility of the cloud' - it's the ability to create applications and run them in a cloud environment that's far more flexible,” explained Matthew Finnie, CTO of Interoute, in this SYS-CON.tv interview at 20th Cloud Expo, held June 6-8, 2017, at the Javits Center in New York City, NY.
For most organizations, the move to hybrid cloud is now a question of when, not if. Fully 82% of enterprises plan to have a hybrid cloud strategy this year, according to Infoholic Research. The worldwide hybrid cloud computing market is expected to grow about 34% annually over the next five years, reaching $241.13 billion by 2022. Companies are embracing hybrid cloud because of the many advantages it offers compared to relying on a single provider for all of their cloud needs. Hybrid offers bala...
A common misconception about the cloud is that one size fits all. Companies expecting to run all of their operations using one cloud solution or service must realize that doing so is akin to forcing the totality of their business functionality into a straightjacket. Unlocking the full potential of the cloud means embracing the multi-cloud future where businesses use their own cloud, and/or clouds from different vendors, to support separate functions or product groups. There is no single cloud so...
Containers, microservices and DevOps are all the rage lately. You can read about how great they are and how they’ll change your life and the industry everywhere. So naturally when we started a new company and were deciding how to architect our app, we went with microservices, containers and DevOps. About now you’re expecting a story of how everything went so smoothly, we’re now pushing out code ten times a day, but the reality is quite different.
"We are a monitoring company. We work with Salesforce, BBC, and quite a few other big logos. We basically provide monitoring for them, structure for their cloud services and we fit into the DevOps world" explained David Gildeh, Co-founder and CEO of Outlyer, in this SYS-CON.tv interview at DevOps Summit at 20th Cloud Expo, held June 6-8, 2017, at the Javits Center in New York City, NY.
21st International Cloud Expo, taking place October 31 - November 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA, 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 strategy. Me...
If you cannot explicitly articulate how investing in a new technology, changing the approach or re-engineering the business process will help you achieve your customer-centric vision of the future in direct and measurable ways, you probably shouldn’t be doing it. At Intellyx, we spend a lot of time talking to technology vendors. In our conversations, we explore emerging new technologies that are either disrupting the way enterprise organizations work or that help enable those organizations to ...
In 2014, Amazon announced a new form of compute called Lambda. We didn't know it at the time, but this represented a fundamental shift in what we expect from cloud computing. Now, all of the major cloud computing vendors want to take part in this disruptive technology. In his session at 20th Cloud Expo, Doug Vanderweide, an instructor at Linux Academy, discussed why major players like AWS, Microsoft Azure, IBM Bluemix, and Google Cloud Platform are all trying to sidestep VMs and containers wit...
The taxi industry never saw Uber coming. Startups are a threat to incumbents like never before, and a major enabler for startups is that they are instantly “cloud ready.” If innovation moves at the pace of IT, then your company is in trouble. Why? Because your data center will not keep up with frenetic pace AWS, Microsoft and Google are rolling out new capabilities. In his session at 20th Cloud Expo, Don Browning, VP of Cloud Architecture at Turner, posited that disruption is inevitable for comp...
For organizations that have amassed large sums of software complexity, taking a microservices approach is the first step toward DevOps and continuous improvement / development. Integrating system-level analysis with microservices makes it easier to change and add functionality to applications at any time without the increase of risk. Before you start big transformation projects or a cloud migration, make sure these changes won’t take down your entire organization.
There's a lot to gain from cloud computing, but success requires a thoughtful and enterprise focused approach. Cloud computing decouples data and information from the infrastructure on which it lies. A process that is a LOT more involved than dragging some folders from your desktop to a shared drive. Cloud computing as a mission transformation activity, not a technological one. As an organization moves from local information hosting to the cloud, one of the most important challenges is addressi...
What's the role of an IT self-service portal when you get to continuous delivery and Infrastructure as Code? This general session showed how to create the continuous delivery culture and eight accelerators for leading the change. Don Demcsak is a DevOps and Cloud Native Modernization Principal for Dell EMC based out of New Jersey. He is a former, long time, Microsoft Most Valuable Professional, specializing in building and architecting Application Delivery Pipelines for hybrid legacy, and cloud ...
Companies have always been concerned that traditional enterprise software is slow and complex to install, often disrupting critical and time-sensitive operations during roll-out. With the growing need to integrate new digital technologies into the enterprise to transform business processes, this concern has become even more pressing. A 2016 Panorama Consulting Solutions study revealed that enterprise resource planning (ERP) projects took an average of 21 months to install, with 57 percent of t...
Microservices are increasingly used in the development world as developers work to create larger, more complex applications that are better developed and managed as a combination of smaller services that work cohesively together for larger, application-wide functionality. Tools such as Service Fabric are rising to meet the need to think about and build apps using a piece-by-piece methodology that is, frankly, less mind-boggling than considering the whole of the application at once. Today, we'll ...
In his session at Cloud Expo, Alan Winters, an entertainment executive/TV producer turned serial entrepreneur, presented a success story of an entrepreneur who has both suffered through and benefited from offshore development across multiple businesses: The smart choice, or how to select the right offshore development partner Warning signs, or how to minimize chances of making the wrong choice Collaboration, or how to establish the most effective work processes Budget control, or how to ma...
Hybrid IT is today’s reality, and while its implementation may seem daunting at times, more and more organizations are migrating to the cloud. In fact, according to SolarWinds 2017 IT Trends Index: Portrait of a Hybrid IT Organization 95 percent of organizations have migrated crucial applications to the cloud in the past year. As such, it’s in every IT professional’s best interest to know what to expect.
Both SaaS vendors and SaaS buyers are going “all-in” to hyperscale IaaS platforms such as AWS, which is disrupting the SaaS value proposition. Why should the enterprise SaaS consumer pay for the SaaS service if their data is resident in adjacent AWS S3 buckets? If both SaaS sellers and buyers are using the same cloud tools, automation and pay-per-transaction model offered by IaaS platforms, then why not host the “shrink-wrapped” software in the customers’ cloud? Further, serverless computing, cl...
In the decade following his article, cloud computing further cemented Carr’s perspective. Compute, storage, and network resources have become simple utilities, available at the proverbial turn of the faucet. The value they provide is immense, but the cloud playing field is amazingly level. Carr’s quote above presaged the cloud to a T. Today, however, we’re in the digital era. Mark Andreesen’s ‘software is eating the world’ prognostication is coming to pass, as enterprises realize they must be...
Colocation is a central pillar of modern enterprise infrastructure planning because it provides greater control, insight, and performance than managed platforms. In spite of the inexorable rise of the cloud, most businesses with extensive IT hardware requirements choose to host their infrastructure in colocation data centers. According to a recent IDC survey, more than half of the businesses questioned use colocation services, and the number is even higher among established businesses and busin...