Setup a Vulnerable LAMP Server

LAMP is an acronym of the names of its original four open-source components used for building dynamic websites and web applications, These components are Linux, Apache, MySQL and PHP (or Perl).

The equivalent installation on Microsoft Windows operating system is known as WAMP.

To make this server vulnerable, we will be installing outdated versions of PHP and setting up broken web applications, these applications are used for learning how to hack\pentest using various different methods. Be careful not to expose your vulnerable LAMP server outside your own network as it will be hacked.

I will be setting up my vulnerable LAMP server in Linux Mint which I installed recently, See my Installing Linux Mint in VirtualBox Tutorial here . But this tutorial should work with most debian\Ubuntu based Linux Distributions.

Before we start let’s update all the repositories and upgrade our Linux installation.

sudo apt-get update && sudo apt-get upgrade -y

Apache

First, we will be installing Apache HTTP server this is simply done by typing this command below.

sudo apt-get install apache2

To test its all working, just open up a web browser and type either http://127.0.0.1 or http://localhost and you should be presented with a page like this.

MySQL

Now its time to install MySQL Database, this is done by typing.

sudo apt-get install mysql-server

This will start the installer and then ask if you want to continue, hit Y and enter and it should start installing.

Then you will be asked to set a Password for MySQL, as this is a vulnerable Server we are going to set the password to [email protected]. In the real world, you would use a password much more secure.

PHP

The latest version of PHP is version 7 but as this a vulnerable server we will need Version 5.6 to make sure the vulnerable sites we will be setting up later work properly, but the only version in the Mint repositories is the latest version 7. To get around this we need to edit the repository list to install a older version of PHP.

DVWA (Damn Vulnerable Web App)

Go to the site (link above) and click their download link which should give you a prompt asking you what you want to do with the file just click Save File and click OK, this should save the file to your downloads folder.

Open up a Terminal and we will need to navigate to where we downloaded DVWA.

cd ~/Downloads

If you do a ls you should be able to see the file you already downloaded.

Now unzip the DVWA zip file extract it into a folder called dvwa.

unzip DVWA-1.9.zip

Rename the unziped DVWA-1.9 folder to dvwa

mv DVWA-1.9 dvwa

Then move newly created dvwa folder to the apache directory.

sudo mv dvwa/ /Var/www/html/

Next navigate to the dvwa config folder so we can enter in the MySQL details to get DVWA working.

cd /var/www/html/dvwa/config/

then use a text edititor to endit the config file.

nano config.inc.php

edit the password to match the password of [email protected] which we setup earlyer in MySQL

Now every thing should be green on our Database setup page, click Create / Reset Database button at the bottom of the DVWA setup window this will connect to MySQL and create all the required databases.

Save the file to your Downloads folder then navagate to your downloads folder.

cd ~/Downloads

type ls just to check bWAPPv2.2.zip is in your Downloads folder and we can now unzip it.

unzip bWAPPv2.2.zip -d bWAPP

Now move the folder to your apache directory.

sudo mv bWAPP /var/www/html/

With a text editor add the database connection settings to bWAPP

sudo nano /var/www/html/bWAPP/bWAPP/admin/settings.php

navigate to the part of the document that says // Database connection settings and add the MySQL password between the speech marks on db_password = “[email protected]”; as below.

press Ctrl + x to exit settings.php and hit y to save the file.

cd .. to go back one directory and we need to change some permissions to make the application Vulnerable.

chmod 777 passwords/
chmod 777 images/
chmod 777 documents/

after making the above permission changes, open up your web browser and navigate to the bWAPP install.php

http://127.0.0.1/bWAPP/bWAPP/install.php

you should see the bWAPP install page, just click the here to install bWAPP link.

This will quickly setup all the databases and the screen will display bWAPP has been installed sucessfully!

You can now navigate to your bWAPP installation

http://127.0.0.1/bWAPP/bWAPP/

default login and password for bWAPP is bee:bug

and thats our vulnerable Server all setup, I will be useing this setup for future tutorials, so keep checking back as i have some exciting things planned and as always please comment in the Reply box below if you have any issues setting this up or have any comments for me.

Nice tutorial you’ve got there. I have downloaded buggy app but never had the time and the knowledge to properly installed it, got it configured and running.
Well, you’ve just made my life a bit easier. Cheers