Sponsored
Web Penetration Testing

Web Server Lab Setup on Docker, Ubuntu and Windows

As we know how much web stack is important for hosting web content in linux environment and in this tutorial we will setup our web server for penetration testing on Ubuntu OS.

What is LAMP ?

LAMP stands for Linux, Apache, MySQL, and PHP. Its all are very common example of a web service stack each component. These are the first priority whenever the web application has been hosted into the web server.

What steps will we follow ?

  • Ubuntu
  • Apache
  • PHP
  • MySQL
  • phpMyAdmin
  • FTP
  • SSH
  • Nmap
  • Docker
  • Windows

Requirements

  • Ubuntu
  • Windows

Lets do it πŸ™‚ !!

Install Apache Nmap PHP SSH FTP

  • Apache – Apache is the most commonly used web server in linux operating system. It is a free open source software which runs over 50% of the world’s wide web servers.
  • PHP – PHP is a popular general-purpose scripting language that is especially suited to web development.
  • Nmap – Nmap is a free and open-source network scanner. It also used for vulnerability scanning and network discovery and analyzing the responses.
  • SSH – Secure Shell (SSH) is a cryptographic network protocol. It is a secure way to access a computer over an unsecured network.
  • FTP – File Transfer Protocol is a standard network protocol used for the transfer of computer files between a client and server on a computer network.

Now we will install all these in a single command.

apt install apache2 php ssh vsftpd nmap -y

Install MySQL

MySQL is a relational database management system based on SQL – Structured Query Language that is works with SELECT , DELETE , INSERT , REPLACE , and UPDATE statements. MySQL is used to manage database systems, retrieving data from database tables etc.

Lets install the MySQL database server by using the β€œapt-get” command.

apt install mysql-server -y

We will login to the database after installation. If we are logging in with root, it is not necessary to enter the password.

mysql -u root -p

After login we have to provide all the privileges to the user of ubuntu, in our case we will select the user β€œshubham” whose password is β€œ123β€œ.

GRANT ALL PRIVILEGES ON . TO 'shubham'@'%' IDENTIFIED BY '123' WITH GRANT OPTION;

We need to execute the flush privileges command to update the database.

flush privileges;
exit

Results

Here you can see that we have configured Web Server Lab in a few minutes.

nmap localhost

Docker

Docker is a tool designed to make it easier to create, deploy, and run applications by using containers.

Now we will configure our Web Server Lab in docker. In order to create a Docker-based LAMP stack we need to download docker first in ubuntu using the following command.

apt install docker.io

After the installation we have to download the docker-compose which let us easily organize multi-container applications using yaml configuration files.

apt install docker-compose

After install all these we need to create a β€œ.yaml” file that will contains the following configuration.
Note : If you are trying this in the new ubuntu, you can enter the given configuration otherwise you will have to change the port and credentials accordingly.

cat > docker-compose.yaml
version: "2"
services:
    www:
        image: amarsingh3d/apache2.4-php7.2
        ports: 
            - "82:80"
        volumes:
            - ./DocumentRoot:/var/www/html/
        links:
            - db
        networks:
            - default
    db:
        image: mysql:5.6
        ports: 
            - "3302:3306"
        environment:
            MYSQL_DATABASE: myDb
            MYSQL_USER: user
            MYSQL_PASSWORD: test
            MYSQL_ROOT_PASSWORD: test 
        volumes:
            - ./MySQL_DATA:/docker-entrypoint-initdb.d
            - persistent:/var/lib/mysql
        networks:
            - default
    phpmyadmin:
        image: phpmyadmin/phpmyadmin
        links: 
            - db:db
        ports:
            - 8080:80
        environment:
            MYSQL_USER: user
            MYSQL_PASSWORD: test
            MYSQL_ROOT_PASSWORD: test 
volumes:
    persistent:

After sets the configuration accordingly, now its time to build our project and setup the web server using the following command.

docker-compose up -d

This may take some time, but you can see that all the service has started in the docker.

docker ps

Check the service to see if the service is working properly. You can see that our Apache server is working successfully on port 82.

Now let’s check the phpmyadmin server, whose username is β€œuser” and the password is β€œtestβ€œ

Windows – XAMPP

XAMPP is a free and open-source web server stack package, consisting mainly of the Apache HTTP Server, MariaDB database, and interpreters for scripts written in the PHP and Perl programming languages.

Configuring the web server lab on a window machine is quite easy. First we have to install the β€œXAMPP” application from the official website. Once installed we have to click on the β€œStart” button of the Apache and MySQL service.

Done ! Our web server is successfully deployed in the window machine.

About the Author
Shubham Goyal Certified Ethical Hacker, information security analyst, penetration tester and researcher. Can be Contact on Linkedin.
Sponsored

View Comments

Recent Posts

Termux Cheat Sheet for Hackers

Hey Folks :) !! In this article, we present the "Termux Cheat Sheet for Hackers"…

1 month ago

Cracking the X-Factor in Cybersecurity: How Humans are Protecting the Systems?

Amid the rapid advancement of technology, the significance of human involvement in cybersecurity frequently goes…

8 months ago

Cariddi – Hidden Endpoint Finder for Bug Hunting

Hey Folks, we are back today after such a long break, but don't worry we…

2 years ago

API Security Testing 101: Know Everything About API Security Testing!

The security of your API should be one of the top priorities of companies. Without…

2 years ago

7 Best Tools for Web Penetration Testing: Comprehensive Details

Hey Folks, In today's business world, it is essential to have an online presence. However,…

2 years ago

Cyber Security Audits: Everything You Need to Know About It

Hey Folks, Is your business prepared in case of a cyber attack? Many companies don't…

2 years ago
Sponsored

This website uses cookies.