Welcome!

Microservices Expo Authors: Derek Weeks, Liz McMillan, Elizabeth White, John Katrick, Pat Romanski

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
Some people are directors, managers, and administrators. Others are disrupters. Eddie Webb (@edwardawebb) is an IT Disrupter for Software Development Platforms at Liberty Mutual and was a presenter at the 2016 All Day DevOps conference. His talk, Organically DevOps: Building Quality and Security into the Software Supply Chain at Liberty Mutual, looked at Liberty Mutual's transformation to Continuous Integration, Continuous Delivery, and DevOps. For a large, heavily regulated industry, this task...
Modern software design has fundamentally changed how we manage applications, causing many to turn to containers as the new virtual machine for resource management. As container adoption grows beyond stateless applications to stateful workloads, the need for persistent storage is foundational - something customers routinely cite as a top pain point. In his session at @DevOpsSummit at 21st Cloud Expo, Bill Borsari, Head of Systems Engineering at Datera, explored how organizations can reap the bene...
Kubernetes is an open source system for automating deployment, scaling, and management of containerized applications. Kubernetes was originally built by Google, leveraging years of experience with managing container workloads, and is now a Cloud Native Compute Foundation (CNCF) project. Kubernetes has been widely adopted by the community, supported on all major public and private cloud providers, and is gaining rapid adoption in enterprises. However, Kubernetes may seem intimidating and complex ...
Gaining visibility in today’s sprawling cloud infrastructure is complex and laborious, involving drilling down into tools offered by various cloud services providers. Enterprise IT organizations need smarter and effective tools at their disposal in order to address this pertinent problem. Gaining a 360 - degree view of the cloud costs requires collection and analysis of the cost data across all cloud infrastructures used inside an enterprise.
You know you need the cloud, but you’re hesitant to simply dump everything at Amazon since you know that not all workloads are suitable for cloud. You know that you want the kind of ease of use and scalability that you get with public cloud, but your applications are architected in a way that makes the public cloud a non-starter. You’re looking at private cloud solutions based on hyperconverged infrastructure, but you’re concerned with the limits inherent in those technologies.
Gone are the days when application development was the daunting task of the highly skilled developers backed with strong IT skills, low code application development has democratized app development and empowered a new generation of citizen developers. There was a time when app development was in the domain of people with complex coding and technical skills. We called these people by various names like programmers, coders, techies, and they usually worked in a world oblivious of the everyday pri...
Our work, both with clients and with tools, has lead us to wonder how it is that organizations are handling compliance issues in the cloud. The big cloud vendors offer compliance for their infrastructure, but the shared responsibility model requires that you take certain steps to meet compliance requirements. Which lead us to start poking around a little more. We wanted to get a picture of what was available, and how it was being used. There is a lot of fluidity in this space, as in all things ...
The dynamic nature of the cloud means that change is a constant when it comes to modern cloud-based infrastructure. Delivering modern applications to end users, therefore, is a constantly shifting challenge. Delivery automation helps IT Ops teams ensure that apps are providing an optimal end user experience over hybrid-cloud and multi-cloud environments, no matter what the current state of the infrastructure is. To employ a delivery automation strategy that reflects your business rules, making r...
The notion of improving operational efficiency is conspicuously absent from the healthcare debate - neither Obamacare nor the newly proposed GOP plan discusses the impact that a step-function improvement in efficiency could have on access to healthcare (through more capacity), quality of healthcare services (through reduced wait times for patients) or cost (through better utilization of scarce, expensive assets).
Admiral Calcote - also known as Lee Calcote (@lcalcote) or the Ginger Geek to his friends - gave a presentation entitled Characterizing and Contrasting Container Orchestrators at the 2016 All Day DevOps conference. Okay, he isn't really an admiral - nor does anyone call him that - but he used the title admiral to describe what container orchestrators do, relating it to an admiral directing a fleet of container ships. You could also say that they are like the conductor of an orchestra, directing...
Cloud Governance means many things to many people. Heck, just the word cloud means different things depending on who you are talking to. While definitions can vary, controlling access to cloud resources is invariably a central piece of any governance program. Enterprise cloud computing has transformed IT. Cloud computing decreases time-to-market, improves agility by allowing businesses to adapt quickly to changing market demands, and, ultimately, drives down costs.
For DevOps teams, the concepts behind service-oriented architecture (SOA) are nothing new. A style of software design initially made popular in the 1990s, SOA was an alternative to a monolithic application; essentially a collection of coarse-grained components that communicated with each other. Communication would involve either simple data passing or two or more services coordinating some activity. SOA served as a valid approach to solving many architectural problems faced by businesses, as app...
SYS-CON Events announced today that Synametrics Technologies will exhibit at SYS-CON's 22nd International Cloud Expo®, which will take place on June 5-7, 2018, at the Javits Center in New York, NY. Synametrics Technologies is a privately held company based in Plainsboro, New Jersey that has been providing solutions for the developer community since 1997. Based on the success of its initial product offerings such as WinSQL, Xeams, SynaMan and Syncrify, Synametrics continues to create and hone in...
Some journey to cloud on a mission, others, a deadline. Change management is useful when migrating to public, private or hybrid cloud environments in either case. For most, stakeholder engagement peaks during the planning and post migration phases of a project. Legacy engagements are fairly direct: projects follow a linear progression of activities (the “waterfall” approach) – change managers and application coders work from the same functional and technical requirements. Enablement and develo...
The “Digital Era” is forcing us to engage with new methods to build, operate and maintain applications. This transformation also implies an evolution to more and more intelligent applications to better engage with the customers, while creating significant market differentiators. In both cases, the cloud has become a key enabler to embrace this digital revolution. So, moving to the cloud is no longer the question; the new questions are HOW and WHEN. To make this equation even more complex, most ...
Recent survey done across top 500 fortune companies shows almost 70% of the CIO have either heard about IAC from their infrastructure head or they are on their way to implement IAC. Yet if you look under the hood while some level of automation has been done, most of the infrastructure is still managed in much tradition/legacy way. So, what is Infrastructure as Code? how do you determine if your IT infrastructure is truly automated?
Every few years, a disruptive force comes along that prompts us to reframe our understanding of what something means, or how it works. For years, the notion of what a computer is and how you make one went pretty much unchallenged. Then virtualization came along, followed by cloud computing, and most recently containers. Suddenly the old rules no longer seemed to apply, or at least they didn’t always apply. These disruptors made us reconsider our IT worldview.
As people view cloud as a preferred option to build IT systems, the size of the cloud-based system is getting bigger and more complex. As the system gets bigger, more people need to collaborate from design to management. As more people collaborate to create a bigger system, the need for a systematic approach to automate the process is required. Just as in software, cloud now needs DevOps. In this session, the audience can see how people can solve this issue with a visual model. Visual models ha...
Containers are rapidly finding their way into enterprise data centers, but change is difficult. How do enterprises transform their architecture with technologies like containers without losing the reliable components of their current solutions? In his session at @DevOpsSummit at 21st Cloud Expo, Tony Campbell, Director, Educational Services at CoreOS, will explore the challenges organizations are facing today as they move to containers and go over how Kubernetes applications can deploy with lega...
Nordstrom is transforming the way that they do business and the cloud is the key to enabling speed and hyper personalized customer experiences. In his session at 21st Cloud Expo, Ken Schow, VP of Engineering at Nordstrom, will discuss some of the key learnings and common pitfalls of large enterprises moving to the cloud. This includes strategies around choosing a cloud provider(s), architecture, and lessons learned. In addition, he’ll go over some of the best practices for structured team migrat...