COMP249: Web Security

Steve Cassidy

Web Security and Privacy

Cracker Motivations

An Example

The FBI released a warning to websites using shopping cart software named "PDG," which was utilized by roughly 4,000 websites, after a devastating bug was found that reveals all the company's customer information. One website, SawyerDesign.com, had purchased the software from a reseller leaving them out of touch from the notifications sent to direct customers. Once the site was discovered by carders, they had a field day racking up thousands of dollars on customers credit cards ranging from long distance cards to domain names. (source www.hackinthebox.org)

How to Crack a Server

How to Crack a Server

Open Internet Ports

Open Internet Ports

You can use telnet to connect to any tcp port and gain some information about the server program:
%  telnet ftp.mq.edu.au 21
Trying 137.111.1.11...
Connected to sunb.ocs.mq.edu.au.
Escape character is '^]'.
220-
220-  This is the Macquarie University anonymous ftp server.
220-  All transfers are logged, if you don't like this policy then
220-  disconnect now.
220-
220-
220 sunb FTP server (Version wu-2.6.1(2) Sat Dec 1 11:33:49 EST 2001) ready.
We now know that ftp.mq.edu.au runs version 2.6.1 or wu-ftpd

Exploiting Security Holes

WU-FTPD Exploit

WU-FTPD File Globbing Denial of Service Vulnerability: Remote exploitation of an input validation vulnerability in version 2.6.2 of WU-FPTD could allow for a denial of service of the system by resource exhaustion. The vulnerability specifically exists in the wu_fnmatch() function in wu_fnmatch.c. When a pattern containing a '*' character is supplied as input, the function calls itself recursively on a smaller substring. By supplying a string which contains a large number of '*' characters, the system will take a long time to return the results, during which time it will be using a large amount of CPU time.

Buffer Overflow Exploit

Wu-ftpd is vulnerable to a very serious remote attack in the SITE EXEC implementation. Because of user input going directly into a format string for a *printf function, it is possible to overwrite important data, such as a return address, on the stack. When this is accomplished, the function can jump into shellcode pointed to by the overwritten eip and execute arbitrary commands as root. (Source: SecurityFocus.com) SecurityFocus.com provides example C programs which take advantage of this exploit

From a Logfile

This line is taken from a web server logfile. It shows an attempted exploit of an IIS security hole (one of the Code Red family I think)
202.127.1.24 - - [12/May/2002:07:32:32 +1000] "GET /default.ida?NNNNNNNN
NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
%u9090%u6858%ucbd3%u7801%u9090%u6858%ucbd3%u7801%u9090%u6858%ucbd3%u7801
%u9090%u9090%u8190%u00c3%u0003%u8b00%u531b%u53ff%u0078%u0000%u00=a  
HTTP/1.0" 400 329 "-" "-"
      

Exploiting CGI Scripts

Exploiting CGI Scripts

An Example CGI Exploit

SQL Injection

SQL Injection

user = form.get_value("user")
password = form.get_value("password")
query = "SELECT * FROM users WHERE user='"+user"' AND password='"+password+"'"
cur.execute(query)
...      
      

If user="hacker" and password="' OR 1=1 --":

SELECT * FROM users WHERE user='hacker' AND password='' OR 1=1 --'

SQL Injection

user = form.get_value("user")
password = form.get_value("password")
query = "SELECT * FROM users WHERE user=? AND password=?"
cur.execute(query, (user, password))
...      
      

If user="hacker" and password="' or 1=1 --":

SELECT * FROM users WHERE user='hacker' AND password='\' or 1=1 --'

Cracking Passwords

Getting Root

Got Root

Network Packet Sniffing

Automated Cracking: Script Kiddies

Trojan Horses

Denial of Service Attacks

Notes and References

Building Secure Servers

Firewalls

Encryption

Using Public Key Cryptography

SSL: Secure Socket Layer

Who Needs Secure Services

Verifying Identity

Secure Data Transmission

Digital Certificates

An Example Digital Certificate

Certificate:
    Data:
        Version: 0 (0x0)
        Serial Number: 0 (0x0)
        Signature Algorithm: md5withRSAEncryption
        Issuer: C=ZA, SP=Western Cape, L=Cape Town, O=Thawte Consulting cc, 
                OU=Certification Services, CN=www.thawte.com, 
                Email=webmaster@thawte.com
        Validity
            Not Before: Nov 14 17:15:25 1996 GMT
            Not After : Dec 14 17:15:25 1996 GMT
        Subject: C=ZA, SP=Western Cape, L=Cape Town, O=Thawte Consulting cc,
                 OU=Certification Services, CN=www.thawte.com,
                 Email=webmaster@thawte.com
        Subject Public Key Info:
            Public Key Algorithm: rsaEncryption
                Modulus:
                    00:9a:92:25:ed:a4:77:69:23:d4:53:05:2b:1f:3a:
                    55:32:bb:26:de:0a:48:d8:fc:c8:c0:c8:77:f6:5d:
                    61:fd:1b:33:23:4f:f4:a8:2d:96:44:c9:5f:c2:6e:
                    45:6a:9a:21:a3:28:d3:27:a6:72:19:45:1e:9c:80:
                    a5:94:ac:8a:67
                Exponent: 65537 (0x10001)
    Signature Algorithm: md5withRSAEncryption
        7c:8e:7b:58:b9:0e:28:4c:90:ab:20:83:61:9e:ab:78:2b:a4:
        54:39:80:7b:b9:d9:49:b3:b2:2a:fe:8a:52:f4:c2:89:0e:5c:
        7b:92:f8:cb:77:3f:56:22:9d:96:8b:b9:05:c4:18:01:bc:40:
        ee:bc:0e:fe:fc:f8:9b:9d:70:e3
      
Taken from Thawte

Notes and References