{"id":1183,"date":"2018-10-31T15:22:29","date_gmt":"2018-10-31T12:22:29","guid":{"rendered":"http:\/\/kifarunix.com\/?p=1183"},"modified":"2024-03-11T19:53:18","modified_gmt":"2024-03-11T16:53:18","slug":"how-to-setup-damn-vulnerable-web-app-lab-on-ubuntu-18-04-server","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/how-to-setup-damn-vulnerable-web-app-lab-on-ubuntu-18-04-server\/","title":{"rendered":"How to Install and Configure DVWA Lab on Ubuntu 18.04 server"},"content":{"rendered":"\n
Hello there, today we are going to learn how to install and configure DVWA lab on Ubuntu 18.04 server.<\/p>\n\n\n\n
DVWA<\/a> has been defined as a damn vulnerable PHP\/MySQL based web application whose main goals are to aid security professionals to test their skills and tools in a legal environment, help web developers better understand the processes of securing web applications and aid teachers or students to teach or learn web application security respectively in a class room environment.<\/p>\n\n\n\n To setup DVWA on Ubuntu 18.04 server, step through the following procedure.<\/p>\n\n\n\n Update and upgrade all packages on your server.<\/p>\n\n\n\n One the upgrade is done, we are going to install the basic components of LAMP stack i.e Apache, MySQL, and PHP. Therefore you can check our previous article on how to install LAMP Stack on Ubuntu 18.04<\/a>.<\/p>\n\n\n\n Once you have had LAMP Stack, proceed as follows.<\/p>\n\n\n\n When prompted to set MySQL password you can set it to the default password that is used by the DVWA, DVWA is available either as a package that will run on your own web server or as a Live CD. In this guide, we are going to use DVWA package.<\/p>\n\n\n\n We are going to install DVWA on the Apache web root directory, Once that is done, clone the latest version of the DVWA to some directory, say \/tmp<\/strong> by running the command below;<\/p>\n\n\n\n The required DVWA source code files are now available under \/tmp\/DVWA<\/strong>. You need to move or copy these files to Apache default web root directory as shown below.<\/p>\n\n\n\n You can now verify that all the DVWA source code files are under the Apache Web root directory.<\/p>\n\n\n\n Next, we are going to configure DVWA database connection details. You will notice that the DVWA configuration file named If you had set a different MySQL password, edit the configuration file, Note, if you are using MariaDB rather than MySQL, you can’t use the database root user and therefore you must create a new database and the database user using the commands below;<\/p>\n\n\n\n Once you are done creating dvwa database user, edit the DVWA configuration and adjust the database configuration settings such that your configuration looks like;<\/p>\n\n\n\n Save the configuration file and restart MySQL.<\/p>\n\n\n\n The version PHP installed in our case here is 7.2.<\/p>\n\n\n\n Now edit the file, Make the following folder and file writeable by the web service for File Uploads and PHPIDS respectively.<\/p>\n\n\n\n In short, you can change the ownership of the Apache web root directory as shown below;<\/p>\n\n\n\n Now locate the IP address of your server and navigate to the web browser and type the IP address of your web server on the address bar to access your DVWA. See the screenshot below.<\/p>\n\n\n\n If your are using MariaDB, then you will get the login page directly.<\/p>\n\n\n\n If the web page doesn’t load, and tailing the the Apache error log, # tail \/var\/log\/apache2\/error.log<\/strong>, you get the following error;<\/p>\n\n\n\n It means you are missing the PHP mysqli package. Install the package as shown below and restart Apache;<\/p>\n\n\n\n As shown in the dashboard above, there are a few issues whose status is marked in red ans therefore we need to fix them as follow;<\/p>\n\n\n\n Once you are done with configurations, restart both Apache and MySQL<\/p>\n\n\n\n Go back to your web browser and reload the page and everything should be fine now.<\/p>\n\n\n\n Now, you have to create the DVWA database to ensure the success of your exercise. Click the button Create\/Reset Database<\/strong> at the bottom of your web page. You may encounter the following error;<\/p>\n\n\n\n The error above is due to wrong database connection details. You can verify the same as shown below;<\/p>\n\n\n\n Therefore, login to your mysql reconfigure it as follows;<\/p>\n\n\n\n Drop the root user;<\/p>\n\n\n\n Recreate root user;<\/p>\n\n\n\n You may opt to use the default DVWA password, Run the command below to reload the database grant tables and quit DB connection.<\/p>\n\n\n\n Restart MySQL service<\/p>\n\n\n\n Before you can navigate back to the web UI, verify that you can now connect to the DVWA DB with the set login credentials;<\/p>\n\n\n\n If all is well, then it should be able to see that the database has been created on the Web UI.<\/p>\n\n\n\n If all is well, you will be redirected to the login page.<\/p>\n\n\n\n You can now login to your DVWA server using the credentials; user There you go.<\/p>\n\n\n\n To wrap, we have successfully learnt Install and configure DVWA lab on Ubuntu 18.04 server. You can now hunt for the vulnerabilities. We hope this article helped. Happy vulnerability hunting!<\/p>\n\n\n\n How to Install Acutenix on Ubuntu 18.04<\/a><\/p>\n\n\n\n Install Nessus Professional Scanner on Debian 10<\/a><\/p>\n\n\n\nInstalling DVWA on Ubuntu 18.04<\/h2>\n\n\n\n
apt update\napt upgrade<\/pre>\n\n\n\n
p@ssw0rd<\/code><\/strong>. If you do set a different password, keep it as we will need it later.<\/p>\n\n\n\n
Download DVWA<\/h3>\n\n\n\n
\/var\/www\/html<\/code><\/strong>. Therefore you have to remove the default
index.html<\/code> <\/strong>file.<\/p>\n\n\n\n
rm -r \/var\/www\/html\/index.html<\/pre>\n\n\n\n
git clone https:\/\/github.com\/ethicalhack3r\/DVWA \/tmp\/DVWA<\/pre>\n\n\n\n
rsync -avP \/tmp\/DVWA\/ \/var\/www\/html\/<\/pre>\n\n\n\n
ls \/var\/www\/html\/\nabout.php config docs external hackable index.php login.php phpinfo.php README.md security.php vulnerabilities\nCHANGELOG.md COPYING.txt dvwa favicon.ico ids_log.php instructions.php logout.php php.ini robots.txt setup.php<\/pre>\n\n\n\n
Configure DVWA on Ubuntu 18.04<\/h3>\n\n\n\n
Set Database connection details<\/h4>\n\n\n\n
\/var\/www\/html\/config\/config.inc.php.dist<\/code><\/strong>. Therefore, rename this configuration file to
\/var\/www\/html\/config\/config.inc.php<\/code><\/strong><\/p>\n\n\n\n
cp \/var\/www\/html\/config\/config.inc.php.dist \/var\/www\/html\/config\/config.inc.php<\/pre>\n\n\n\n
\/var\/www\/html\/config\/config.inc.php<\/code><\/strong> and find the line,
$_DVWA[ 'db_password' ] = 'p@ssw0rd';<\/strong><\/code> <\/strong>and replace the
'p@ssw0rd'<\/strong><\/code><\/strong> with your new password. For example, if you set your root password to NewP@SSw0rd<\/strong>, your configuration should look like as shown below;<\/p>\n\n\n\n
vim \/var\/www\/html\/config\/config.inc.php<\/pre>\n\n\n\n
...<\/strong>\n# If you are using MariaDB then you cannot use root, you must use create a dedicated DVWA user.\n# See README.md for more information on this.\n$_DVWA = array();\n$_DVWA[ 'db_server' ] = '127.0.0.1';\n$_DVWA[ 'db_database' ] = 'dvwa';\n$_DVWA[ 'db_user' ] = 'root';\n$_DVWA[ 'db_password' ] = 'NewP@SSw0rd';<\/strong>\n...<\/strong><\/pre>\n\n\n\n
mysql><\/span> create database dvwa;\nmysql><\/span> grant<\/span> all on<\/span> dvwa.*<\/span> to dvwa@localhost identified by '<\/span>STRONGP@SSW0rd'<\/span><\/span>;\nmysql><\/span> flush privileges;\nmysql> quit<\/pre>\n\n\n\n
...<\/strong>\n$_DVWA[ 'db_server' ] = '127.0.0.1';\n$_DVWA[ 'db_database' ] = 'dvwa';\n$_DVWA[ 'db_user' ] = 'dvwa';\n$_DVWA[ 'db_password' ] = 'STRONGP@SSW0rd';\n...<\/strong><\/pre>\n\n\n\n
systemctl restart mysql<\/pre>\n\n\n\n
Configure PHP<\/h4>\n\n\n\n
php -v\nPHP 7.2.10-0ubuntu0.18.04.1 (cli) (built: Sep 13 2018 13:45:02) ( NTS )<\/pre>\n\n\n\n
\/etc\/php\/7.2\/apache2\/php.ini<\/strong><\/code><\/strong> and make the following changes.<\/p>\n\n\n\n
\n
allow_url_include = on<\/code> – Allows for Remote File Inclusions (RFI)<\/li>\n\n\n\n
allow_url_fopen = on<\/code> – Allows for Remote File Inclusions (RFI)<\/li>\n\n\n\n
safe_mode = off<\/code> – (If PHP <= v5.4) Allows for SQL Injection (SQLi)<\/li>\n\n\n\n
magic_quotes_gpc = off<\/code> – (If PHP <= v5.4) Allows for SQL Injection (SQLi)<\/li>\n\n\n\n
display_errors = off<\/code> – (Optional) Hides PHP warning messages to make it less verbose<\/li>\n<\/ul>\n\n\n\n
File Permissions<\/h4>\n\n\n\n
\/var\/www\/html\/hackable\/uploads\/\n\/var\/www\/html\/external\/phpids\/0.6\/lib\/IDS\/tmp\/phpids_log.txt<\/pre>\n\n\n\n
chown -R www-data.www-data \/var\/www\/html\/<\/pre>\n\n\n\n
<\/a><\/figure>\n\n\n\n
[Tue Oct 30 23:27:28.149822 2018] [php7:error] [pid 16560] [client 192.168.43.149:40556] PHP Fatal error: Uncaught Error: Call to undefined function mysqli_connect() in \/var\/www\/html\/dvwa\/includes\/dvwaPage.inc.php:470\\nStack trace:\\n#0 \/var\/www\/html\/login.php(8): dvwaDatabaseConnect()\\n#1 {main}\\n thrown in \/var\/www\/html\/dvwa\/includes\/dvwaPage.inc.php on line 470<\/strong><\/pre>\n\n\n\n
apt install php-mysqli -y\nsystemctl restart apache2<\/pre>\n\n\n\n
\n
<\/span><\/strong>\n\n
# apt install php-gd -y<\/strong><\/code><\/strong><\/li>\n<\/ul>\n<\/li>\n\n\n\n
\n
\/var\/www\/html\/config\/config.inc.php<\/code><\/strong> and set the values for;\n
\n
$_DVWA[ 'recaptcha_public_key' ] = 'PASTE YOUR PUBLIC KEY HERE';<\/code> &<\/li>\n\n\n\n
$_DVWA[ 'recaptcha_private_key' ] = 'PASTE YOUR SECRET KEY HERE';<\/code><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n
systemctl restart apache2\nsystemctl restart mysql<\/pre>\n\n\n\n
<\/a><\/figure>\n\n\n\n
Create Database for DVWA<\/h3>\n\n\n\n
<\/a><\/figure>\n\n\n\n
mysql -u root -pNewP@SSw0rd<\/strong> -D dvwa -h 127.0.0.1\nmysql: [Warning] Using a password on the command line interface can be insecure.\nERROR 1698 (28000): Access denied for user 'root'@'localhost'<\/strong><\/pre>\n\n\n\n
mysql -u root -p<\/pre>\n\n\n\n
drop user root@localhost;<\/pre>\n\n\n\n
create user root@localhost identified by 'NewP@SSw0rd<\/strong>'<\/pre>\n\n\n\n
p@ssw0rd<\/strong><\/code><\/strong>.<\/p>\n\n\n\n
flush privileges;\nquit;<\/pre>\n\n\n\n
systemctl restart mysql<\/pre>\n\n\n\n
mysql -u root -pNewP@SSw0rd<\/strong> -D dvwa -h 127.0.0.1<\/pre>\n\n\n\n
<\/a><\/figure>\n\n\n\n
<\/a><\/figure>\n\n\n\n
admin<\/strong><\/code><\/strong> passord:
password<\/strong><\/code><\/strong>.<\/p>\n\n\n\n
<\/a><\/figure>\n\n\n\n
Other Related Guides<\/h3>\n\n\n\n