Welcome!

Microservices Expo Authors: Liz McMillan, Elizabeth White, Astadia CloudGPS, Jason Bloomberg, Karthick Viswanathan

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
"We focus on SAP workloads because they are among the most powerful but somewhat challenging workloads out there to take into public cloud," explained Swen Conrad, CEO of Ocean9, Inc., in this SYS-CON.tv interview at 20th Cloud Expo, held June 6-8, 2017, at the Javits Center in New York City, NY.
"As we've gone out into the public cloud we've seen that over time we may have lost a few things - we've lost control, we've given up cost to a certain extent, and then security, flexibility," explained Steve Conner, VP of Sales at Cloudistics,in this SYS-CON.tv interview at 20th Cloud Expo, held June 6-8, 2017, at the Javits Center in New York City, NY.
"Peak 10 is a hybrid infrastructure provider across the nation. We are in the thick of things when it comes to hybrid IT," explained , Chief Technology Officer at Peak 10, in this SYS-CON.tv interview at 20th Cloud Expo, held June 6-8, 2017, at the Javits Center in New York City, NY.
"I think DevOps is now a rambunctious teenager – it’s starting to get a mind of its own, wanting to get its own things but it still needs some adult supervision," explained Thomas Hooker, VP of marketing at CollabNet, 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.
"I will be talking about ChatOps and ChatOps as a way to solve some problems in the DevOps space," explained Himanshu Chhetri, CTO of Addteq, in this SYS-CON.tv interview at @DevOpsSummit at 20th Cloud Expo, held June 6-8, 2017, at the Javits Center in New York City, NY.
Your homes and cars can be automated and self-serviced. Why can't your storage? From simply asking questions to analyze and troubleshoot your infrastructure, to provisioning storage with snapshots, recovery and replication, your wildest sci-fi dream has come true. In his session at @DevOpsSummit at 20th Cloud Expo, Dan Florea, Director of Product Management at Tintri, provided a ChatOps demo where you can talk to your storage and manage it from anywhere, through Slack and similar services with...
If you are thinking about moving applications off a mainframe and over to open systems and the cloud, consider these guidelines to prioritize what to move and what to eliminate. On the surface, mainframe architecture seems relatively simple: A centrally located computer processes data through an input/output subsystem and stores its computations in memory. At the other end of the mainframe are printers and terminals that communicate with the mainframe through protocols. For all of its apparen...
Many organizations are now looking to DevOps maturity models to gauge their DevOps adoption and compare their maturity to their peers. However, as enterprise organizations rush to adopt DevOps, moving past experimentation to embrace it at scale, they are in danger of falling into the trap that they have fallen into time and time again. Unfortunately, we've seen this movie before, and we know how it ends: badly.
DevOps at Cloud Expo, taking place October 31 - November 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA, is co-located with 21st Cloud Expo and will feature technical sessions from a rock star conference faculty and the leading industry players in the world. The widespread success of cloud computing is driving the DevOps revolution in enterprise IT. Now as never before, development teams must communicate and collaborate in a dynamic, 24/7/365 environment. There is no time to w...
From manual human effort the world is slowly paving its way to a new space where most process are getting replaced with tools and systems to improve efficiency and bring down operational costs. Automation is the next big thing and low code platforms are fueling it in a significant way. The Automation era is here. We are in the fast pace of replacing manual human efforts with machines and processes. In the world of Information Technology too, we are linking disparate systems, softwares and tool...
All organizations that did not originate this moment have a pre-existing culture as well as legacy technology and processes that can be more or less amenable to DevOps implementation. That organizational culture is influenced by the personalities and management styles of Executive Management, the wider culture in which the organization is situated, and the personalities of key team members at all levels of the organization. This culture and entrenched interests usually throw a wrench in the work...
There is a huge demand for responsive, real-time mobile and web experiences, but current architectural patterns do not easily accommodate applications that respond to events in real time. Common solutions using message queues or HTTP long-polling quickly lead to resiliency, scalability and development velocity challenges. In his session at 21st Cloud Expo, Ryland Degnan, a Senior Software Engineer on the Netflix Edge Platform team, will discuss how by leveraging a reactive stream-based protocol,...
DevOps sees the coming together of practices, philosophies, and tools that allow you to create services and applications very quickly. This means that you can improve on your apps and evolve them at a much faster rate than those developers who are using traditional software development processes. We’ve talked about DevOps, in general, a great deal, but today, we’re going to dig a little deeper and take a look at Java DevOps specifically.
In his session at 20th Cloud Expo, Mike Johnston, an infrastructure engineer at Supergiant.io, discussed how to use Kubernetes to set up a SaaS infrastructure for your business. Mike Johnston is an infrastructure engineer at Supergiant.io with over 12 years of experience designing, deploying, and maintaining server and workstation infrastructure at all scales. He has experience with brick and mortar data centers as well as cloud providers like Digital Ocean, Amazon Web Services, and Rackspace. H...
With continuous delivery (CD) almost always in the spotlight, continuous integration (CI) is often left out in the cold. Indeed, it's been in use for so long and so widely, we often take the model for granted. So what is CI and how can you make the most of it? This blog is intended to answer those questions. Before we step into examining CI, we need to look back. Software developers often work in small teams and modularity, and need to integrate their changes with the rest of the project code b...
"Outscale was founded in 2010, is based in France, is a strategic partner to Dassault Systémes and has done quite a bit of work with divisions of Dassault," explained Jackie Funk, Digital Marketing exec at Outscale, in this SYS-CON.tv interview at 20th Cloud Expo, held June 6-8, 2017, at the Javits Center in New York City, NY.
From personal care products to groceries and movies on demand, cloud-based subscriptions are fulfilling the needs of consumers across an array of market sectors. Nowhere is this shift to subscription services more evident than in the technology sector. By adopting an Everything-as-a-Service (XaaS) delivery model, companies are able to tailor their computing environments to shape the experiences they want for customers as well as their workforce.
If you read a lot of business and technology publications, you might think public clouds are universally preferred over all other cloud options. To be sure, the numbers posted by Amazon Web Services (AWS) and Microsoft’s Azure platform are nothing short of impressive. Statistics reveal that public clouds are growing faster than private clouds and analysts at IDC predict that public cloud growth will be 3 times that of private clouds by 2019.
"At the keynote this morning we spoke about the value proposition of Nutanix, of having a DevOps culture and a mindset, and the business outcomes of achieving agility and scale, which everybody here is trying to accomplish," noted Mark Lavi, DevOps Solution Architect at Nutanix, in this SYS-CON.tv interview at @DevOpsSummit at 20th Cloud Expo, held June 6-8, 2017, at the Javits Center in New York City, NY.
SYS-CON Events announced today that Calligo has been named “Bronze Sponsor” of 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. Calligo is an innovative cloud service provider offering mid-sized companies the highest levels of data privacy. Calligo offers unparalleled application performance guarantees, commercial flexibility and a personalized support service from its globally located cloud platfor...