
Day 1: Web Application Hacking 101: Setup, Targets & Recon Tools
Introduction to Web Pentesting
Web application penetration testing is a critical discipline in cybersecurity, aimed at identifying vulnerabilities in web-based systems to prevent exploitation by malicious actors. Parrot OS, a Debian-based Linux distribution tailored for security professionals, provides an ideal platform for learning and practicing web pentesting. On Day 1 of this 7-day series on web application hacking, we establish the foundation for effective penetration testing. This article guides you through setting up a test lab using Damn Vulnerable Web Application (DVWA) or OWASP Juice Shop, understanding basic HTTP/HTTPS concepts, headers, and cookies, and performing reconnaissance with tools like WhatWeb, theHarvester, Nmap, Dirb, Gobuster, and dnsenum. All commands use example.com
as the target for illustrative purposes, but you should test only on systems you own or have permission to assess. By mastering these fundamentals, you will be prepared to conduct ethical and effective web reconnaissance.
Setting Up a Test Lab
A controlled test lab is essential for practicing web pentesting safely and ethically. We will set up two popular vulnerable web applications: Damn Vulnerable Web Application (DVWA) and OWASP Juice Shop, both running on a local LAMP (Linux, Apache, MySQL, PHP) stack in Parrot OS.
Installing the LAMP Stack
The LAMP stack provides the necessary environment for hosting web applications.
- Update Parrot OS:
Ensures the system is current.sudo apt update && sudo apt upgrade
- Install LAMP Components:
Installs Apache, MySQL, and PHP.sudo apt install apache2 mysql-server php php-mysql libapache2-mod-php
- Start Services:
Starts and enables services for automatic startup.sudo systemctl start apache2 sudo systemctl start mysql sudo systemctl enable apache2 sudo systemctl enable mysql
- Verify Apache: Open a browser and navigate to
http://localhost
to see the Apache default page.
Setting Up DVWA
DVWA is a deliberately vulnerable web application designed for learning penetration testing.
- Download DVWA:
Clones DVWA into Apache’s web directory.git clone https://github.com/digininja/DVWA.git /var/www/html/dvwa
- Configure DVWA:
- Copy the configuration file:
cp /var/www/html/dvwa/config/config.inc.php.dist /var/www/html/dvwa/config/config.inc.php
- Edit
/var/www/html/dvwa/config/config.inc.php
to set database credentials (default:root
, no password).
- Copy the configuration file:
- Configure MySQL:
sudo mysql CREATE DATABASE dvwa; GRANT ALL PRIVILEGES ON dvwa.* TO 'dvwa'@'localhost' IDENTIFIED BY 'p@ssw0rd'; FLUSH PRIVILEGES; EXIT;
- Set Permissions:
sudo chown -R www-data:www-data /var/www/html/dvwa sudo chmod -R 755 /var/www/html/dvwa
- Access DVWA: Navigate to
http://localhost/dvwa
, click “Create / Reset Database,” and log in withadmin
/password
.
Setting Up OWASP Juice Shop
OWASP Juice Shop is another vulnerable web application, simulating a modern e-commerce platform with diverse vulnerabilities.
- Install Node.js:
sudo apt install nodejs npm
- Download Juice Shop:
git clone https://github.com/juice-shop/juice-shop.git /var/www/html/juice-shop
- Install Dependencies:
cd /var/www/html/juice-shop npm install
- Start Juice Shop:
Access atnpm start
http://localhost:3000
. - Run as a Service (optional):
- Create a systemd service file:
Add:sudo nano /etc/systemd/system/juiceshop.service
[Unit] Description=OWASP Juice Shop After=network.target [Service] ExecStart=/usr/bin/npm start --prefix /var/www/html/juice-shop Restart=always [Install] WantedBy=multi-user.target
- Enable and start:
sudo systemctl enable juiceshop sudo systemctl start juiceshop
- Create a systemd service file:
Task: Install DVWA and OWASP Juice Shop on your LAMP stack, then access both applications to confirm they are operational.
Outcome: You have a fully functional test lab with DVWA and Juice Shop for practicing web pentesting.
Basic HTTP/HTTPS Concepts, Headers, and Cookies
Understanding the mechanics of web communication is essential for effective reconnaissance and exploitation. This section covers HTTP/HTTPS, headers, and cookies.
HTTP and HTTPS
HyperText Transfer Protocol (HTTP) is the foundation of web communication, enabling data exchange between clients (e.g., browsers) and servers.
- HTTP: Unencrypted protocol using port 80. Requests and responses are sent in plaintext, making them vulnerable to interception.
- HTTPS: Secure version of HTTP using TLS/SSL encryption on port 443, protecting data confidentiality and integrity.
- Request Methods:
- GET: Retrieves data (e.g., loading a webpage).
- POST: Submits data (e.g., form submissions).
- PUT, DELETE: Used for updating or deleting resources.
HTTP Headers
Headers provide metadata about HTTP requests and responses, influencing how data is processed.
- Common Request Headers:
- Host: Specifies the target domain (e.g.,
Host: example.com
). - User-Agent: Identifies the client (e.g.,
User-Agent: Mozilla/5.0
). - Cookie: Sends stored cookies to the server.
- Host: Specifies the target domain (e.g.,
- Common Response Headers:
- Server: Identifies the server software (e.g.,
Server: Apache/2.4.41
). - Content-Type: Specifies the response format (e.g.,
Content-Type: text/html
). - Set-Cookie: Instructs the client to store a cookie.
- Server: Identifies the server software (e.g.,
Cookies
Cookies are small data files stored by browsers to maintain stateful information, such as session IDs or user preferences.
- Types:
- Session Cookies: Temporary, deleted after the session ends.
- Persistent Cookies: Stored for a set duration.
- Security Implications: Cookies can be stolen via XSS or intercepted over HTTP, leading to session hijacking.
Task: Use your browser’s developer tools (e.g., F12) to inspect the headers and cookies for http://example.com
. Note the User-Agent
and any Set-Cookie
headers.
Outcome: You understand HTTP/HTTPS, headers, and cookies, enabling you to analyze web traffic during reconnaissance.
Reconnaissance Tools
Reconnaissance gathers information about a target to identify potential vulnerabilities. Parrot OS includes powerful tools for web reconnaissance, all demonstrated with example.com
as the target.
WhatWeb
WhatWeb identifies technologies, frameworks, and CMS used by a website.
- Basic Scan:
Detects server software, CMS, and plugins.whatweb http://example.com
- Aggressive Scan:
Performs a deeper analysis for detailed results.whatweb -a 3 http://example.com
- Output to File:
whatweb http://example.com -o whatweb_results.txt
Task: Run WhatWeb against http://localhost/dvwa
and http://example.com
(if accessible in your lab), and compare the technologies detected.
theHarvester
theHarvester collects emails, subdomains, and hosts associated with a domain for OSINT.
- Basic Search:
Queries Google for data related totheharvester -d example.com -b google
example.com
. - Multiple Sources:
Searches across multiple engines.theharvester -d example.com -b all
- Save Output:
theharvester -d example.com -b google -f results.html
Task: Use theHarvester to gather OSINT for example.com
and your local DVWA instance, saving results to a file.
Nmap
Nmap (Network Mapper) scans networks to discover hosts, ports, and services.
- Ping Scan:
Identifies live hosts associated withnmap -sP example.com
example.com
. - TCP SYN Scan:
Scans for open ports stealthily.sudo nmap -sS example.com
- Service/Version Detection:
Identifies services and versions.sudo nmap -sV example.com
- Save Output:
sudo nmap -sV example.com -oN nmap_results.txt
Task: Perform an Nmap service/version scan on example.com
(or localhost
in your lab) and analyze the results.
Dirb
Dirb brute-forces directories and files on web servers to uncover hidden resources.
- Basic Scan:
Scans for common directories.dirb http://example.com /usr/share/dirb/wordlists/common.txt
- Output to File:
dirb http://example.com -o dirb_results.txt
Task: Run Dirb against http://localhost/dvwa
and http://example.com
(if accessible), and note any discovered directories.
Gobuster
Gobuster is another directory brute-forcing tool with enhanced speed and flexibility.
- Basic Scan:
gobuster dir -u http://example.com -w /usr/share/wordlists/dirb/common.txt
- Include Extensions:
gobuster dir -u http://example.com -w /usr/share/wordlists/dirb/common.txt -x php,html,txt
Task: Use Gobuster to enumerate directories on http://localhost/juice-shop
and compare results with Dirb.
dnsenum
dnsenum enumerates DNS records to discover subdomains and infrastructure details.
- Basic Enumeration:
Lists DNS records fordnsenum example.com
example.com
. - Brute-Force Subdomains:
dnsenum --enum -f /usr/share/dnsenum/dns.txt example.com
- Save Output:
dnsenum example.com -o dns_results.xml
Task: Run dnsenum on example.com
and your local lab domain (if applicable) to identify subdomains.
Ethical Note: Only perform reconnaissance on systems you own or have explicit permission to test. Unauthorized scanning of example.com
or other live systems is illegal and unethical.
Outcome: You can use a suite of reconnaissance tools to gather critical information about web targets.
Practical Exercise
- Install and configure DVWA and OWASP Juice Shop on your LAMP stack.
- Inspect HTTP headers and cookies for
http://example.com
andhttp://localhost/dvwa
using browser developer tools. - Run WhatWeb against
http://example.com
andhttp://localhost/juice-shop
to identify technologies. - Use theHarvester to collect OSINT for
example.com
and save the results. - Perform an Nmap service/version scan on
example.com
(orlocalhost
in your lab). - Enumerate directories on
http://example.com
andhttp://localhost/dvwa
using Dirb and Gobuster. - Run dnsenum to discover subdomains for
example.com
.
Conclusion
Day 1 of this 7-day web application hacking series has laid the foundation for effective penetration testing using Parrot OS. By setting up a test lab with DVWA and OWASP Juice Shop, understanding HTTP/HTTPS, headers, and cookies, and mastering reconnaissance tools like WhatWeb, theHarvester, Nmap, Dirb, Gobuster, and dnsenum, you are equipped to gather critical information about web targets. These skills are essential for identifying vulnerabilities and planning attacks in a controlled, ethical environment. Continue practicing in your lab, and prepare for Day 2, where you will explore web vulnerability scanning with tools like Nikto and Burp Suite.
Next Steps:
- Experiment with additional Juice Shop challenges to understand web vulnerabilities.
- Explore other Parrot OS reconnaissance tools like Recon-ng.
- Engage with cybersecurity communities on platforms like X to share insights and learn best practices.