Welcome!

Microservices Expo Authors: Jason Bloomberg, Karthick Viswanathan, Elizabeth White, Mehdi Daoudi, 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
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.
These days, APIs have become an integral part of the digital transformation journey for all enterprises. Every digital innovation story is connected to APIs . But have you ever pondered over to know what are the source of these APIs? Let me explain - APIs sources can be varied, internal or external, solving different purposes, but mostly categorized into the following two categories. Data lakes is a term used to represent disconnected but relevant data that are used by various business units wit...
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,...
Today most companies are adopting or evaluating container technology - Docker in particular - to speed up application deployment, drive down cost, ease management and make application delivery more flexible overall. As with most new architectures, this dream takes significant work to become a reality. Even when you do get your application componentized enough and packaged properly, there are still challenges for DevOps teams to making the shift to continuous delivery and achieving that reducti...
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...
Enterprises are moving to the cloud faster than most of us in security expected. CIOs are going from 0 to 100 in cloud adoption and leaving security teams in the dust. Once cloud is part of an enterprise stack, it’s unclear who has responsibility for the protection of applications, services, and data. When cloud breaches occur, whether active compromise or a publicly accessible database, the blame must fall on both service providers and users. In his session at 21st Cloud Expo, Ben Johnson, C...
Many organizations adopt DevOps to reduce cycle times and deliver software faster; some take on DevOps to drive higher quality and better end-user experience; others look to DevOps for a clearer line-of-sight to customers to drive better business impacts. In truth, these three foundations go together. In this power panel at @DevOpsSummit 21st Cloud Expo, moderated by DevOps Conference Co-Chair Andi Mann, industry experts will discuss how leading organizations build application success from all...
‘Trend’ is a pretty common business term, but its definition tends to vary by industry. In performance monitoring, trend, or trend shift, is a key metric that is used to indicate change. Change is inevitable. Today’s websites must frequently update and change to keep up with competition and attract new users, but such changes can have a negative impact on the user experience if not managed properly. The dynamic nature of the Internet makes it necessary to constantly monitor different metrics. O...
The last two years has seen discussions about cloud computing evolve from the public / private / hybrid split to the reality that most enterprises will be creating a complex, multi-cloud strategy. Companies are wary of committing all of their resources to a single cloud, and instead are choosing to spread the risk – and the benefits – of cloud computing across multiple providers and internal infrastructures, as they follow their business needs. Will this approach be successful? How large is the ...
Agile has finally jumped the technology shark, expanding outside the software world. Enterprises are now increasingly adopting Agile practices across their organizations in order to successfully navigate the disruptive waters that threaten to drown them. In our quest for establishing change as a core competency in our organizations, this business-centric notion of Agile is an essential component of Agile Digital Transformation. In the years since the publication of the Agile Manifesto, the conn...
The nature of the technology business is forward-thinking. It focuses on the future and what’s coming next. Innovations and creativity in our world of software development strive to improve the status quo and increase customer satisfaction through speed and increased connectivity. Yet, while it's exciting to see enterprises embrace new ways of thinking and advance their processes with cutting edge technology, it rarely happens rapidly or even simultaneously across all industries.
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.
Most of the time there is a lot of work involved to move to the cloud, and most of that isn't really related to AWS or Azure or Google Cloud. Before we talk about public cloud vendors and DevOps tools, there are usually several technical and non-technical challenges that are connected to it and that every company needs to solve to move to the cloud. In his session at 21st Cloud Expo, Stefano Bellasio, CEO and founder of Cloud Academy Inc., will discuss what the tools, disciplines, and cultural...
With the rise of DevOps, containers are at the brink of becoming a pervasive technology in Enterprise IT to accelerate application delivery for the business. When it comes to adopting containers in the enterprise, security is the highest adoption barrier. Is your organization ready to address the security risks with containers for your DevOps environment? In his session at @DevOpsSummit at 21st Cloud Expo, Chris Van Tuin, Chief Technologist, NA West at Red Hat, will discuss: The top security r...
"NetApp's vision is how we help organizations manage data - delivering the right data in the right place, in the right time, to the people who need it, and doing it agnostic to what the platform is," explained Josh Atwell, Developer Advocate for NetApp, in this SYS-CON.tv interview at 20th Cloud Expo, held June 6-8, 2017, at the Javits Center in New York City, NY.
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 ...
One of the biggest challenges with adopting a DevOps mentality is: new applications are easily adapted to cloud-native, microservice-based, or containerized architectures - they can be built for them - but old applications need complex refactoring. On the other hand, these new technologies can require relearning or adapting new, oftentimes more complex, methodologies and tools to be ready for production. In his general session at @DevOpsSummit at 20th Cloud Expo, Chris Brown, Solutions Marketi...
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...
Today companies are looking to achieve cloud-first digital agility to reduce time-to-market, optimize utilization of resources, and rapidly deliver disruptive business solutions. However, leveraging the benefits of cloud deployments can be complicated for companies with extensive legacy computing environments. In his session at 21st Cloud Expo, Craig Sproule, founder and CEO of Metavine, will outline the challenges enterprises face in migrating legacy solutions to the cloud. He will also prese...
DevOps at Cloud Expo – being held October 31 - November 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA – announces that its Call for Papers is open. Born out of proven success in agile development, cloud computing, and process automation, DevOps is a macro trend you cannot afford to miss. From showcase success stories from early adopters and web-scale businesses, DevOps is expanding to organizations of all sizes, including the world's largest enterprises – and delivering real r...