Chapter 6

Techniques Used by Hackers

Chapter Objectives

After reading this chapter and completing the exercises, you will be able to do the following:

  • A shaded box with a faded outline. Understand the basic methodology used by hackers

  • A shaded box with a faded outline. Be familiar with some of the basic hacking tools

  • A shaded box with a faded outline. Understand the hacking mentality

  • A shaded box with a faded outline. Be able to explain specific attack methods

Introduction

The first five chapters introduced you to general security concepts. Now it is time to explore the techniques that are used to attack your network. If you do not know what the adversary knows, it is very difficult to truly secure your network. Before going any further, it is important to realize that many hackers are not criminals. A hacker is a person who wants to understand a system, often by probing its weaknesses. There are even hackers who work for organizations, testing the organizations’ system security. This is called penetration testing and also sometimes white hat hacking. There are several certifications for penetration testing:

There is also a magazine for white hat hackers called 2600 (www.2600.com). Many computer security professionals attempt to learn hacking techniques either to enhance their security capabilities or to simply satisfy their curiosity. The techniques themselves are not criminal. However, there are people who use hacking techniques to breach systems to steal data, damage systems, or commit other cybercrimes. These people are usually referred to as black hat hackers or crackers.

The techniques presented in this chapter are presented not only to give you an understanding of how black hat hackers work but to show how you can perform penetration testing on your own network. By attempting some of these techniques on your network, you can assess your vulnerability. (It should be pointed out that you should only do this when you are very comfortable with the techniques in this chapter—and only with permission from senior management.)

Basic Terminology

Before we can delve into the world of hacking, we need to discuss the basic terminology used in this community. As you already know, the term white hat hacker is used to describe a person who uses hacking techniques for legal/ethical purposes. And the terms black hat hacker and cracker are used to describe a person who uses hacking techniques for illegal purposes.

There are a few other terms you should be familiar with. A gray hat hacker is one who was previously a black hat hacker and turned into a white hat hacker (basically, a former criminal now turned ethical). With the proliferation of tools on the Internet, there are also a lot of people who download tools (some of which we will examine in this chapter) and perform cyber attacks without really understanding what they are doing. These people are termed script kiddies (also sometimes spelled kiddys). Another important term, phreaking, refers to hacking into phones (which predates hacking into computer systems).

Often penetration testing is conducted to emulate a specific adversary or type of adversary. This is done by a red team. For example, if an organization is concerned primarily about nation-state attacks, then a red team can conduct a penetration test utilizing the same techniques that are commonly used in nation-state attacks. In contrast to the red team is the blue team, which is the defensive team attempting to stop the red team’s attack.

The Reconnaissance Phase

Any intelligent/experienced hacker is going to attempt to find out information about a target before actually attempting an attack. Just as a bank robber would want to know about a bank’s alarm systems, number of guards, police response time, and so on, a black hat hacker would want to know about your system’s security. What may surprise you is how much information can be found easily on the Internet without even attaching to the target system.

Passive Scanning Techniques

One of the easiest things a hacker can do is check the target organization’s websites. Businesses commonly post information that can be very useful to an attacker. For example, let’s assume that company XYZ lists John Doe as its IT manager. An enterprising hacker can scan bulletin boards and discussion groups for references to John Doe at XYZ. That attacker might find information useful in spear phishing attacks (that is, phishing targeted at a specific individual or group of individuals), or the attacker might find information useful in social engineering. For example, a number of former employees might have complained online that John Doe is demanding and quick to fire people. An enterprising hacker could call someone at XYZ claiming to be working for John Doe. The hacker might claim that he is trying to log on remotely to that person’s computer to update her system. After a few moments, the hacker tells the person he forgot the password John Doe gave him and is very concerned he will get fired if he doesn’t complete this assignment; then he asks that person for his password. The information the attacker gleaned from the Web gave him enough information to make this social engineering attack plausible.

It is also possible for an attacker to scan bulletin boards, chat rooms, discussion groups, and other places, looking for questions from IT staff at the target organization. For example, if an administrator posts in a discussion group asking about a particular server problem, this can give the attacker valuable information about that target network.

Another way attackers can use the Web to find out information about a target is through job ads. For example, if a company routinely advertises for ASP.NET developers and never for PHP or Perl, then it is likely that the company’s web applications are developed with ASP.NET running on a Windows web server (Internet Information Services). This can allow the attacker to focus only on a small group of possible attacks—those against ASP.NET/Windows.

Information can also be garnered from job ads. For example, if a small company with fewer than 200 employees has an advertisement for a network administrator twice a year, it is likely that the company has recently lost its old administrator because a small company would not need multiple administrators. If the current administrator is new, it means she is probably not as familiar with her own systems as the old admin. Also, if this trend of advertising for new administrators extends over a couple of years, the hacker can guess that the company has high turnover, and there is some problem the attacker may be able to exploit.

There are also specific websites that provide information an attacker may find useful. For example, netcraft.com, shown in Figure 6.1, provides information about websites. For example, you can find out what kind of server a site is running, and in some cases how long it has been since the server was last rebooted.

A window displays the site information of www.chuckeasttom.com.

Figure 6.1 www.netcraft.com.

Another site that can be useful for attackers is https://archive.org. This site, shown in Figure 6.2, archives older versions of websites. The server scours the Web, archiving sites. The frequency with which a site is archived depends on its popularity.

A screenshot displays the archive of older versions of the website.

Figure 6.2 www.archive.org.

Active Scanning Techniques

The previously mentioned techniques are all considered passive, as they do not require the attacker to connect to the target system. Since the attacker is not actually connecting to the target system, it is impossible for an intrusion detection system (IDS) to detect the scan. Active scans are far more reliable but may be detected by the target system. There are a few types of active scans.

Port Scanning

Port scanning is the process of attempting to contact each network port on the target system and see which ones are open. There are 1024 well-known ports that are usually associated with specific services. For example, port 161 is associated with Simple Network Management Protocol (SNMP). If an attacker detects port 161 open on the target system, he might decide to try SNMP-related attacks. Even more information can be derived from a port scan. For example, ports 137, 138, and 139 are all associated with NetBIOS, a very old Windows method of network communication that is not used in Windows anymore. However, NetBIOS is often used for systems where Windows machines need to communicate with Linux machines, so discovering those ports open reveals something about the target network.

A simple Google search for port scanner will reveal a host of well-known, widely used, and often free port scanners. However, the most popular port scanner in the hacking and security community is the free tool Nmap (https://nmap.org). There is a Windows version of it, called Zenmap, as shown in Figure 6.3.

A screenshot displays Zenmap GUI.

Figure 6.3 Zenmap GUI.

Nmap allows you to customize a scan to make it more or less stealthy and to target certain systems. The most common types of scans are listed here:

  • A shaded box with a faded outline. Ping scan: This scan simply sends a ping to the target port. Many network administrators block incoming ICMP packets for the purpose of stopping ping scans.

  • A shaded box with a faded outline. Connect scan: This is the most reliable scan but also the type most likely to be detected. With this type of scan, a complete connection is made with the target system.

  • A shaded box with a faded outline. SYN scan: This scan is very stealthy. Most systems accept SYN (synchronize) requests. This scan is similar to the SYN flood DoS attack described in Chapter 4, “Denial of Service Attacks.” In this type of scan, you send a SYN packet but never respond when the system sends a SYN/ACK. However, unlike with a DoS SYN flood, you send only one packet per port. This is also called a half-open scan.

  • A shaded box with a faded outline. FIN scan: This scan has the FIN (connection finished) flag set. This is not an unusual packet for systems to receive, so it is considered stealthy.

Each of these scans provokes a different response on the target machine and thus provides different information to the port scanner:

  • A shaded box with a faded outline. With a FIN scan or an XMAS scan, if the target port is closed, the system sends back an RST (reset) flag packet. If it is open, there is no response.

  • A shaded box with a faded outline. With a SYN scan, if the port is closed, the response is an RST; if it is open, the response is a SYN/ACK.

  • A shaded box with a faded outline. ACK scans and NULL scans work only on UNIX systems.

Nmap also lets you set a number of flags (either with the command line version of Nmap or the Windows version) to customize the scan. The allowed flags are listed here:

-O Detects the operating system

-sP Ping scan

-sT TCP connect scan

-sS SYN scan

-sF FIN scan

-sX Xmas tree scan

-sN NULL scan

-sU UDP scan

-sO Protocol scan

-sA ACK scan

-sW Windows scan

-sR RPC scan

-sL List/DNS scan

-sI Idle scan

-Po Don’t ping

-PT TCP ping

-PS SYN ping

-PI ICMP ping

-PB TCP and ICMP ping

-PM ICMP netmask

-oN Normal output

-oX XML output

-oG Greppable output

-oA All output

-T Timing

-T0 Paranoid

-T1 Sneaking

-T2 Polite

-T3 Normal

-T4 Aggressive

-T5 Insane

As you can see, there are a number of options available to an attacker using Nmap. One can spend a lot of time just learning Nmap.

Note

There are, of course, a number of other port scanning tools. We have focused on Nmap because it is free and widely used. It also figures prominently on the EC-Council Certified Ethical Hacker certification, GPEN (from SANS), and the Professional Penetration Tester certification.

The Nmap settings are, for the most part, self-explanatory. Perhaps the timing warrants a bit more discussion, however. Timing involves how quickly to send scanning packets. Essentially, the faster you send packets, the more likely the scan is to be detected.

Here is the most basic Nmap scan:

nmap 192.168.1.1

Here is a scan of a range of IP addresses:

nmap 192.168.1.1-20

The following command scans to detect operating system, use TCP scan, and use sneaky speed:

nmap -O -PT -T1 192.168.1.1
Other Scans

There are a wide range of scans an attacker can use to probe your network. It is often a good idea to look at logs for any evidence that such scans are being conducted against your network. Even if an attacker is not successful in breaching your system, the fact that he or she has attempted to do so makes it likely the attacker will try again.

These are a few of the scans an attacker may use to probe your network:

  • A shaded box with a faded outline. FIN probe: A FIN packet is sent to an open port, and the response is recorded. Although the standard for the FIN flag (RFC 793) states that the required behavior is not to respond, many operating systems such as Windows will respond with an RST.

  • A shaded box with a faded outline. FTP bounce scan: This scan bounces scan packets off an FTP server, which makes the scan harder to trace.

  • A shaded box with a faded outline. SNMP scan: Simple Network Management Protocol (SNMP) is a popular protocol for remote monitoring and management on a network. It’s used to report the status of services and devices. It works through a system of agents and nodes. SNMP is designed so that requests are sent to agents, and the agents send back replies. The requests and replies refer to configuration variables that are accessible by agent software. Traps are used to signify an event that might be of interest. This can be anything from a simple reboot to some system failure. SNMP makes use of the Management Information Base (MIB), which is the database of configuration variables that resides on the networking device. SNMP uses UDP port 161.

Vulnerability Assessment

Vulnerability assessment involves checking a system to see if it is vulnerable to specific attacks. Although hackers can use vulnerability assessment tools to assess your system, these tools are designed to allow you to assess your system. These tools are not particularly stealthy and thus will probably be detected by an intrusion detection system. In fact, network administrators commonly use vulnerability assessment tools to test their own networks. These tools will be covered in Chapter 11, “Network Scanning and Vulnerability Scanning.”

Enumeration

Another technique that is commonly used before an actual attack is enumeration. Enumeration is simply the process of finding out what is on the target system. If the target is an entire network, the attacker wants to find out what servers, computers, and printers are on that network. If the target is a specific computer, the attacker wants to find out what users and shared folders exist on that system.

A simple Google search will help you find a number of enumeration tools. One of the easiest to use is Cain and Abel, shown in Figure 6.4.

A screenshot depicts the Cain and Abel tool.

Figure 6.4 Cain and Abel.

Although we are focusing on enumeration here, Cain and Abel can do a lot more than just enumeration. To use Cain and Able for enumeration, simply click on the Network tab, and you will find all the machines connected to the network you are on. (You obviously need some level of access before you can enumerate the target network.)

The following are a few other enumeration tools that are popular with hackers and can easily be found on the Internet:

  • A shaded box with a faded outline. Sid2User

  • A shaded box with a faded outline. Cheops (Linux only)

  • A shaded box with a faded outline. UserInfo

  • A shaded box with a faded outline. UserDump

  • A shaded box with a faded outline. DumpSec

  • A shaded box with a faded outline. Netcat

  • A shaded box with a faded outline. NBTDump

This is not an exhaustive list, but it includes some of the most widely used enumeration tools.

To defend against scanning, you should use the following techniques:

  • A shaded box with a faded outline. Be careful how much information you put on the Internet about your organization and its network.

  • A shaded box with a faded outline. Create a company policy mandating that technical personnel who use bulletin boards, chat rooms, and so on for technical data not use their real names or reveal the company’s name.

  • A shaded box with a faded outline. Use an IDS that detects many scans.

  • A shaded box with a faded outline. Block incoming Internet Control Message Protocol (ICMP) packets.

These techniques won’t make scanning and reconnaissance on your system impossible, but they will significantly reduce the amount of information an attacker can gather.

Shodan

Shodan (see Figure 6.5) is a tool used by attackers and penetration testers alike. The website https://www.shodan.io is essentially a search engine for vulnerabilities. You need to sign up for a free account to use it, but then it can be invaluable to a pen tester trying to identify vulnerabilities. Of course, the site can also be invaluable to attackers.

A screenshot displays Shodan tool.

Figure 6.5 Shodan.

There are many options you can use in searching with Shodan.io; some are given here:

  • A shaded box with a faded outline. Search for default passwords, using search terms such as the following:

    • A shaded box with a faded outline. default password country:US

    • A shaded box with a faded outline. default password hostname:chuckeasttom.com

    • A shaded box with a faded outline. default password city:Chicago

  • A shaded box with a faded outline. Find Apache servers:

    • A shaded box with a faded outline. apache city: “San Francisco”

  • A shaded box with a faded outline. Find webcams:

    • A shaded box with a faded outline. webcamxp city:Chicago

    • A shaded box with a faded outline. OLD IIS

    • A shaded box with a faded outline. “iis/5.0”

In addition to these search terms, you can use filters, including these:

  • A shaded box with a faded outline. city: Find devices in a specific city.

  • A shaded box with a faded outline. country: Find devices in a specific country.

  • A shaded box with a faded outline. geo: Pass coordinates (that is, latitude and longitude).

  • A shaded box with a faded outline. hostname: Find values that match a specific hostname.

  • A shaded box with a faded outline. net: Search based on an IP or /x CIDR address.

  • A shaded box with a faded outline. os: Search based on operating system.

  • A shaded box with a faded outline. port: Find particular ports that are open.

  • A shaded box with a faded outline. before/after: Find results within a time frame.

For example, Figure 6.6 shows the results of a search for default passwords city:dallas.

A screenshot for Shodan search result is shown.

Figure 6.6 Shodan search results.

When you are performing a penetration test, it is a good idea to search the company domain for anything you can find via Shodan. You can restrict your search to the hostname or domain name of the client who has hired you to conduct a penetration test. You can use Shodan to seek out default passwords, old web servers, unsecured web cameras, and other vulnerabilities in the target network. Again, you can be sure that would-be attackers will also use this tool.

Actual Attacks

Now that we have discussed how attackers scan a target system, let’s look at a few attacks that are commonly used. Obviously this isn’t an exhaustive list, but it provides some insight into the attack methodologies used. In Chapter 4 we discussed denial of service (DoS) attacks and some tools used to perpetrate these attacks. In this section we will look at other sorts of attacks and the techniques and tools used to make them happen.

SQL Script Injection

SQL script injection might be the most popular type of attack on websites. In recent years, more websites have taken steps to mitigate the dangers of these attacks, but unfortunately, many websites are still susceptible. An SQL script injection attack involves passing Structured Query Language (SQL) commands to a web application and getting the website to execute them.

Before we can discuss SQL injection further, we must talk about SQL and relational databases. Relational databases are based on relations between various tables. The structure includes tables, primary and foreign keys, and relations:

  • A shaded box with a faded outline. Each row represents a single entity.

  • A shaded box with a faded outline. Each column represents a single attribute.

  • A shaded box with a faded outline. Each record is identified by a unique number called a primary key.

  • A shaded box with a faded outline. Tables are related by foreign keys. A foreign key is a primary key in another table.

You can see an example of these relations in Figure 6.7.

The database relation between two tables are compared.

Figure 6.7 Database relations.

All relational databases use SQL, which includes commands such as SELECT, UPDATE, DELETE, INSERT, and WHERE. At least the basic queries are very easy to understand and interpret.

Most basic SQL injection works like this: Many websites/applications have a page where a user enters a username and password. That username and password will have to be checked against some database to see if they are valid. Regardless of the type of database (Oracle, SQL Server, MySQL), all databases speak SQL. SQL looks and functions a great deal like English. For example, to check a username and password, you might want to query the database to see if there is any entry in the users table that matches the username and password that was entered. If there is such an entry, you have a match. The SQL statement to ask this might look something like this:

'SELECT * FROM tblUsers WHERE USERNAME = 'jdoe' AND PASSWORD = 'letmein'

The problem with this query is that, although it is valid SQL, it hard codes the username and password. For a real website, you would have to take whatever the user entered into the username field and password field and check that. This can be easily done (regardless of what programming or scripting language the website is programmed in). It would look something like this:

'SELECT * FROM tblUsers WHERE USERNAME = '" + txtUsername.Text +' AND PASSWORD = '" +
txtPassword.Text +"'".

If you enter username jdoe and password letmein, this code produces the following SQL command:

SELECT * FROM tblUsers WHERE USERNAME = 'jdoe' AND PASSWORD = 'letmein'

Now if there is a username jdoe in tblUsers, and the password for it is letmein, then this user will be logged on. If not, then an error will occur.

SQL injection works by putting some SQL into the username and password block that is always true. For example, suppose you enter 'OR X=X' into the username and password boxes. This will cause the program to create this query:

SELECT * FROM tblUsers WHERE USERNAME = ''OR X=X' AND PASSWORD = ''OR X=X'

Notice that you start with a single quotation mark (') before the OR X=X. This closes the open quote the attacker knows must be in the code. And if you see '', that essentially is a blank or null, and it tells the database to log you in if the username is blank, or if X=X, and if the password is blank, or if X=X. If you think about this for a second, you will see that X always equals X, so this will always be true.

There is no significance to 'OR X=X'; it is simply a statement that will always be true. Attackers try other similar statements, such as the following:

' or 'a' ='a
' or '1' ='1
' or (1=1)

The example given here is the most basic version of SQL injection, but it is the most common. You can do far more with SQL injection. The attacker is limited only by her knowledge of SQL and the target database system.

The defense against this type of attack is to filter all user input before processing it. This process, often referred to as input validation, prevents an attacker from entering SQL commands rather than a username and password. Unfortunately, many sites do not filter user input and are still vulnerable to SQL injection attacks.

Remember that earlier in the text when we first, briefly, mentioned SQL injection, it was suggested that filtering input could prevent such an attack. For example, a programmer creating a website should write the code to first check for any common SQL injection symbols such as the single quote ('), percent sign (%), equal sign (=), or ampersand (&), and if those are found, stop processing and log an error. This would prevent many SQL injection attacks. There are methods to circumvent these security measures, but implementing them would, nonetheless, stop many SQL injection attacks.

Cross-Site Scripting

With cross-site scripting, an attacker injects client-side scripts into web pages viewed by other users. The key is that the attacker enters scripts into an area that other users interact with. When users go to that part of the site, the attacker’s script, rather than the intended website functionality, is executed. For example, say that a shopping site allows users to review products. Rather than typing in a review, an attacker might type in JavaScript that redirects the user to a phishing website. When another user views that “review,” the script executes and takes the user to the new site. Again, such attacks can be prevented by simply filtering all user input. As of this writing, all the major online shopping portals, such as Amazon.com, do filter input and are not susceptible to this attack. However, many smaller sites are still susceptible to cross-site scripting.

Cross-site scripting and SQL injection both illustrate why it is critical that all IT personnel, not just security administrators, be familiar with security. If more web developers were more familiar with security, these two attacks would not be widespread.

Cross-Site Request Forgery

Cross-site request forgery could be viewed as the other side of cross-site scripting. Whereas cross-site scripting attacks the user, based on the user’s trust of a website, cross-site request forgery attacks the website, based on the site’s trust of a user. The trusted user, who is authenticated to the website, is tricked into sending requests to the website. These requests can then be used to attack the website.

Directory Traversal

Directory traversal allows attackers to access restricted directories—including those containing application source code, configuration files, and critical system files—and execute commands outside the web server’s root directory.

Attackers can manipulate variables that reference files with “dot-dot-slash” (../) sequences and variations, as in these examples:

http://www.example.com/process.aspx=../../../../some dir/some file
http://www.example.com/../../../../some dir/some file

Cookie Poisoning

Many web applications use cookies in order to save information (user ID, timestamp, and so on) on the client’s machine. For example, when a user logs in to a site, a login web script may validate his username and password and set a cookie with his numerical identifier.

When the user checks his preferences later, another web script (say, preferences.asp) retrieves the cookie and displays the user information records of the corresponding user. Because cookies are not always encrypted, they can be modified; an attack that includes this type of modification is called cookie poisoning. In fact, JavaScript can modify, write, or read a cookie. So this type of attack can be combined with cross-site scripting.

URL Hijacking

URL hijacking, also called typosquatting, involves a fake URL that is very close to a real one. For example, my website is www.Chuckeasttom.com. Someone might set up the site www.Chuckeastom.com, with only one t in the last name.

Command Injection

A command injection attack is designed to inject and execute commands specified by the attacker in a vulnerable application. Command injection attacks occur because of lack of correct input data validation, which also can be manipulated by the attacker (in forms, cookies, HTTP headers, and so on). As an example, with Linux, you can execute two commands by typing one after another, like this:

#cmd1 && cmd2

Therefore, a vulnerable application could execute the following:

www.google.com && cat /etc/passwd

Sometimes command injection is referred to as shell injection.

Wireless Attacks

A number of wireless attacks are commonly used. For example, with an evil twin attack, a rogue wireless access point (WAP) is set up that has the same SSID as one of your legitimate access points. That rogue WAP might be used to initiate a denial of service attack on your legitimate access point, making it unable to respond to users, so they are redirected to the evil twin.

Another wireless attack is the WPS attack. Wi-Fi Protected Setup (WPS) requires a PIN to connect to the WAP. The WPS attack attempts to intercept that PIN in transmission, connect to the WAP, and then steal the WPA2 password.

A deauthentication attack can cause legitimate wireless clients to deauthenticate from legitimate wireless APs or wireless routers to either perform a denial of service condition or to make those clients connect to an evil twin.

Cell Phone Attacks

There are many ways to attack cell phones. The most common attacks are briefly described here:

  • A shaded box with a faded outline. Bluesnarfing: Unauthorized access of information from a Bluetooth device.

  • A shaded box with a faded outline. Blue jacking: The process of using another Bluetooth device that is within range (depending on the version of Bluetooth it could be 10 to 240 meters) to send unsolicited messages to the target.

  • A shaded box with a faded outline. Bluebugging: Unauthorized access and use of using all phone features.

  • A shaded box with a faded outline. Pod slurping: Use of a device such as an iPod to illicitly steal confidential data by directly plugging it into a computer where the data is held.

Password Cracking

Doing password cracking is easiest when one can actually get physical access to a machine—and this is not as difficult as it sounds. Many organizations (such as universities) have kiosk machines where someone can use the system with minimal/guest privileges. A skilled hacker can use this access to gain further access.

Password Cracking Methods

There are several different approaches to password cracking. The more common approaches are listed here:

  • A shaded box with a faded outline. Dictionary attacks: A text file full of dictionary words is loaded into a password program and then run against user accounts located by the application. If simple passwords have been used, this might be enough to crack the code. Dictionary attacks can be performed offline with tools like LCP and Hashcat and online with tools like Brutus and THC-Hydra.

  • A shaded box with a faded outline. Hybrid attacks: This type of attack is similar to a dictionary attack except that it adds numbers or symbols to the dictionary words. Many people change their passwords by simply adding a number to the end of their current password. The pattern usually takes this form: First month’s password is Mike, second month’s password is Mike2, third month’s password is Mike3, and so on.

  • A shaded box with a faded outline. Rainbow table: Passwords are often stored as a hash. A hash cannot be “unhashed”; however, one can make tables of widely used passwords and hash those. Then if one can get access to the hash of a password, one can search the rainbow table for a match.

  • A shaded box with a faded outline. Brute-force attacks: This is the most comprehensive form of attack and the most potentially time-consuming. Brute-force attacks can take weeks, depending on the length and complexity of the password.

ophcrack

A very popular tool for cracking Windows passwords is ophcrack. ophcrack can be downloaded from http://ophcrack.sourceforge.net. It is based on an understanding of how Windows passwords work. Windows passwords are stored as hashes in a SAM file in one of the system directories, usually C:WINDOWSsystem32config. SAM is an acronym for Security Accounts Manager. The passwords are stored as a hash. (Hashes will be discussed in detail in Chapter 8, “Encryption.”) Windows hashes the password you type in and compares it to the hash found in the SAM file. If there is a match, then you are logged in. To prevent someone from copying the SAM file and taking it off to try to brute-force it, as soon as Windows begins the boot process, the operating system locks the SAM file. ophcrack boots to Linux and then gets the SAM file and looks up the hashed passwords in a large table of hashed values it has, searching for a match. If it finds one, then the matching text in that table of hashed values is the password. You can see ophcrack in Figure 6.8.

A screenshot displays Ophcrack.

Figure 6.8 ophcrack.

This tool is remarkably easy to use. Just put the ophcrack CD into the machine and reboot. During the boot process, you can press F12 for a boot menu and tell the system to boot from CD. You will then start ophcrack. It should be noted that longer passwords (as of this writing, longer than 10 characters) are usually not crackable by ophcrack.

If ophcrack is successful (though it isn’t always), what can the attacker now do? At best she simply got the local machine admin account and not a domain account. Well, this can be used to then gain domain access. One such method of obtaining domain access will be explored later in this chapter in the “Net User Script” section.

Other Password Cracking Tools

As you probably can guess, there are many password cracking tools one can get from the Internet. A few common tools are listed here:

  • A shaded box with a faded outline. Brutus: Brutus can perform remote dictionary or brute-force attacks against Telnet, FTP, SMTP, and web servers.

  • A shaded box with a faded outline. John the Ripper: This tool has been around for many years. It is an effective password cracking tool.

  • A shaded box with a faded outline. WebCracker: This simple tool takes text lists of usernames and passwords and uses them as dictionaries to implement basic authentication password guessing.

  • A shaded box with a faded outline. THC-Hydra: This very useful web password-cracking tool attacks many common authentication schemes.

  • A shaded box with a faded outline. Crack Station: The website for this tool, https://crackstation.net, attempts to match a hashed password with a known password in a rainbow table.

Malware Creation

In this section we will briefly discuss how easy it is to create malware. In Chapter 5, “Malware,” you saw the tool eLiTeWrap. In this section you will see the methods used to actually create viruses. This is not in any way an encouragement for you to create such viruses. It is meant to educate you on why such malware is so common.

For many years, one needed significant programming skills in order to create a virus. However, in recent years there have been a number of tools developed to create viruses. These tools allow the end user to click a few buttons and create a virus. This is one reason viruses are becoming so prevalent. One such tool is TeraBIT Virus Maker, shown in Figure 6.9.

A screenshot displays TeraBIT virus maker.

Figure 6.9 TeraBIT Virus Maker.

Tools like this make it very easy for even a novice to create a virus. When tools that automate some specific computer attack become prevalent, then one can expect a great many more such attacks.

You can easily see from the options that TeraBIT Virus Maker can create some rather damaging malware. It is important to realize that this is only one option that a malware creator has. There are a number of tools on the Internet that help create viruses. There are even ransomware development kits. A few common utilities for making malware are as follows:

  • A shaded box with a faded outline. Sam’s Virus Generator

  • A shaded box with a faded outline. Internet Worm Maker Thing

  • A shaded box with a faded outline. JPS Virus Maker

  • A shaded box with a faded outline. Deadlines Virus Maker

  • A shaded box with a faded outline. Sonic Bat Virus Creator

In addition to these tools, there are websites that contain catalogs of malware code. Anyone with only moderate programming skills can download the code for a virus and modify that malware for his specific needs. You can think of this as a sort of cyber weapons proliferation.

This proliferation of cyber weapons is the primary reason for this section in this chapter. It is critical that security professionals (and aspiring security professionals) be aware of just how easy it is to create a virus. We should reasonably expect to see more viruses as time goes on. Of course, there are still custom written viruses, and these are in fact the most effective form of malware. But the proliferation of tools and source code means that even those with only minimal technical skills can create viruses.

Windows Hacking Techniques

Given the ubiquitous nature of Microsoft Windows, it should be no surprise that there are a wide range of attacks specifically aimed at that operating system. In this section, we will briefly look at some of them.

Pass the Hash

We will examine cryptographic hashes at some length in Chapter 8. For now, you can just accept that many systems store passwords as cryptographic hashes. This is done because it is impossible to “unhash” something.

A pass the hash attack essentially realizes that the hash cannot be reversed; rather than trying to find out what the password is, the attacker just sends over the hash. If the attacker can obtain valid username and user password hash values, then the hacker can use that hash without ever knowing the actual password.

Windows applications ask users to type in their passwords; then the application in turn hashes them. Often the hashing can be done with an API like LsaLogonUser, converting the password to either an LM hash or an NT hash. Pass the hash skips around the application and just sends the hash.

Net User Script

A net user script exploit first requires access to the target machine with at least guest-level privileges. It is based on the fact that many organizations put the technical support personnel in the domain admin’s group.

The attacker writes the following two-line script (where the word localaccountname is replaced with an actual local account name):

net user /domain /add localaccountname password
net group /domain "Domain Admins" /add Domain

The attacker saves this script in the All Users startup folder. The next time someone with domain admin privileges logs on to the machine, it will execute, and localaccountname will now be a domain admin. The only problem is that it may be quite some time before someone with such privileges logs onto that machine. To speed up the process, the attacker will cause a problem with the system that would necessitate technical support fixing it, such as disabling the network card. The next user to log in will not be able to access the network or Internet and will call technical support. There is a reasonably good chance that the person in technical support is a member of the domain administrators group. When that person logs on to the computer to fix the problem, unbeknownst to her, the script will execute.

This particular exploit illustrates two different security issues. The first is the concept of least privileges, which means allowing each user only the minimum privileges to do his job. (This concept was discussed briefly in Chapter 1, “Introduction to Computer Security.”) Technical support personnel should not be in the domain admin group, and if they are not, a net user script attack will not succeed. The second issue is that access to any of your machines should be controlled. This exploit only requires that the attacker have guest-level access and then only for a few minutes. From that minimum access, a skilled attacker can move forward and acquire domain admin privileges.

Login as System

A login as system attack requires physical access to one machine on your network. It does not require domain or even computer login credentials. To understand this attack, think about the last time you logged into any Windows computer, even a Windows server. Next to the login text boxes (Username and Password), there is an accessibility button that allows you to launch various tools to aid those users with disabilities. For example, you can launch the magnifier glass in order to magnify text.

In this attack, the perpetrator will boot the system to any Linux live CD. Then, using the FDISK utility, the attacker will locate the Windows partition. By navigating to the WindowsSystem32 directory, the attacker can first make a backup of magnify.exe, perhaps naming the backup magnify.bak. Then she can rename command.exe (the command prompt) magnify.exe.

Now the attacker reboots to Windows. When the login screen appears, the perpetrator clicks Accessibility and then Magnify. Since command.exe was renamed magnify.exe, the attacker is actually launching the command prompt. No user has logged in yet, so the command prompt will have system privileges. At this point, the attacker is only limited by her knowledge of commands executed from the command prompt.

This particular attack illustrates the need for physical security. If an attacker can get even 10 minutes alone with your Windows computer, she will likely find a way to breach the network.

Penetration Testing

As mentioned at the beginning of this chapter, the techniques described in this chapter can be used in penetration testing. However, a penetration test is not simply a random application of a variety of hacking techniques. Usually a penetration test is done along with or subsequent to a vulnerability assessment. (We will discuss vulnerability assessments in detail in Chapter 11.)

A penetration test involves methodical probing of a target network in order to identify weaknesses in the network. The theory behind penetration testing is that the only way to objectively determine the security level of a given network is to have a competent penetration tester attempt to breach security. As described in this section, there are a variety of standards that one can use to guide a penetration test.

NIST 800-115

NIST 800-115 is the National Institute of Standards and Technology guideline for security assessments for Federal Information Systems. Assessments include penetration tests. NIST 800-115 describes security assessments as having four phases:

  • A shaded box with a faded outline. Planning: During this phase, the tester needs to set specific testing goals. Often these will be related to previous risk assessment evaluations of the target network.

  • A shaded box with a faded outline. Discovery: This phase involves using a variety of tools—including port scanners, vulnerability scanners, and manual techniques—to identify or discover any issues with the target network.

  • A shaded box with a faded outline. Attack: Now the attacker can attempt to compromise the target network by exploiting the vulnerabilities found during the discovery phase. It is in this phase that the penetration tester applies the hacking techniques we have discussed in this chapter.

  • A shaded box with a faded outline. Reporting: The final step is to prepare a detailed report and to deliver it to the person who hired the penetration tester. The report should provide details on what vulnerabilities were exploited, how they were exploited, and what remediation steps are recommended.

Even though this approach has only four phases, these are rather broad phases that include many substeps. It is not necessary for our purposes to delve into all the details of NIST 800-115. However, these broad steps provide a framework for penetration testing. Notice that there are two steps prior to the attack phase. Planning and discovery are critical, and you will see similar items in other penetration testing standards.

The NSA Information Assessment Methodology

The National Security Agency (NSA) has primary responsibility for information security throughout the U.S. federal government. The NSA has formulated a methodology to be applied to any information systems assessment that includes security audits, vulnerability tests, and penetration tests. That methodology is briefly described here:

  • A shaded box with a faded outline. Pre-assessment

    • A shaded box with a faded outline. Determine and manage the customer’s expectations.

    • A shaded box with a faded outline. Gain an understanding of the organization’s information criticality.

  • A shaded box with a faded outline. Determine the customer’s goals and objectives.

    • A shaded box with a faded outline. Determine the system boundaries.

  • A shaded box with a faded outline. Coordinate with the customer.

    • A shaded box with a faded outline. Request documentation.

  • A shaded box with a faded outline. Onsite assessment

    • A shaded box with a faded outline. Conduct an opening meeting.

    • A shaded box with a faded outline. Gather and validate system information (via interview, system demonstration, and document review).

    • A shaded box with a faded outline. Analyze assessment information.

    • A shaded box with a faded outline. Develop initial recommendations.

    • A shaded box with a faded outline. Present an out-brief.

  • A shaded box with a faded outline. Post-assessment

    • A shaded box with a faded outline. Give an additional review of documentation.

    • A shaded box with a faded outline. Get help understanding what you learned.

  • A shaded box with a faded outline. Report coordination (and writing)

This particular summary of steps is interesting. Managing customer expectations is a critical step. It is important that the customer know what a penetration test can and cannot do. The pre-assessment phase is all about deciding what will be done and what is expected.

The onsite assessment includes the process of examining the system and involves an out-briefing to let the customer know the essence of what you found. Then it culminates with a report that is written and delivered in the third phase. It is also interesting to notice that in the final phase there is a substep involving getting additional expertise. If your penetration test or security audit found items that are outside your expertise, then it is wise to consult with an expert in that area.

PCI Penetration Testing Standard

The Payment Card Industry Data Security Standard (PCI DSS) is a set of standards used by companies that process credit cards. We will look at PCI standards in general in Chapter 10, “Security Policies.” In this section we will briefly examine the penetration testing portion of those standards. PCI DSS Requirement 11.3.4 mandates penetration testing to validate that segmentation controls and methods are operational and effective and to ensure that they isolate all out-of-scope systems from systems in the cardholder data environment.

PCI standards recommend testing a separate environment, not the live production environment, during normal business hours.

It is recommended that pen testing include social engineering tests.

Per PCI DSS Requirements 11.3.1 and 11.3.2, penetration testing must be performed at least annually and after any significant change—for example, infrastructure or application upgrade or modification—or new system component installations. As with the previous models we examined, PCI DSS has some specific steps:

  • A shaded box with a faded outline. Pre-engagement: Defining scope, documents, rules of engagement, success criteria, and review of past issues

  • A shaded box with a faded outline. The actual penetration test: Applying hacking techniques

  • A shaded box with a faded outline. Post-engagement: Reporting and recommending remediation steps

It is not critical that you memorize these standards. The point is to understand that hacking techniques are utilized in penetration testing but that penetration testing is more than just random attempts to hack the target network. It is a methodical approach to verifying the security of a target network that happens to include real hacking techniques.

This book is meant to introduce computer security and does not go into detail on penetration testing. For more details, you may want to consider Penetration Testing Fundamentals: A Hands-On Guide to Reliable Security Audits, also from Pearson.

The Dark Web

The Dark Web is an area of the Internet that is accessible only via onion routing. Onion routing essentially routes packets all around the world, bouncing through proxy servers. Each packet is encrypted with multiple layers of encryption, and each proxy can only decrypt one layer, and send the packet to the next proxy. If someone intercepts a packet in transit between two proxies, you can only determine the previous proxy and the next proxy. You cannot determine the actual origin or destination. This is shown in Figure 6.10.

A figure illustrates how the data transfers from the user's machine to the target site.

Figure 6.10 TOR.

This leads to a situation in which a user’s location is not easily determined. For example, I used the TOR browser to visit Yahoo.com while sitting in my study in Plano, Texas. In Figure 6.11 you can see the results. As you can see, Yahoo thought I was coming from Sweden and presented its page in Swedish.

The concept of using the TOR browser is explained.

Figure 6.11 Yahoo through TOR.

The anonymity provided by TOR is not inherently wrong or unethical. Many people simply do not wish to be monitored when surfing the Web. However, this level of anonymity does lend itself to criminal activity, and markets on the Dark Web traffic in a range of illegal products and services.

In the past several years, many Dark Web criminal markets—for example, Silk Road, Silk Road 2, HANSA, and Alpha Bay—have been taken down by law enforcement. But others have popped up. Within minutes of searching the Dark Web, you can readily find drugs, guns, child pornography, and many other illegal products and services. You can find Jihad training sites, instructions on how to make explosives, hacking services, places to buy and sell malware, and even sites devoted to extreme sexual deviation. As one example of a Dark Web market, Figure 6.12 shows The People’s Drug Store (http://newpdsuslmzqazvr.onion).

A figure depicts the information about the dark web's online drug supplier.

Figure 6.12 The People’s Drug Store.

Surfing the Dark Web can be a bit dangerous. Many sites are replete with malware. Therefore, you must establish a specific environment for Dark Web activities—a virtual machine that is completely isolated from the host operating system (which means no sharing of the Clipboard or folders). The virtual machine should preferably run a different operating system than the host, making crossing the VM/host barrier even more difficult. Finally, that VM should be used only for the Dark Web activities and for no other purpose. Many Dark Web investigators like to use The Amnesiac Incognito Live System (TAILS) for Dark Web surfing. It is a free download from https://tails.boum.org.

You should note that TOR has been updated to use Onion v3. Many sites are moving their addresses to Onion v3. As pf October 15, 2021, all Onion v2 sites are disabled in the TOR browser. If you have links from before 2022, they may no longer work.

Some people speculate that the stories about illicit materials on the Dark Web are simply hype. The following are just a few stories related to the Dark Web from news sources:

For those readers who would like more technical information on the Dark Web, the most important thing to understand is the nodes. The various nodes are described here:

  • A shaded box with a faded outline. Entry node: This is the first node, where the traffic enters the TOR network. Any relay node can act as an entry node. There is no difference in the function of the entry and relay nodes; however, there is a difference from the user’s point of view. The entry node is the node that has the real identity of the user. This is the extent of the knowledge the entry node has. The entry node only knows the identity of the user and the next node information. It doesn’t know about the destination because of Perfect Forward Secrecy.

  • A shaded box with a faded outline. Relay node: Relay nodes accept the TOR connections, unwrap the additional layer of the Perfect Forward Secrecy, and relay the connection to the next node in the forward path chain. Default configurations have set only one node in the middle of the TOR circuit, but you can increase the number if you like. Be aware that as you increase the number of middle nodes, the delay in the connection increases.

  • A shaded box with a faded outline. Exit node: The exit node is the node that communicates to the destination. Again, this node is no different from the other two nodes, but as it communicates to the destination server and forwards the traffic out of the TOR network, it serves as the source for the destination server. Because of this, exit nodes are always being accused of their activities in the TOR network. Exit nodes are always targeted by investigators. Owners of exit nodes have to repeatedly give explanations to justify their servers.

  • A shaded box with a faded outline. Advertised relay nodes: These nodes are called advertised nodes because they are listed in the directory servers. These are the real nodes that help to anonymize the TOR network by maintaining Perfect Forward Secrecy. Anyone can see the identity of these nodes by querying them as they would a TOR browser.

  • A shaded box with a faded outline. Bridge nodes: Bridge nodes are like any other nodes except that they are not advertised, which means bridge nodes are not listed in the directory servers. What is the purpose of bridge nodes if they are not listed in the directory servers? The main reason to have these nodes is to hide the TOR traffic from government agencies and Internet firewalls. As you may know, TOR nodes are often accused by security agencies because of their activities on the TOR network. In addition, these are easy to block as the identities of the TOR nodes are publicly available on the directory servers. Bridge nodes are used to bypass the blocks. If a bridge node is serving as an entry node, it is hard to find and block the traffic on the firewalls as they are not listed in the TOR directory servers. The main challenge of using a bridge node as an entry node, however, is that someone has to learn about the active bridge server, and it has to be configured manually on the TOR browser.

You can find lists of exit nodes on many websites. The following are just a few:

Summary

In this chapter we have examined just a few techniques hackers utilize and illustrated the need for a variety of security measures. The scanning techniques illustrate the need for blocking certain traffic at the firewall and for running an IDS. The SQL injection attack demonstrates why security must be part of application development. And the ophcrack tool illustrates why physical security is important and why the principle of least privileges is important. Putting tech support staff into the domain admins group violates the concept of least privileges and makes the privilege escalation script possible. If you wish to delve deeper into hacking and penetration testing, you may wish to read Penetration Testing Fundamentals: A Hands-On Guide to Reliable Security Audits, also from Pearson and from the same author as this current book.

Test Your Skills

Multiple Choice Questions

1. Elizabeth is describing web-based attacks to a group of students in a computer security course. What does an SQL injection attack require?

A. Having database admin privileges

B. Creating an SQL statement that is always true

C. Creating an SQL statement that will force access

D. Understanding web programming

2. Juan is using a rainbow table to circumvent passwords on a Windows computer. What is the best description of a rainbow table?

A. A table of precomputed hashes

B. A brute-force password attack

C. A dictionary attack on passwords

D. A multi pronged attempt to crack passwords

3. You are responsible for security on an e-commerce system. You want to mitigate as many attacks as you can. How can you prevent cross-site scripting?

A. Filter user input.

B. Use an IDS.

C. Use a firewall.

D. It cannot be prevented.

4. What is an advantage of using Shodan.io?

A. It is free.

B. It can check for a wide range of vulnerabilities.

C. It is designed for Windows systems.

D. It includes an IDS.

5. Perez is exploring different password cracking tools. A friend has told him about ophcrack. ophcrack depends on the attacker doing what?

A. Getting physical access to the machine

B. Getting domain admin privileges

C. Using social engineering

D. Using a scanning tool

6. If you wish to view items that have been removed from a website, what is the best way to do so?

A. Use Nessus.

B. Use Nmap.

C. Use www.netcraft.com.

D. Use www.archive.org.

7. Malek needs a port scanner so he can scan open ports on his own network. Which of the following is a popular port scanner?

A. Nessus

B. ophcrack

C. MBSA

D. Nmap

8. Jane wants to mitigate as many attacks as she can. A colleague suggested that she block ICMP packets. Blocking incoming ICMP packets will prevent what type of scan?

A. SYN

B. Ping

C. FIN

D. Stealth

9. It is important that you understand cybersecurity terminology, including terms for different actors in cybersecurity. What is the correct term for a person who uses hacking techniques for illegal activities?

A. A hacker

B. A gray hat hacker

C. A phreaker

D. A cracker

10. What is the term for a person who hacks into phone systems?

A. A hacker

B. A gray hat hacker

C. A phreaker

D. A cracker

11. Penelope is teaching an introductory cybersecurity course and is trying to explain the terminology to students. What is the term for a person who uses tools to hack without understanding the underlying technology?

A. A script kiddy

B. A gray hat hacker

C. A novice

D. A white hat hacker

12. What is the name for the process of trying to list all the servers on a network?

A. Port scanning

B. Enumeration

C. Vulnerability scanning

D. Scouting

13. Terrance is performing a scan. What response will a Windows machine give to a FIN scan?

A. ACK

B. None

C. SYN

D. RST

14. Jaron is trying to do a port scan of his own company. He wants to test to see if the company’s security systems will be able to detect his scan. Which of the following is considered the stealthiest port scan?

A. SYN

B. Connect

C. Ping

D. Nmap

15. What is the stealthiest way to find out what type of server a website is running?

A. Use Nmap.

B. Use Cain and Abel.

C. Use www.netcraft.com.

D. Use www.archive.org.

Exercises

EXERCISE 6.1: Using www.archive.org

This exercise gives you practice using www.archive.org. Go to www.archive.org and pull up at least two previous versions of your college’s/university’s website. What information can you find that is no longer on the website?

EXERCISE 6.2: Using Nmap

This exercise introduces you to the Nmap tool. You should download and install Nmap. Then run at least three different scans on either your own computer or a designated lab computer. (While it is not illegal to scan a computer, doing so may violate security policies for some colleges and universities. Make certain you scan only a designated lab computer.)

EXERCISE 6.3: Using ophcrack

Download ophcrack to a CD. Then reboot your own machine to the ophcrack CD and attempt to crack your own local passwords. (It is critical that you do this only on your own machine or a designated lab machine. Doing this on other machines would probably violate security policies at your college/university/company.)

EXERCISE 6.4: Using Netcraft.com

Visit www.netcraft.com and do a search on at least three different websites of your choosing. Note what information you are able to gather about each website.

Projects

PROJECT 6.1: Passive Reconnaissance

Select a local organization and conduct passive reconnaissance on it. This should include searching job boards, the organization’s own website, user groups/bulletin boards, social networking sites, www.archive.org, and more. Gather as much information about the target network as you can.

PROJECT 6.2: Port Scanners

Use your favorite search engine to locate at least two other port scanners besides Nmap. Download and install them and then try them on your own machine or a designated lab computer. Compare and contrast these tools to Nmap. Are they easier to use? More informative?

Case Study

Jane is a hacker intent on breaking into XYZ Corporation. She uses a variety of passive reconnaissance techniques and gathers extensive information about the company. Jane finds out from network administrator questions/comments in user groups the model of routers being used in the company. She finds a complete list of the IT staff and their phone numbers from a personnel directory on the company website. She also finds out what services are running by using a port scan.

Based on this scenario, consider the following questions:

  1. What reasonable steps could the company have taken to prevent Jane from finding out router models and other company hardware?

  2. What steps should the company take to prevent or at least reduce the efficacy of port scans?

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset