Lab 9 (17.2.6) - Attacking A mySQL Database
Lab 9 (17.2.6) - Attacking A mySQL Database
Objectives
In this lab, you will view a PCAP file from a previous attack against a SQL database.
Part 1: Open Wireshark and load the PCAP file.
Part 2: View the SQL Injection Attack.
Part 3: The SQL Injection Attack continues…
Part 4: The SQL Injection Attack provides system information.
Part 5: The SQL Injection Attack and Table Information
Part 6: The SQL Injection Attack Concludes.
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
CyberOps Workstation virtual machine
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.
2018 - 2022 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 1 of 11 www.netacad.com
Lab 9 (17.2.6) - Attacking a mySQL Database
timestamp and some of your desktop background is also captured. Same goes to all other screen
captures for this lab.
f. What are the two IP addresses involved in this SQL injection attack based on the information
displayed?
= 10.0.2.4 & 10.0.2.15
2018 - 2022 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 2 of 11 www.netacad.com
Lab 9 (17.2.6) - Attacking a mySQL Database
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.
b. Screen shot the screen the whole Follow HTTP Stream window that shown the results.
c. The source traffic is shown in red. What is the IP address of the host that the source has sent a
GET request to?
Note: In blue, the destination device is responding back to the source.
=10.0.2.15
2018 - 2022 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 3 of 11 www.netacad.com
Lab 9 (17.2.6) - Attacking a mySQL Database
2018 - 2022 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 4 of 11 www.netacad.com
Lab 9 (17.2.6) - Attacking a mySQL Database
2018 - 2022 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 5 of 11 www.netacad.com
Lab 9 (17.2.6) - Attacking a mySQL Database
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 information you have captured above. Screen shot the part that
showed this information.
Take note that he database name is dvwa and the database user is root@localhost. There are
also multiple user accounts being displayed.
2018 - 2022 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 6 of 11 www.netacad.com
Lab 9 (17.2.6) - Attacking a mySQL Database
2018 - 2022 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 7 of 11 www.netacad.com
Lab 9 (17.2.6) - Attacking a mySQL Database
Question:
b. In the Find field, enter users. Click Find Next. Screen shot your results.
2018 - 2022 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 8 of 11 www.netacad.com
Lab 9 (17.2.6) - Attacking a mySQL Database
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.
d. What would the modified command of (1' OR 1=1 UNION SELECT null, column_name FROM
INFORMATION_SCHEMA.columns WHERE table_name='users') do for the attacker?
=Will display shorter output with the word ‘users’
e. Close the Follow HTTP Stream window.
f. Click Clear display filter to display the entire Wireshark conversation.
2018 - 2022 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 9 of 11 www.netacad.com
Lab 9 (17.2.6) - Attacking a mySQL Database
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! Screen shot
these results. Don’t forget the timestamp and desktop background.
2018 - 2022 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 10 of 11 www.netacad.com
Lab 9 (17.2.6) - Attacking a mySQL Database
Question:
Reflection Questions
1. What is the risk of having platforms use the SQL langauge?
= Any application or websites that use a SQL database, such as MySQL, Oracle, SQL Server, or
others, may be vulnerable to SQL Injection attacks. It could be used by criminals to obtain
unauthorized access to your sensitive data, such as customer information, personal data, trade
secrets, intellectual property, and more.
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?
= The only sure way to prevent SQL Injection attacks is input validation and parametrized queries
including prepared statements.
End of document
2018 - 2022 Cisco and/or its affiliates. All rights reserved. Cisco Public Page 11 of 11 www.netacad.com