Lab16 Dvwa Manual SQL Injection and Password Cracking
Lab16 Dvwa Manual SQL Injection and Password Cracking
Introduction
Exercise 1 - DVWA Usage
Exercise 2 - Performing an SQL Injection Attack
Exercise 3 - Password Cracking with John
Summary
Introduction
The DVWA - Manual SQL Injection and Password Cracking module provides you
with the instructions and devices to develop your hands-on skills in the following topics:
DVWA Usage
Performing an SQL Injection Attack
Password Cracking with John
Exam Objectives
CS0-001 3.4 Given a scenario, analyze common symptoms to select the best course
of action to support incident response
CS0-001 4.2 Given a scenario, use data to recommend remediation of security
issues related to identity and access management
CS0-001 4.3 Given a scenario, review security architecture and make
recommendations to implement compensating controls
CS0-001 4.4 Given a scenario, use application security best practices while
participating in the Software Development Life Cycle (SDLC)
Lab Diagram
During your session, you will have access to the following lab configuration. Depending
on the exercises you may or may not use all of the devices, but they are shown here in the
layout to get an overall understanding of the topology of the lab.
In this module, you will be working on the following equipment to carry out the steps
defined in each exercise.
To start, simply choose a device and click Power on. In some cases, the devices may
power on automatically.
For further information and technical support, please see our Help and Support
page.
Copyright Notice
This document and its content is copyright of Practice-IT - © Practice-IT 2017. All rights reserved. Any
redistribution or reproduction of part or all of the contents in any form is prohibited other than the
following:
1. You may print or download to a local hard disk extracts for your personal and non-commercial use
only.
2. You may copy the content to individual third parties for their personal use, but only if you
acknowledge the website as the source of the material. You may not, except with our express written
permission, distribute or commercially exploit the content. Nor may you transmit it or store it in any
other website or other form of electronic retrieval system.
Activate DVWA
Connect to DVWA
In this task, we will be starting the DVWA web service through XAMPP so that the
website is broadcasting through the IP of the Windows 2012 server on the IP of
192.168.0.1. We will then start up Kali and connect to the device.
Step 1
Connect to PLABSA01, on the taskbar you will see the XAMPP icon, click this icon and
activate the application.
Figure 1.1 Screenshot of PLABSA01: XAMPP running.
This starts up the DVWA website which is has been configured to broadcast on the
PLABSA01 IP address.
Step 2
Now open up Internet Explorer and type into the address bar:
192.168.0.1
Press Enter.
This will take you to the website being broadcast by XAMPP; this is to confirm that the
site is up and working.
Type into the address bar.
http://192.168.0.1/dvwa/login.php
This should present you with the login page for DVWA. Therefore we know the site is up
and working.
Step 3
Ensure you have powered on all the devices listed in the introduction and connect to
PLABKALI01.
In the Username filed type the following:
root
Click Next.
Step 4
In the Password field type the following:
Passw0rd
Click Sign In.
Figure 1.4 Screenshot of PLABKALI01: Logging into PLABKALI01 as root user.
Step 5
You have successfully logged in to PLABKALI01.
Figure 1.5 Screenshot of PLABKALI01: Displaying successfully logged in to
PLABKALI01.
We will now connect to the DVWA service and confirm the website contents is working
through Firefox within Kali.
Step 1
Open Firefox ESR application and type into the address bar the following:
192.168.0.1/dvwa/login.php
Figure 1.7 Screenshot of PLABKALI01: DVWA accessed from Firefox.
Again, the site is confirmed to be up and working, but we will go a little further to make
sure of this now.
Step 2
Let’s now log into the site and begin working with it.
Username:
Admin
Password:
password
If Firefox ESR presents this reminder for password information, you can click
Remember.
If you now scroll to the bottom of this page, you will see the following details.
Your username:
admin
Security Level:
low
PHPIDS:
disabled
Figure 1.10 Screenshot of PLABKALI01: DVWA main menu bottom.
The PHPIDS has been turned off for these exercises; that is why its listed as disabled.
Step 3
Scroll to the top of the page and Click in the left column Setup/Reset DB.
Figure 1.11 Screenshot of PLABKALI01: In the DVWA menu setting up a new
Database.
Step 4
Scroll down on the page and Click on the Create/ Reset Database button.
Figure 1.12 Screenshot of PLABKALI01: DVWA creating the DVWA database.
You will see an output telling you the database has been created, with users, some data, a
guestbook with data and the setup was successful. We are now ready to start a SQL
injection.
Figure 1.13 Screenshot of PLABKALI01: Displaying the new database has been
successfully created.
Stay logged into PLABKALI01 and move onto the next exercise.
We are now going to perform a manual SQL Injection attack on the DVWA page to obtain
information about the database and the information that it contains regarding the
column headings, to work out where the user information is sitting.
Step 1
Click on the Tab for SQL Injection.
User ID: 2
Step 3
Switch back to the Firefox page and let’s begin.
ID:3
First Name: Hack
Surname: Me
We will move onto more advanced SQL terms now to work out the columns.
3’
We get this error message which is a positive sign and strongly indicates this website is
vulnerable to SQL Injection.
Step 4
Type into the User ID Field and click Submit:
3’ and 1=1 #
Now we know that the database is MariaDB and its version 10.1.16
Step 5
Type into the User ID Field click Submit:
We are now presented with column headings through the table of the database. We can
see that there are a lot of different headings within this database. Take a moment to scan
through the different listings and you will see that there are columns for user privileges
and a variety of statistical information which are held in the database.
This command has brought up information about the account columns by calling on the
schema which contains those details. We see an that we have accessed information about
the guestbook, users and accounts fields.
Here we have picked out the column for only the users. We will now work on that column
specifically.
Step 6
Type into the User ID Field:
Here we are beginning to produce really interesting results showing the Information
about users, first names and last names. We can also see that they use an avatar and
there is a field for the number of failed logins together with the list of connections to the
system.
We now have the information of the first name and the password hash values.
Copy and paste the details directly from the DVWA page.
Figure 2.14 Screenshot of PLABKALI01: DVWA SQL Injection results.
Copy these details, remember to right-click on the screen and use the menu items.
Stay logged into PLABKALI01, minimize Firefox ESR and move onto the next exercise
Using a Wordlist
We will extract the password hashes and make our own file to save them into, which will
be used by John the Ripper to scan and extract out the hash values for cracking purposes.
Step 1
Let’s Open up LeafPad from the terminal to begin recording the information we learn.
Click on:
Follow the image above to open Leafpad up which is a notepad type tool for recording
information in plain format.
Figure 3.2 Screenshot of PLABKALI01: Leafpad.
Here we have a plain interface in Leafpad where we are going to record information of
interest.
Now tidy up the file by removing the commands listed, the first name field and the
surname field.
Figure 3.4 Screenshot of PLABKALI01: Leafpad.
Step 2
Then click on;
Name: password.txt
Then in the Places column change the directory to the Desktop and click the save
button.
Figure 3.5 Screenshot of PLABKALI01: Leafpad saving the file.
We will use a wordlist to aid our cracking time and reduce it significantly in terms of how
long it would take to break the hash values through a brute force attack.
Step 1
Open a new terminal screen.
We will now prepare the password list to be used which will help us crack the passwords
faster than using a brute force attack.
Type the following in the console and press Enter after each command:
root@kali:# cd /usr/share/wordlists/
root@kali:/usr/share/wordlists# ls
Type the following in the console and press Enter after each command:
Here we can see that a new text file called rockyou.txt has been created.
Now we are going to use the John tool to cracking the hash values and providing us with
the passwords we need, after which we will test the results on the login page of DVWA to
validate which logins are allocated to login and if they work.
Step 1
Open up a new terminal and type the following command and press Enter:
john
This will display all the options that can be used with the password cracking application.
The John application will be used to crack the password file that was created on the
Desktop. It will be used to crack the hashes and display the passwords.
Step 2
Navigate to the directory where the passwords.txt is located.
Type the following commands in the terminal window pressing Enter after each
command:
root@kali:# cd Desktop
root@kali:~/Desktop# ls
Step 3
The John application will now be used crack the password file.
Type the following command in 1 line in the terminal window and press Enter:
root@kali:~/Desktop# john --format=raw-md5 --
wordlist=/usr/share/wordlists/rockyou.txt password.txt
This command will display the passwords for the users of the DVWA website.
admin : password
Gordon : abc123
Pablo : letmein
Hack : charley
Now just to verify logout of the DVWA site to come back to the original login page.
Username: Pablo
Password: letmein
Scroll down the page and you will see you have logged into Pablo’s account.
Figure 3.12 Screenshot of PLABKALI01: DVWA Main Menu.
Perfect we have now completed this exercise, we exploited the database, exfiltrated the
password hashes and users, then cracked the passwords and used Pablo to log back into
the database as his user account.
The steps taken above are in fact key to confirming the security around applications and
databases and are part of the security testing phase.
Shut down all virtual machines used in this exercise using Practice Labs power
button function to revert these devices to their default settings. Alternatively, you
may sign out to power down all devices.
Summary
You covered the following activities in this module:
DVWA Usage
Performing an SQL Injection Attack
Password Cracking with John