As mentioned in the previous article, we are now well familiar with the DVWA aka Damn vulnerable web app. So without wasting much time, I am beginning this article.

  • What will you learn in this article?
  •  We will learn to configure a DVWA in Kali linux 2.0.
  • Unzip the downloaded dvwa-master file, rename the dwa-master file to dvwa, open terminal on the same folder and move the unzip dvwa folder to the html path by the following command
mv dvwa /var/www/html
 


  • Then, go to the config folder. You have to change the name of config.inc.php.dist to config.inc.php. Why? To stop the config file from being overwritten in update.
cd /var/www/html/dvwa/config
         mv config.inc.php.dist config.inc.php



  • The name of config file is updated. Now, open this file.
gedit config.inc.php

  • Change the db_user name to user and db_password to p@ssword.Further more, you need to generate your own Recaptcha key by going on this link https://www.google.com/recaptcha/admin/create 


How to create a Recaptcha?

Login with your gmail account. Select recaptcha and add domain and subdomain. For example, for this tutorial I used dummy.com as my domain and subdomain.dummy.com as my subdomain. After that, two keys will be visible to you. Site key which will be your public key and secret key as your Private key.Grab the key and add them in recaptcha public and private key. Save the file and exit.
We have changed the root username and password in config.inc.php because by default in Kali, MariaDB is used instead of MySQL and we have to create a new user.

 

  • Now go to cd /var/www/html/ and type chmod -R 777 dvwa. Through this command, you are giving explicit permission to dvwa folder for reading and writing.
 

  • Now the server configuration is about to start. After entering the required commands in desired sequence, you will be able to create a DVWA database.

        service mysql start
        mysql -u root -p #just hit enter for password
        create database dvwa;
        CREATE USER 'user'@'127.0.0.1' IDENTIFIED BY 'p@ssword';
        grant all on dvwa.* to 'user'@'127.0.0.1';
        flush privileges;
        exit
        service mysql stop

 

  • DVWA needs a php module which is not installed in. In order to install it, first check your php version by using the command php -v. In my case, I had php 7.0.29-1. I first did apt-get update and then installed the required php gd version by using the command
apt-get install php7.0-gd.

  • If you have a older php version, then you have to install an older php-gd     version.Note:This is a crucial step.

 

  • You're almost done. Last thing to do is edit the main config file for apache2, type (gedit /etc/php/7.0/apache2/php.ini). Search for allow_url and enable allow_url_include to on. This step is necessary to exploit the file upload vulnerability.
  • You're done. Your DVWA is correctly setted and can now be started.
service apache2 start
                                      service mysql start
  • Now open your web browser and type  

    127.0.0.1/dvwa

    If all the things are configured accordingly, a login page will be displayed. Type username as admin and password as password.