Project SQL-X1 for CNIT 123: Havij (10 pts.)

Requirements

Testing SQLol

In your Linux machine, in Firefox, go to

localhost/sqlol

SQLol opens, as shown below:

If you don't see the SQLol page, try restarting Apache with this command:

service apache2 restart
If that doesn't work, re-do the first portion of the first SQlol project to get SQlol installed and working.

Testing Mysql

In your Linux machine, in Firefox, go to

localhost/sqlol

SQLol opens, as shown below:

Click RESET

A message appears saying "Done!"

If you see the "Could not connect..." message shown below, restart mySQL with this command:

service mysql restart
If that doesn't work, re-do the first portion of the first SQlol project to get SQlol installed and working.

Using the "Find Users" Page

SQLol is too complex for Havij to exploit in its original state, so I added a simplified "Find Users" page.

In your Linux machine, in Firefox, go to

localhost/sqlol/search.htm

A "Find Users" page opens, as shown below:

In the Name field, type

C%
Click the Submit button.

You should see the username "Chunk MacRunfast", as shown below:

In Firefox, click the Back button to return to the "Find Users" page.

In the Name field, type

%
Click the Submit button.

You should see all five usernames, as shown below:

Breaking the "Find Users" Page

Apparently the designers of this site don't regard usernames as confidential. But the database also contains social security numbers, and those really are confidential.

The whole point of SQL injection is that a simple form like this can be tricked into revealing more data than the designer intended to reveal.

In Firefox, click the Back button to return to the "Find Users" page.

In the Name field, type

O'Neil
Click the Submit button.

You should see an error message, as shown below:

This is the kiss of death--an error like this means that you have lost control of the database, and an attacker can often extract all the data.

We'll steal the data with Havij, which is absurdly easy to use.

Getting the IP Address of the Linux Machine

On your Linux machine, in a Terminal window, enter this command:
ifconfig
Record the IP Address of your Linux machine.

If you are using a virtual machine, it's best to use "Bridged" networking rather than NAT.

Starting the Windows Machine

Start your Windows machine. In a Command prompt, PING the IP address of your Linux machine. You should get replies. If you do not, you need to troubleshoot your networking before proceeding further.

Viewing the "Find Users" Page from the Windows Machine

On your Windows machine, open a Web browser and go to

http://192.168.198.175/sqlol/search.htm

Replace 192.168.198.136 with the correct IP address of your Linux machine.

A "Find Users" page opens, as shown below:

In the Name field, type

x
Click the Submit button.

You should see the results page, as shown below:

No users were found, but that's not a problem. What we really want is the URL of this page, as shown in the address bar:

http://192.168.198.175/sqlol/search.php?q=x
You don't need to use the form to perform a search. You can do it by inserting the search parameter directly into the URL.

On the Windows machine, in the URL bar, add an apostrophe to the end of the URL, so it becomes this:

http://192.168.198.175/sqlol/search.php?q=x'
Press the Enter key.

A SQL error message appears, as shown below:

This URL is the attack point Havij needs: a URL with a vulnerable parameter.

Installing Havij

Havij is a free and powerful SQL Injection attack tool.

On your Windows machine, in a Web browser, go to:

http://www.itsecteam.com/products/havij-v116-advanced-sql-injection/index.html

Click the "Download" tab.

Click "Havij v1.15 Free"

Extract with 7-zip. If you don't have 7-zip, get it here

Install Havij with the default options.

If it doesn't launch automatically, click Start, type Havij into the Search box, and run Havij. It does not require Administrator privileges.

In the Havij window, paste this URL into the Target field, using the correct IP address of your Linux machine:

http://192.168.198.175/sqlol/search.php?q=x

In the Havij window, click the Analyze button.

The Log at the bottom of the Havij window should show "Current DB: sqlol", as shown below:

In the upper center of the Havij window, click the Tables button.

In the lower bar that appears, click the "Get Tables" button.

The tables "ssn" and "users" appear, as shown below:

In the left-center pane of the Havij window, check the ssn and users boxes.

In the center of the Havij window, click the "Get Columns" button.

The column names appear, as shown below:

In the left-center pane of the Havij window, in the "ssn" table section, check the name and ssn boxes.

In the center of the Havij window, click the "Get Data" button.

The names and ssns appear, as shown below:

Saving the Screen Image

Make sure you can see the names and ssns, as shown in the image above on this page, but without the gray boxes obscuring the data.

Save a screen image with the filename Proj SQL-X1 from Your Name.

Turning in Your Project

Email the image to cnit.123@gmail.com with a Subject line of Proj SQL-X1 from Your Name.

Last modified: 11 am 1-1-13