Lab Attacking A MySQL Database FINISHED
Lab Attacking A MySQL Database FINISHED
Objectives
In this lab, you will view a PCAP file from a previous attack against a SQL database.
Background / Scenario
SQL injection attacks allow malicious hackers to type SQL statements in a web site and receive
a response from the database. This allows attackers to tamper with current data in the
database, spoof identities, and miscellaneous mischief.
A PCAP file has been created for you to view a previous attack against a SQL database. In this
lab, you will view the SQL database attacks and answer the questions.
Required Resources
Instructions
You will use Wireshark, a common network packet analyzer, to analyze network traffic. After
starting Wireshark, you will open a previously saved network capture and view a step by step
SQL injection attack against a SQL database.
The Wireshark application can be opened using a variety of methods on a Linux workstation.
<=""
p="" style="box-sizing: inherit; border-style: none; max-width: 400px !important; display: block;
min-width: auto; width: 400px; height: auto; text-align: center;">
What are the two IP addresses involved in this SQL injection attack based on the information
displayed?
Answer Area
a. Within the Wireshark capture, right-click line 13 and select Follow > HTTP Stream. Line
13 was chosen because it is a GET HTTP request. This will be very helpful in following
the data stream as the application layers sees it and leads up to the query testing for the
SQL injection.
<="" p="" style="box-sizing: inherit; border-style: none; max-width: 400px !important; display:
block; min-width: auto; width: 400px; height: auto; text-align: center;">
The source traffic is shown in red. The source has sent a GET request to host 10.0.2.15. In
blue, the destination device is responding back to the source.
c. The attacker has entered a query (1=1) into a UserID search box on the target 10.0.2.15
to see if the application is vulnerable to SQL injection. Instead of the application
responding with a login failure message, it responded with a record from a database.
The attacker has verified they can input an SQL command and the database will
respond. The search string 1=1 creates an SQL statement that will be always true. In the
example, it does not matter what is entered into the field, it will always be true.
<="" p="" style="box-
sizing: inherit; border-style: none; max-width: 400px !important; display: block; min-width: auto;
width: 400px; height: auto; text-align: center;">
d. The attacker has entered a query (1=1) into a UserID search box on the target 10.0.2.15
to see if the application is vulnerable to SQL injection. Instead of the application
responding with a login failure message, it responded with a record from a database.
The attacker has verified they can input an SQL command and the database will
respond. The search string 1=1 creates an SQL statement that will be always true. In the
example, it does not matter what is entered into the field, it will always be true.
e. Click Clear display filter to display the entire Wireshark conversation.
<="" p="" style="box-sizing: inherit; border-style: none; max-width: 400px !important; display:
block; min-width: auto; width: 400px; height: auto;">
a. Within the Wireshark capture, right-click line 19, and click Follow > HTTP Stream.
b. In the Find field, enter 1=1. Click Find Next.
c. The attacker has entered a query (1’ or 1=1 union select database(), user()#) into a
UserID search box on the target 10.0.2.15. Instead of the application responding with a
login failure message, it responded with the following information:
The database name is dvwa and the database user is root@localhost. There are also multiple
user accounts being displayed.
a. Within the Wireshark capture, right-click line 22 and select Follow > HTTP Stream. In
red, the source traffic is shown and is sending the GET request to host 10.0.2.15. In
blue, the destination device is responding back to the source.
b. In the Find field, enter 1=1. Click Find Next.
c. The attacker has entered a query (1’ or 1=1 union select null, version ()#) into a UserID
search box on the target 10.0.2.15 to locate the version identifier. Notice how the version
identifier is at the end of the output right before the.closing HTML code.
<="" p="" style="box-
sizing: inherit; border-style: none; max-width: 400px !important; display: block; min-width: auto;
width: 400px; height: auto; text-align: center;">
Answer Area
Show Answer
The attacker knows that there is a large number of SQL tables that are full of information. The
attacker attempts to find them.
a. Within the Wireshark capture, right-click on line 25 and select Follow > HTTP Stream.
The source is shown in red. It has sent a GET request to host 10.0.2.15. In blue, the
destination device is responding back to the source.
b. In the Find field, enter users. Click Find Next.
c. The attacker has entered a query (1’or 1=1 union select null, table_name from
information_schema.tables#) into a UserID search box on the target 10.0.2.15 to view all
the tables in the database. This provides a huge output of many tables, as the attacker
specified “null” without any further specifications.
<="" p="" style="box-
sizing: inherit; border-style: none; max-width: 400px !important; display: block; min-width: auto;
width: 400px; height: auto; text-align: center;">
What would the modified command of (1' OR 1=1 UNION SELECT null, column_name FROM
INFORMATION_SCHEMA.columns WHERE table_name='users')?
Answer Area
Show Answer
The attack ends with the best prize of all; password hashes.
a. Within the Wireshark capture, right-click line 28 and select Follow > HTTP Stream. The
source is shown in red. It has sent a GET request to host 10.0.2.15. In blue, the
destination device is responding back to the source.
b. Click Find and type in 1=1. Search for this entry. When the text is located,
click Cancel in the Find text search box.
The attacker has entered a query (1’or 1=1 union select user, password from users#) into a
UserID search box on the target 10.0.2.15 to pull usernames and password hashes!
<="" p="" style="box-
sizing: inherit; border-style: none; max-width: 400px !important; display: block; min-width: auto;
width: 400px; height: auto; text-align: center;">
Answer Area
Show Answer
c. Using a website such as https://crackstation.net/, copy the password hash into the
password hash cracker and get cracking.
Answer Area
Show Answer
d. Close the Follow HTTP Stream window. Close any open windows.
Reflection Questions
Show Answer
2. Browse the internet and perform a search on “prevent SQL injection attacks”. What are 2
methods or steps that can be taken to prevent SQL injection attacks?
Answer Area
Show Answer