CEH: The Seven-Step Information Gathering Process
The Seven-Step Information Gathering Process
Define footprinting
Footprinting is about information gathering and is both passive and active. Reviewing the company’s website is an example of passive footprinting, whereas calling the help desk and attempting to social engineering them out of privileged information is an example of active information gathering. Scanning entails pinging machines, determining network ranges and port scanning individual systems. The EC-Council divides footprinting and scanning into seven basic steps. These include
Figure 3.1 Documentation finding.
This query will search in a URL for the tsweb/default.htm string. The search found over 200 sites that had the tsweb/default folder. One of these sites is shown in Figure 3.4.
Figure 3.4 Google hacking TSWeb.
Figure 3.5 DNS structure.
Locate the network range
Now that the pen test team has been able to locate name, phone numbers, addresses, some server names, and IP addresses, it’s important to find out what range of IP addresses are available for scanning and further enumeration. If you take the IP address of a web server discovered earlier and enter it into the Whois lookup at www.arin.net, the network’s range can be determined. As an example, 192.17.170.17 was entered into the ARIN Whois, and the following information was received:
Specify how traceroute works
The traceroute utility is used to determine the path to a target computer. Just as with nslookup, traceroute is available on Windows and UNIX platforms. In Windows, it is known as tracert because of 8.3 legacy filename constraints remaining from DOS. Traceroute was originally developed by Van Jacobson to view the path a packet follows from its source to its destination. Traceroute owes its functionality to the IP header time-to-live (TTL) field. You might remember from the discussion in Chapter 2, “The Technical Foundations of Hacking,” that the TTL field is used to limit IP datagram’s. Without a TTL, some IP datagram’s might travel the Internet forever as there would be no means of timeout. TTL functions as a decrementing counter. Each hop that a datagram passes through reduces the TTL field by one. If the TTL value reaches 0, the datagram is discarded and a time exceeded in transit Internet Control Message Protocol (ICMP) message is created to inform the source of the failure. Linux tracer-oute is based on UDP, whereas Windows uses ICMP.
Traceroute and ping are useful tools for identifying active systems, mapping their location, and learning more about their location. To learn more about these tools, take a few moments to complete the following challenge exercise:
Objective:
Identify active machines
Attackers will want to know if machines are alive before they attempt to attack. One of the most basic methods of identifying active machines is to perform a ping sweep. Although ping is found on just about every system running TCP/IP, it has been restricted by many organizations. Ping uses ICMP and works by sending an echo request to a system and waiting for the target to send an echo reply back. If the target device is unreachable, a request time out is returned. Ping is a useful tool to identify active machines and to measure the speed at which packets are moved from one host to another or to get details like the TTL. Figure 3.7 shows a ping capture from a Windows computer. If you take a moment to examine the ASCII decode in the bottom-left corner, you will notice that the data in the ping packet is composed of the alphabet, which is unlike a Linux ping, which would contain numeric values. That’s because the RFC that governs ping doesn’t specify what’s carried in the packet as payload. Vendors fill in this padding as they see fit. Unfortunately, this can also serve hackers as a covert channel. However, hackers can use a variety of programs to place their own information in place of the normal padding. Then what appears to be normal pings are actually a series of messages entering and leaving the network.
Ping does have a couple of drawbacks: First, only one system at a time is pinged and second, not all networks allow ping. To ping a large amount of hosts, a ping sweep is usually performed. Programs that perform ping sweeps typically sweep through a range of devices to determine which ones are active. Some of the programs that will perform ping sweeps include
Objective:
Understand how to map open ports and identify their underlying applications
With knowledge of the network range and a list of active devices, the next step is to identify open ports and access points. Identifying open ports will go a long way toward potential attack vectors. There is also the possibility of using war dialing programs to find ways around an organization’s firewall. If the organization is located close by, the attacker might war drive the area to look for open access points.
Objective:
Describe the differences between TCP and UDP scanning
Port scanning is the process of connecting to TCP and UDP ports for the purpose of finding what services and applications are running on the target device. After running applications, open ports and services are discovered, the hacker can then determine the best way to attack the system.
As discussed in Chapter 2, there are a total of 65,535 TCP and UDP ports. These port numbers are used to identify a specific process that a message is coming from or going to. Some common port numbers are shown in Table 3.6.
As you have probably noticed, some of these applications run on TCP, whereas others run on UDP. Although it is certainly possible to scan for all 65,535 TCP and 65,535 UDP ports, many hackers will not. They will concentrate on the first 1,024 ports. These well-known ports are where we find most of the commonly used applications. A list of well-known ports can be found at www.iana.org/assignments/port-numbers. Now, this is not to say that high order ports should be totally ignored because hackers might break into a system and open a high order port, such as 31337, to use as a backdoor. So, is one protocol easier to scan for than the other? Well, the answer to that question is yes. TCP offers more opportunity for the hacker to manipulate than UDP. Let’s take a look at why.
TCP offers robust communication and is considered a connection protocol. TCP establishes a connection by using what is called a 3-way handshake. Those three steps proceed as follows:
The TCP header contains a one-byte field for the flags. These flags can be seen in Table 3.7.
At the conclusion of communication, TCP terminates the session by using a 4-step shutdown. Those four steps proceed as follows:
The TCP system of communication makes for robust communication but also allows a hacker many ways to craft packets in an attempt to coax a server to respond or to try and avoid detection of anintrusion detection system (IDS). Many of these methods are built into Nmap and other port scanning tools, but before taking a look at those tools, some of the more popular port scanning techniques are listed here:
Certain OSes have taken some liberties when applying the TCP/IP RFCs and do things their own way. Because of this, not all scan types will work against all systems. So, results will vary, but Full Connect scans and SYN scans should work against all systems.
These are not the only types of possible scans; however, they are the more popular types. A few others worth briefly noting include
Now let’s look at UDP scans. UDP is unlike TCP. Although TCP is built on robust connections, UDP is based on speed. With TCP, the hacker has the ability to manipulate flags in an attempt to generate a TCP response or an error message from ICMP. UDP does not have flags, nor does UDP issue responses. It’s a fire and forget protocol! The most you can hope for is a response from ICMP.
If the port is closed, ICMP will attempt to send an ICMP type 3 code 3 port unreachable message to the source of the UDP scan. But, if the network is blocking ICMP, no error message will be returned. Therefore, the response to the scans might simply be no response. If you are planning on doing UDP scans, plan for unreliable results.
Next some of the programs that can be used for port scanning are discussed.
10>
Footprinting is about information gathering and is both passive and active. Reviewing the company’s website is an example of passive footprinting, whereas calling the help desk and attempting to social engineering them out of privileged information is an example of active information gathering. Scanning entails pinging machines, determining network ranges and port scanning individual systems. The EC-Council divides footprinting and scanning into seven basic steps. These include
- Information gathering
- Determining the network range
- Identifying active machines
- Finding open ports and access points
- OS fingerprinting
- Fingerprinting services
- Mapping the network
Many times, students ask for a step-by-step method of information gathering. Realize that these are just general steps and that ethical hacking is really the process of discovery. Although the material in this book is covered in an ordered approach, real life sometimes varies. When performing these activities, you might find that you are led in a different direction than what you originally envisioned.
Passive Information Gathering vs Active
Sniffing a network is NOT considered to be “Passive Information Gathering” because it involves direct contact with the target. Sniffing can be passive or active but still falls under “Active Information Gathering”.Information Gathering
The information gathering steps of footprinting and scanning are of utmost importance. Good information gathering can make the difference between a successful pen test and one that has failed to provide maximum benefit to the client. An amazing amount of information is available about most organizations in business today. This information can be found on the organization’s website, trade papers, Usenet, financial databases, or even from disgruntled employees. Some potential sources are discussed, but first, let’s review documentation.
Documentation
One important aspect of information gathering is documentation. Most people don’t like paperwork, but it’s a requirement that can’t be ignored. The best way to get off to a good start is to develop a systematic method to profile a target and record the results. Create a matrix with fields to record domain name, IP address, DNS servers, employee information, email addresses, IP address range, open ports, and banner details. Figure 3.1 gives an example of what your information matrix might look like when you start the documentation process.
Figure 3.1 Documentation finding.
Building this type of information early on will help in mapping the network and planning the best method of attack.
The Organization’s Website
With the initial documentation out of the way, it’s time to get started. The best place to begin is the organization’s website. You want to look for open source information, which is information freely provided to clients, customers, or the general public. Let’s look at an example of a local web hosting company. A quick review of its site shows it has a news and updates section. Recent news states the following:
“We are proud to have just updated all of our Cobalt servers to Plesk7 Virtual Site Servers. Anyone logging in to these new servers as admin should use the username of the domain, for example,http://www.xyz.com. The passwords have been transferred from the old servers, so no password reset should be required. We used the existing domain administrator password. Our continued alliance with Enterasys has allowed us to complete our transition from Cisco equipment. These upgrades, along with our addition of a third connection to the Internet, give us a high degree of fault tolerance.”
You might consider this good marketing information to provide potential clients. The problem is that this information is available to anyone who browses the website. This information allows attackers to know that the new systems are Linux-based and that the network equipment is all Enterasys. If attackers were planning to launch a denial of service (DoS) attack against the organization, they now know that they must knock out three nodes to the Internet. Even a competitor would benefit from this knowledge as the company is telling the competition everything about its infrastructure.
Another big information leakage point is the company directories. These usually identify key employees or departments. By combining this information with a little social engineering, an attacker can call the help desk, pretend he works for one of these key employees, and demand that a password be reset or changed. He could also use biographical information about a key employee to perform other types ofsocial engineering trickery. Kevin Mitnick used just this type of attack to gain access to restricted code that detailed the operation of Motorola cell phones. During a pen test, you will want to record any such findings and make sure to alert the organization as to what information is available and how it might be used in an attack.
Job Boards
If you’re lucky, the company has a job posting board. Look this over carefully, as you will be surprised at how much information is given here. If no job listings are posted on the organization’s website, get interactive and check out some of the major Internet job boards. Some popular sites are
Once at the job posting site, query for the organization. Here’s an example of the type of information typically found:
- Primary responsibilities for this position include management of a Windows 2000 Active Directory environment, including MS Exchange 2000, SQL 2000, and Citrix.
- Interact with the technical support supervisor to resolve issues and evaluate/maintain patch level and security updates.
- Experience necessary in: Active Directory, Microsoft Clustering and Network Load-Balancing, MS Exchange 2000, MS SQL 2000, Citrix MetaFrame XP, EMC CX-400 SAN-related or other enterprise level SAN, Veritas Net Backup, BigBrother, and NetIQ Monitoring SW.
- Maintain, support, and troubleshoot a Windows NT/2000 LAN.
Did these organizations give away any information that might be valuable to an attacker? They actually have told attackers almost everything about their network. Just the knowledge that the organization is still running Windows NT/2000 is extremely valuable.
Alternative Websites
If information is leaked on a company website, it cannot always be quickly removed. So, what if sensitive information is on a website that an organization does not control? There’s always the chance that disgruntled employees might have leaked this information on purpose. That’s why any good information gathering process will include visiting the darker corners of the Internet. Layoffs, reductions in force, and outsourcing are the types of events that don’t necessarily put the staff in the best of moods. It could be that the organization’s insiders have posted information that could be rather damaging. These unhappy individuals are potential sources of information leakage. This information might be posted on a blog, some type of “sucks” domain, or other site. Shown in Figure 3.2 is the Gap sucks domain. Although the legality of these domains depends on the type of information provided and their status as a non-commercial entity, their existence is something you should be aware of.
Frustrated employees will always find some way to vent their thoughts even if not from a “sucks” domain. One such site that might offer other insider information is internalmemos.com. This site lists information that is usually sensitive and that probably shouldn’t be released to the general public. Although some of the content is free, most of the content is considered premium and must be purchased to be viewed. One such document found after a search on the word “security” is shown in Figure 3.3. Don’t be surprised at what you find on this site or others like it.
Some other sites that can be used to gather information about the target organization and its employees include
- zabasearch.com— Contains names, addresses, phone numbers, date of birth, and other information about individuals.
- anywho.com— Phone book offering forward and reverse lookups.
- maps.yahoo.com— Yahoo! map site.
In combination, these sites allow attackers to locate key individuals, identify their home phone numbers, and even create maps to their houses. Attackers can even see the surroundings of the company or the home they are targeting with great quality satellite pictures.
EDGAR Database
If the organization you are working for is publicly traded, you will want to review the Security and Exchange commision’s EDGAR database. It’s located at www.sec.gov. A ton of information is available at this site. Hackers focus on the 10-Q and 10-K. These two documents contain yearly and quarterly reports. Not only do these documents contain earnings and potential revenue, but also details about any acquisitions and mergers. Anytime there is a merger or one firm acquires another, there is a rush to integrate the two networks. Having the networks integrated is more of an immediate concern than security. Therefore, you will be looking for entity names that are different from the parent organization. These findings might help you discover ways to jump from the subsidiary to the more secure parent company. You will want to record this information and have it ready when you start to research theIANA and ARIN databases.
Google Hacking
Most of us use Google or another search engine to locate information. What you might not know is that search engines, such as Google, have the capability to perform much more powerful searches than most people ever dream of. Not only can Google translate documents, perform news searches, do image searches, but it can also be used by hackers and attackers to do something that has been termed Google hacking. By using basic search techniques combined with advanced operators, Google can become a powerful vulnerability search tool. Some advanced operators include those shown in Table 3.1.
Table 3.1. Google Search Terms
Operator | Description |
Filetype | This operator directs Google to search only within the test of a particular type of file. Example: filetype:xls |
Inurl | This operator directs Google to search only within the specified URL of a document. Example: inurl:search-text |
Link | The link operator directs Google to search within hyperlinks for a specific term. Example link:www.domain.com |
Intitle | The intitle operator directs Google to search for a term within the title of a document. Example intitle: “Index of…etc” |
By using the advanced operators shown in Table 3.1 in combination with key terms, Google can be used to uncover many pieces of sensitive information that shouldn’t be revealed. A term even exists for the people who blindly post this information on the Internet; they are called google dorks. To see how this works, enter the following phrase into Google:
allinurl:tsweb/default.htmThis query will search in a URL for the tsweb/default.htm string. The search found over 200 sites that had the tsweb/default folder. One of these sites is shown in Figure 3.4.
Figure 3.4 Google hacking TSWeb.
As you can see, this could represent an easy way for a hacker to log directly in to the organization’s servers. Also, notice that there is no warning banner or other notice that unauthorized users should not attempt to connect. Finally, don’t forget that finding a vulnerability using Google is not unethical, but using that vulnerability is unless you have written permission from the domain owner. To learn more about Google hacking, take a look at http://johnny.ihackstuff.com. The site’s owner, Johnny Long, has also written an excellent book on the subject, Google Hacking for Penetration Testers.
USENET
USENET is a user’s network, which is nothing more than a collection of the thousands of discussion groups that reside on the Internet. Each discussion group contains information and messages centered on a specific topic. Messages are posted and responded to by readers either as public or private emails. Even without direct access to USENET, a convenient way to browse the content is by using Google Groups. Google Groups allow any Internet user a way to post and read USENET messages. During a penetration test, you will want to review Google Groups for postings from the target company.
One way to search is to use individual’s names you might have uncovered; another is to do a simple search of the company. Searching for @company.com will work. Many times, this will reveal useful information. One company that I performed some work for had listings from the network administrator. He had been asked to set up a new router and was having trouble getting it configured properly. The administrator had not only asked the group for help, but had also posted the router configuration to see if someone could help figure out what was wrong. The problem was that the configuration file had not been sanitized and not only contained IP addresses but also the following information:
enable secret 5 $1$2RKf$OMOAcvzpb7j9uhfw6C5Uj1
enable password 7 583132656321654949
For those of you who might not be Cisco gurus, those are encrypted passwords. Sure, they are encrypted, but given enough time, there’s the possibility that they might be cracked. Others of you who say that it’s only router passwords might be right, but let’s hope that the administrator doesn’t reuse passwords as many people do. As you can see, you can gain additional information about an organization and its technical strengths just by uncovering a few USENET posts.
Insecure Applications
Most applications really aren’t bad. Some are more insecure than others, but when deployed with layered controls and properly patched, risk can be minimized. When defense in depth isn’t used, problems start to arise. Defense in depth is the layering of one defensive mechanism after another. A case in point is the program Big Brother (www.bb4.com).
Big Brother is a program that can be used to monitor computer equipment. It can monitor and report the status of items, such as the central processing unit (CPU) utilization, disk usage, ssh status, http status, pop3 status, telnet status, and so on. Unlike Simple Network Monitoring Protocol (SNMP) in which information is just collected and devices polled, Big Brother can collect this information and forward it to a central web page or location. This makes it a valuable tool to the administrator in that it provides one central location to review network status and indicates status with a simple red/green interface. Problems are indicated in red, whereas operational systems are indicated in green. You might be asking yourself, okay, so what’s the problem with all this?
The problem is in how the administrator might have set up or configured Big Brother. Big Brother doesn’t need to run as root; therefore, the installation guide recommends that the user create a user named bb and configure that user with user privileges. Unless the administrator has changed this, you now know a valid user account on a system. Because the account isn’t used by a human, it might have an easy password or one that is not changed often. The makers of Big Brother also recommend that the web page used to store the information Big Brother generates be password protected. After all, this is extremely sensitive information. If this information has not been protected, all someone must do is go to www.google.com and search for “green:big brother.” If you scroll through the lists of sites and simply click on one, you’ll be taken to a page that displays systems, IP addresses, services, and versions
It’s only taken a few minutes for an attacker to gather this type of information, and it’s completely legal. These pages are posted so that the entire world can read them. Security professionals should always be concerned about what kind of information is posted on the Web and who can access it.
Registrar Query
Not long ago, searching for domain name information was much easier. There were only a few places to obtain domain names, and the activities of spammers and hackers had yet to cause the Internet Assigned Numbers Authority (IANA) to restrict the release of this information. Today, The Internet Corporation for Assigned Names and Numbers (ICANN) is the primary body charged with management of IP address space allocation, protocol parameter assignment, and domain name system management. Its role is really that of overall management, as domain name registration is handled by a number of competing firms that offer various value added services. These include firms such as networksolutions.com, register.com, godaddy.com, and tucows.com. There is also a series of Regional Internet Registries (RIR) that manage, distribute, and register public IP addresses within their respective regions. There are four primary RIRs with a fifth planned to support Africa. These are shown in Table 3.2.
Table 3.2. RIRs and Their Area of Control
RIR | Region of Control |
ARIN | North and South America and SubSaharan Africa |
APNIC | Asia and Pacific |
RIPE | Europe, Middle East, and parts of Africa |
LACNIC | Latin America and the Caribbean |
AfriNIC | Planned RIR to support Africa |
The primary tool to navigate these databases is Whois. Whois is a utility that interrogates the Internet domain name administration system and returns the domain ownership, address, location, phone number, and other details about a specified domain name. Whois is the primary tool used to query Domain Name Services (DNS). If you’re performing this information gathering from a Linux computer, the good news is Whois is built in. From the Linux prompt, users can type in whois domainname.com or whois? to get a list of various options. Windows users are not as fortunate as Linux users because Windows does not have a built-in Whois client. Windows users will have to use a third-party tool or website to obtain Whois information. One tool that a Windows user can use to perform Whois lookups is Sam Spade. It can be downloaded from www.samspade.org/ssw/download.html. Sam Spade contains a lot more utilities that just Whois, such as ping, finger, and traceroute. There’s also a variety of websites that you can use to obtain Whois information. Some of these include
- www.betterwhois.com
- www.allwhois.com
- http://geektools.com
- www.all-nettools.com
- www.tamos.com/products/smartwhois/
- www.dnsstuff.com
- www.samspade.org
Regardless of the tool, the goal is to obtain registrar information. As an example, the following listing shows the results after www.samspade.org is queried for information on www.exam-cram.com:
Registrant:
Pearson Technology Centre
Kenneth Simmons
200 Old Tappan Rd .
Old Tappan, NJ 07675 USA
Email: billing@superlibrary.com
Phone: 001-201-7846187
Registrar Name....: REGISTER.COM, INC.
Registrar Whois...: whois.register.com
Registrar Homepage: www.register.com
DNS Servers:
usrxdns1.pearsontc.com
oldtxdns2.pearsontc.com
This information provides a contact person, address, phone number, and DNS servers. A hacker skilled in the art of social engineering might use this information to call the organization and pretend to be Kenneth, or he might use the phone number to war dial a range of phone numbers looking for modems.
DNS Enumeration
The attacker has also identified the names of the DNS servers. DNS servers might be targeted for zone transfers. A zone transfer is the mechanism used by DNS servers to update each other by transferring the contents of their database. DNS is structured as a hierarchy so that when you request DNS information, your request is passed up the hierarchy until a DNS server is found that can resolve the domain name request. You can get a better idea of how DNS is structured by examining Figure 3.5. There is a total of 13 DNS root servers.
Figure 3.5 DNS structure.
What’s left at this step is to try and gather additional information from the organization’s DNS servers. The primary tool to query DNS servers is nslookup. Nslookup provides machine name and address information. Both Linux and Windows have nslookup clients. Nslookup is used by typing nslookup from the command line followed by an IP address or a machine name. Doing so will cause nslookup to return the name, all known IP addresses, and all known CNAMES for the identified machine. Nslookup queries DNS servers for machine name and address information. Using nslookup is rather straightforward. Let’s look at an example in which nslookup is used to find out the IP addresses of Google’s web servers. By entering nslookup www.google.com , the following response is obtained:
C:\>nslookup www.google.com
Server: dnsr1.sbcglobal.net
Address: 68.94.156.1
Non-authoritative answer:
Name: www.l.google.com
Addresses: 64.233.187.99, 64.233.187.104
Aliases: www.google.com
The first two lines of output say which DNS servers are being queried. In this case, it’sdnsr1.sbcglobal.net in Texas. The non-authoritative answer lists two IP addresses for the Google web servers. Responses from non-authoritative servers do not contain copies of any domains. They have a cache file that is constructed from all the DNS lookups it has performed in the past for which it has gotten an authoritative response.
Nslookup can also be used in an interactive mode by just typing nslookup at the command prompt. In interactive mode, the user will be given a prompt of >; at which point, the user can enter a variety of options, including attempts to perform a zone transfer.
DNS normally moves information from one DNS server to another through the DNS zone transfer process. If a domain contains more than one name server, only one of these servers will be the primary. Any other servers in the domain will be secondary servers. Zone transfers are much like the DHCP process in that each is a four-step process. DNS zone transfers function as follows:
- The secondary name server starts the process by requesting the SOA record from the primary name server.
- The primary then checks the list of authorized servers, and if the secondary server’s name is on that list, the SOA record is sent.
- The secondary must then check the SOA record to see if there is a match against the SOA it already maintains. If the SOA is a match, the process stops here; however, if the SOA has a serial number that is higher, the secondary will need an update. The serial number indicates if changes were made since the last time the secondary server synchronized with the primary server. If an update is required, the secondary name server will send an All Zone Transfer (AXFR) request to the primary server.
- Upon receipt of the AXFR, the primary server will send the entire zone file to the secondary name server.
Some common DNS resource record names and types are shown in Table 3.3.
Table 3.3. DNS Records and Types
Record Name | Record Type | Purpose |
Host | A | Maps a domain name to an IP address |
Pointer | PTR | Maps an IP address to a domain name |
Name Server | NS | Configures settings for zone transfers and record caching |
Start of Authority | SOA | Configures settings for zone transfers and record caching |
Service Locator | SRV | Used to locate services in the network |
MX | Used to identify SMTP servers |
A zone transfer is unlike a normal lookup in that the user is attempting to retrieve a copy of the entire zone file for a domain from a DNS server. This can provide a hacker or pen tester with a wealth of information. This is not something that the target organization should be allowing. Unlike lookups that primarily occur on UDP 53, unless the response is greater than 512 bytes, zone transfers use TCP 53. To attempt a zone transfer, you must be connected to a DNS server that is the authoritative server for that zone. Remember the nslookup information we previously gathered? It’s shown here again for your convenience.
Registrant:
Pearson Technology Centre
Kenneth Simmons
200 Old Tappan Rd .
Old Tappan, NJ 07675 USA
Email: billing@superlibrary.com
Phone: 001-201-7846187
Registrar Name....: REGISTER.COM, INC.
Registrar Whois...: whois.register.com
Registrar Homepage: www.register.com
DNS Servers:
usrxdns1.pearsontc.com
oldtxdns2.pearsontc.com
Review the last two entries. Both usrxdns1.pearsontc.com and oldtxdns2.pearsontc.com are the DNS authoritative servers for ExamCram.com. These are the addresses that an attacker will target to attempt a zone transfer. The steps to try and force a zone transfer are shown here:
- nslookup—Enter nslookup from the command line.
- server <ipaddress>—Enter the IP address of the authoritative server for that zone.
- set type = any—Tells nslookup to query for any record.
- ls –d <domain.com>—Domain.com is the name of the targeted domain of the final step that performs the zone transfer.
One of two things will happen at this point; either you will receive an error message indicating that the transfer was unsuccessful, or you will be returned a wealth of information, as shown in the following:
C:\WINNT\system32>nslookup
Default Server: dnsr1.sbcglobal.net
Address: 128.112.3.12
server 172.6.1.114
set type=any
ls -d example.com
example.com. SOA hostmaster.sbc.net (950849 21600 3600 1728000 3600)
example.com. NS auth100.ns.sbc.net
example.com. NS auth110.ns.sbc.net
example.com. A 10.14.229.23
example.com. MX 10 dallassmtpr1.example.com
example.com. MX 20 dallassmtpr2.example.com
example.com. MX 30 lasmtpr1.example.com
lasmtpr1 A 192.172.243.240
dallassmtpr1 A 192.172.163.9
dallaslink2 A 192.172.161.4
spamassassin A 192.172.170.49
dallassmtpr2 A 192.172.163.7
dallasextra A 192.172.170.17
dallasgate A 192.172.163.22
lalink A 172.16.208.249
dallassmtp1 A 192.172.170.49
nygate A 192.172.3.250
www A 10.49.229.203
dallassmtp MX 10 dallassmtpr1.example.com
dallassmtp MX 20 dallassmtpr2.example.com
dallassmtp MX 30 lasmtpr1.example.com
This type of information should not be made available to just anyone. Hackers can use this to find out what other servers are running on the network, and it can help them map the network and formulate what types of attacks to launch. Notice the first line that has example.com listed previously. Observe the final value of 3600 on that line. That is the TTL value discussed previously which would inform a hacker as to how long DNS poisoning would last. 3,600 seconds is 60 minutes. Zone transfers are intended for use by secondary DNS servers to synchronize with their primary DNS server. You should make sure that only specific IP addresses are allowed to request zone transfers. Although most Operating Systems restrict this by default, Windows 2000 did not. So, be aware of this if any 2000 servers are still in your network.
Determining the Network Range
Objective:Locate the network range
Now that the pen test team has been able to locate name, phone numbers, addresses, some server names, and IP addresses, it’s important to find out what range of IP addresses are available for scanning and further enumeration. If you take the IP address of a web server discovered earlier and enter it into the Whois lookup at www.arin.net, the network’s range can be determined. As an example, 192.17.170.17 was entered into the ARIN Whois, and the following information was received:
OrgName: target network
OrgID: Target-2
Address: 1313 Mockingbird Road
City: Anytown
StateProv: Tx
PostalCode: 72341
Country: US
ReferralServer: rwhois://rwhois.exodus.net:4321/
NetRange: 192.17.12.0 - 192.17.12.255
CIDR: 192.17.0.0/24
NetName: SAVVIS
NetHandle: NET-192-17-12-0-1
Parent: NET-192-0-0-0-0
This means that the target network has 254 total addresses. The attacker can now focus his efforts on the range from 192.17.12.1 to 192.17.12.254 /24. If these results don’t prove satisfactory, traceroute can be used for additional mapping.
Traceroute
Objective:Specify how traceroute works
The traceroute utility is used to determine the path to a target computer. Just as with nslookup, traceroute is available on Windows and UNIX platforms. In Windows, it is known as tracert because of 8.3 legacy filename constraints remaining from DOS. Traceroute was originally developed by Van Jacobson to view the path a packet follows from its source to its destination. Traceroute owes its functionality to the IP header time-to-live (TTL) field. You might remember from the discussion in Chapter 2, “The Technical Foundations of Hacking,” that the TTL field is used to limit IP datagram’s. Without a TTL, some IP datagram’s might travel the Internet forever as there would be no means of timeout. TTL functions as a decrementing counter. Each hop that a datagram passes through reduces the TTL field by one. If the TTL value reaches 0, the datagram is discarded and a time exceeded in transit Internet Control Message Protocol (ICMP) message is created to inform the source of the failure. Linux tracer-oute is based on UDP, whereas Windows uses ICMP.
To get a better idea of how this works, let’s take a look at how Windows would process a tracer-oute. For this example, say that the target is three hops away. Windows would send out a packet with a TTL of 1. Upon reaching the first router, the packet TTL value would be decremented to 0, which would illicit a time exceeded in transit error message. This message would be sent back to the sender to indicate that the packet did not reach the remote host. Receipt of the message would inform Windows that it had yet to reach its destination, and the IP of the device in which the datagram timed out would be displayed. Next, Windows would increase the TTL to a value of 2. This datagram would make it through the first router, where the TTL value would be decremented to 1. Then it would make it through the second router; at which time, the TTL value would be decremented to 0 and the packet would expire. Therefore, the second router would create a time exceeded in transit error message and forward it to the original source. The IP address of this device would next be displayed on the user’s computer. Finally, the TTL would be increased to 3. This datagram would easily make it past the first and second hop and arrive at the third hop. Because the third hop is the last hop before the target, the router would forward the packet to the destination and the target would issue a normal ICMP ping response. The output of this traceroute can be seen here:
C:\>tracert 192.168.1.200
Tracing route to 192.168.1.200:
1 10 ms <10 10="" 192.168.1.200="" 20="" 2="" 3="" complete.="" ms="" pre="" trace="">
Linux-based versions of traceroute work much the same way but use UDP. Traceroute sends these UDP packets targeted to high order port numbers that nothing should be listening on. Just as described previously, the TTL is increased until the target device is reached. Because traceroute is using a high order UDP port, typically 33434, the host should ignore the packets after generating port unreachable messages. These ICMP port unreachable messages are used by traceroute to notify the source that the destination has been reached.
It’s advisable to check out more than one version of traceroute if you don’t get the required results. Some techniques can also be used to try and slip traceroute passed a firewall or filtering device. When UDP and ICMP are not allowed on the remote gateway, TCPTraceroute can be used. Another unique technique was developed by Michael Schiffman, who created a patch called traceroute.diff that allows you to specify the port that traceroute will use. With this handy tool, you could easily direct traceroute to use UDP port 53. Because that port is used for DNS queries, there’s a good chance that it could be used to slip past the firewall. If you’re looking for a GUI program to perform traceroute with, several are available, which are described here:
- NeoTrace— NeoTrace is a powerful tool for mapping path information. The graphical display shows you the route between you and the remote site, including all intermediate nodes and their registrant information. NeoTrace is probably the most well-known GUI traceroute program. Along with a graphical map, it also displays information on each node such as IP address, contact information, and location. NeoTrace can be seen in Figure 3.6. That trace shows the results of a traceroute to Microsoft.com. Just remember that NeoTrace builds from provided information that is entered into the routers, and it might not always be accurate.
- Trout— Trout is another visual traceroute and Whois program. What’s great about this program is its speed. Unlike traditional traceroute programs, trout performs parallel pinging. By sending packets with more than one TTL at a time, it can quickly determine the path to a targeted device.
- VisualRoute— VisualRoute is another graphical traceroute for Windows. VisualRoute not only shows a graphical world map that displays the path packets are taking, but it also lists information for each hop, including IP address, node name, and geographical location.
Traceroute and ping are useful tools for identifying active systems, mapping their location, and learning more about their location. To learn more about these tools, take a few moments to complete the following challenge exercise:
Identifying Active Machines
Objective:
Identify active machines
Attackers will want to know if machines are alive before they attempt to attack. One of the most basic methods of identifying active machines is to perform a ping sweep. Although ping is found on just about every system running TCP/IP, it has been restricted by many organizations. Ping uses ICMP and works by sending an echo request to a system and waiting for the target to send an echo reply back. If the target device is unreachable, a request time out is returned. Ping is a useful tool to identify active machines and to measure the speed at which packets are moved from one host to another or to get details like the TTL. Figure 3.7 shows a ping capture from a Windows computer. If you take a moment to examine the ASCII decode in the bottom-left corner, you will notice that the data in the ping packet is composed of the alphabet, which is unlike a Linux ping, which would contain numeric values. That’s because the RFC that governs ping doesn’t specify what’s carried in the packet as payload. Vendors fill in this padding as they see fit. Unfortunately, this can also serve hackers as a covert channel. However, hackers can use a variety of programs to place their own information in place of the normal padding. Then what appears to be normal pings are actually a series of messages entering and leaving the network.
Ping does have a couple of drawbacks: First, only one system at a time is pinged and second, not all networks allow ping. To ping a large amount of hosts, a ping sweep is usually performed. Programs that perform ping sweeps typically sweep through a range of devices to determine which ones are active. Some of the programs that will perform ping sweeps include
- Angry IP Scanner
- Pinger
- WS_Ping_ProPack
- Network scan tools
- Super Scan
- Nmap
Finding Open Ports and Access Points
Objective:
Understand how to map open ports and identify their underlying applications
With knowledge of the network range and a list of active devices, the next step is to identify open ports and access points. Identifying open ports will go a long way toward potential attack vectors. There is also the possibility of using war dialing programs to find ways around an organization’s firewall. If the organization is located close by, the attacker might war drive the area to look for open access points.
Port Scanning
Objective:
Describe the differences between TCP and UDP scanning
Port scanning is the process of connecting to TCP and UDP ports for the purpose of finding what services and applications are running on the target device. After running applications, open ports and services are discovered, the hacker can then determine the best way to attack the system.
As discussed in Chapter 2, there are a total of 65,535 TCP and UDP ports. These port numbers are used to identify a specific process that a message is coming from or going to. Some common port numbers are shown in Table 3.6.
Table 3.6. Common Ports and Protocols
Port | Service | Protocol |
20/21 | FTP | TCP |
22 | SSH | TCP |
23 | Telnet | TCP |
25 | SMTP | TCP |
53 | DNS | TCP/UDP |
69 | TFTP | UDP |
80 | HTTP | TCP |
110 | POP3 | TCP |
135 | RPC | TCP |
161/162 | SNMP | UDP |
1433/1434 | MSSQL | TCP |
As you have probably noticed, some of these applications run on TCP, whereas others run on UDP. Although it is certainly possible to scan for all 65,535 TCP and 65,535 UDP ports, many hackers will not. They will concentrate on the first 1,024 ports. These well-known ports are where we find most of the commonly used applications. A list of well-known ports can be found at www.iana.org/assignments/port-numbers. Now, this is not to say that high order ports should be totally ignored because hackers might break into a system and open a high order port, such as 31337, to use as a backdoor. So, is one protocol easier to scan for than the other? Well, the answer to that question is yes. TCP offers more opportunity for the hacker to manipulate than UDP. Let’s take a look at why.
TCP offers robust communication and is considered a connection protocol. TCP establishes a connection by using what is called a 3-way handshake. Those three steps proceed as follows:
- The client sends the server a TCP packet with the sequence number flag (SYN Flag) set and an Initial Sequence Number (ISN).
- The server replies by sending a packet with the SYN/ACK flag set to the client. Thesynchronize sequence number flag informs the client that it would like to communicate with it, whereas the acknowledgement flag informs the client that it received its initial packet. The acknowledgement number will be one digit higher than the client’s ISN. The server will generate an ISN as well to keep track of every byte sent to the client.
- When the client receives the server’s packet, it creates an ACK packet to acknowledge that the data has been received from the server. At this point, communication can begin.
The TCP header contains a one-byte field for the flags. These flags can be seen in Table 3.7.
Table 3.7. TCP Flag Types
Flag | Purpose |
SYN | Synchronize and Initial Sequence Number (ISN) |
ACK | Acknowledgement of packets received |
FIN | Final data flag used during the 4-step shutdown of a session |
RST | Reset bit used to close an abnormal connection |
PSH | Push data bit used to signal that data in the packet should be pushed to the beginning of the queue. Usually indicates an urgent message. |
URG | Urgent data bit used to signify that urgent control characters are present in this packet that should have priority. |
At the conclusion of communication, TCP terminates the session by using a 4-step shutdown. Those four steps proceed as follows:
- The client sends the server a packet with the FIN/ACK flags set.
- The server sends a packet ACK flag set to acknowledge the clients packet.
- The server then generates another packet with the FIN/ACK flags set to inform the client that it also is ready to conclude the session.
- The client sends the server a packet with the ACK flag set to conclude the session.
The TCP system of communication makes for robust communication but also allows a hacker many ways to craft packets in an attempt to coax a server to respond or to try and avoid detection of anintrusion detection system (IDS). Many of these methods are built into Nmap and other port scanning tools, but before taking a look at those tools, some of the more popular port scanning techniques are listed here:
- TCP Connect scan— This type of scan is the most reliable, although it is also the most detectable. It is easily logged and detected because a full connection is established. Open ports reply with a SYN/ACK, whereas closed ports respond with an RST/ACK.
- TCP SYN scan— This type of scan is known as half open because a full TCP three-way connection is not established. This type of scan was originally developed to be stealthy and evade IDS systems although most now detect it. Open ports reply with a SYN/ACK, whereas closed ports respond with a RST/ACK.
- TCP FIN scan— Forget trying to set up a connection; this technique jumps straight to the shutdown. This type of scan sends a FIN packet to the target port. Closed ports should send back an RST. This technique is usually effective only on UNIX devices.
- TCP NULL scan— Sure, there should be some type of flag in the packet, but a NULL scan sends a packet with no flags set. If the OS has implemented TCP per RFC 793, closed ports will return an RST.
- TCP ACK scan— This scan attempts to determine access control list (ACL) rule sets or identify if stateless inspection is being used. If an ICMP destination unreachable, communication administrative prohibited message is returned, the port is considered to be filtered.
- TCP XMAS scan— Sorry, there are no Christmas presents here, just a port scan that has toggled on the FIN, URG, and PSH flags. Closed ports should return an RST.
Certain OSes have taken some liberties when applying the TCP/IP RFCs and do things their own way. Because of this, not all scan types will work against all systems. So, results will vary, but Full Connect scans and SYN scans should work against all systems.
These are not the only types of possible scans; however, they are the more popular types. A few others worth briefly noting include
- IDLE scan— Uses an idle host to bounce packets off of and make the scan harder to trace. It is considered the only totally stealth scan.
- FTP Bounce scan— Uses an FTP server to bounce packets off of and make the scan harder to trace.
- RPC scan— Attempts to determine if open ports are RPC ports.
- Window scan— Similar to an ACK scan, but can sometimes determine open ports.
Now let’s look at UDP scans. UDP is unlike TCP. Although TCP is built on robust connections, UDP is based on speed. With TCP, the hacker has the ability to manipulate flags in an attempt to generate a TCP response or an error message from ICMP. UDP does not have flags, nor does UDP issue responses. It’s a fire and forget protocol! The most you can hope for is a response from ICMP.
If the port is closed, ICMP will attempt to send an ICMP type 3 code 3 port unreachable message to the source of the UDP scan. But, if the network is blocking ICMP, no error message will be returned. Therefore, the response to the scans might simply be no response. If you are planning on doing UDP scans, plan for unreliable results.
Next some of the programs that can be used for port scanning are discussed.
10>
NSLOOKUP
$ nslookup redhat.com
Server: 192.168.19.2
Address: 192.168.19.2#53
Non-authoritative answer:
Name: redhat.com
Address: 209.132.183.181
$ nslookup -query=mx redhat.com
Server: 192.168.19.2
Address: 192.168.19.2#53
Non-authoritative answer:
redhat.com mail exchanger = 10 mx2.redhat.com.
redhat.com mail exchanger = 5 mx1.redhat.com.
Authoritative answers can be found from:
mx2.redhat.com internet address = 66.187.233.33
mx1.redhat.com internet address = 209.132.183.28
nslookup -type=ns redhat.com
Server: 192.168.19.2
Address: 192.168.19.2#53
Non-authoritative answer:
redhat.com nameserver = ns4.redhat.com.
redhat.com nameserver = ns2.redhat.com.
redhat.com nameserver = ns1.redhat.com.
redhat.com nameserver = ns3.redhat.com.
Authoritative answers can be found from:
ns4.redhat.com internet address = 209.132.188.218
ns2.redhat.com internet address = 209.132.183.2
ns1.redhat.com internet address = 209.132.186.218
ns3.redhat.com internet address = 209.132.176.100
$ nslookup -type=any google.com
Server: 192.168.19.2
Address: 192.168.19.2#53
Non-authoritative answer:
Name: google.com
Address: 173.194.35.7
Name: google.com
Address: 173.194.35.8
google.com nameserver = ns1.google.com.
google.com nameserver = ns2.google.com.
google.com
origin = ns1.google.com
mail addr = dns-admin.google.com
serial = 2012071701
refresh = 7200
retry = 1800
expire = 1209600
minimum = 300
google.com mail exchanger = 20 alt1.aspmx.l.google.com.
google.com mail exchanger = 30 alt2.aspmx.l.google.com.
google.com mail exchanger = 40 alt3.aspmx.l.google.com.
google.com mail exchanger = 50 alt4.aspmx.l.google.com.
google.com mail exchanger = 10 aspmx-v4v6.l.google.com.
google.com has AAAA address 2a00:1450:4002:801::1004
Authoritative answers can be found from:
ns4.google.com internet address = 216.239.38.10
ns3.google.com internet address = 216.239.36.10
$ nslookup 209.132.183.181
Server: 192.168.19.2
Address: 192.168.19.2#53
Non-authoritative answer:
181.183.132.209.in-addr.arpa name = origin-www2.redhat.com
Using Specific DNS server
Instead of using default DNS server’s for querying, you can also specify a particular name server to resolve the domain name.
$ nslookup redhat.com ns1.redhat.com
Server: 209.132.186.218
Address: 209.132.186.218#53
Name: redhat.com
Address: 209.132.183.181
Change the port number to connect with
By default DNS servers uses the port number 53. If for any reasons, the port number got changed, then we can specify the port number using -port option$ nslookup -port 56 redhat.com
Change timeout interval to wait for a reply
You can change the default timeout to wait for a reply using -timeout option.$ nslookup -timeout=10 redhat.com
Enabling debug mode using -debug
You can turn on/off the debugging using -debug option in the command line$ nslookup -debug redhat.com
Server: 192.168.19.2
Address: 192.168.19.2#53
------------
QUESTIONS:
redhat.com, type = A, class = IN
ANSWERS:
-> redhat.com
internet address = 209.132.183.181
ttl = 5
AUTHORITY RECORDS:
ADDITIONAL RECORDS:
------------
Non-authoritative answer:
Name: redhat.com
Address: 209.132.183.181
https://mywebclasses.wordpress.com/category/ceh/ceh-02-footprinting-and-reconnaissance/
0 Response to "CEH: The Seven-Step Information Gathering Process"
Post a Comment