Day 2: Information Gathering & Scanning
Scanning the Web: Discovering Hidden Paths & Weak Services
Information gathering and scanning are pivotal steps in web application penetration testing, enabling security professionals to map a target’s attack surface and identify potential vulnerabilities. Building on the foundational knowledge from Day 1, this article delves deeper into reconnaissance techniques using Parrot OS, a Debian-based Linux distribution optimized for cybersecurity tasks. On Day 2 of this 7-day web application hacking series, we focus on advanced scanning techniques to uncover hidden directories, detect underlying technologies, identify outdated software, and enumerate subdomains. This article covers directory and file enumeration with Gobuster and Dirsearch, technology detection with WhatWeb and Wappalyzer, scanning for outdated software with Nikto and WPScan, and subdomain enumeration with Sublist3r and Amass, using example.com as the target for all commands. Additional tools like Wfuzz and Recon-ng are included to enhance your reconnaissance capabilities. All commands are designed for use in a controlled lab environment, such as the DVWA or OWASP Juice Shop setups from Day 1. By mastering these tools, you will be equipped to perform thorough reconnaissance ethically and effectively.
Verifying the Test Lab
Before proceeding with scanning, ensure your test lab from Day 1 (DVWA and OWASP Juice Shop) is operational.
- Check LAMP Stack:
Verify that Apache and MySQL are running.sudo systemctl status apache2 sudo systemctl status mysql - Access DVWA: Navigate to
http://localhost/dvwa, log in withadmin/password, and set the security level to “Low.” - Access Juice Shop: Navigate to
http://localhost:3000to confirm OWASP Juice Shop is running.
Ethical Note: All commands in this article use example.com for illustrative purposes. Only test on systems you own or have explicit permission to scan, such as your local lab. Unauthorized scanning of live systems like example.com is illegal and unethical.
Task: Verify that DVWA and OWASP Juice Shop are accessible in your local lab environment.
Outcome: Your test lab is ready for advanced scanning and reconnaissance.
Directory and File Enumeration
Directory and file enumeration identifies hidden or unprotected resources on a web server, such as configuration files or administrative panels, which may expose vulnerabilities.
Gobuster
Gobuster is a fast, flexible tool for brute-forcing directories and files on web servers.
- Basic Directory Enumeration:
Scansgobuster dir -u http://example.com -w /usr/share/wordlists/dirb/common.txtexample.comfor common directories using thecommon.txtwordlist. - Include File Extensions:
Searches for files withgobuster dir -u http://example.com -w /usr/share/wordlists/dirb/common.txt -x php,html,txt.php,.html, and.txtextensions. - Output to File:
Saves results togobuster dir -u http://example.com -w /usr/share/wordlists/dirb/common.txt -o gobuster_results.txtgobuster_results.txt. - Advanced Options:
Uses a larger wordlist, 50 threads, and additional file extensions.gobuster dir -u http://example.com -w /usr/share/wordlists/dirb/big.txt -t 50 -x php,html,txt,conf
Task: Run Gobuster against http://localhost/dvwa and http://example.com (in your lab) with the common.txt wordlist and compare discovered directories.
Dirsearch
Dirsearch is another directory enumeration tool with enhanced features for recursive scanning and filtering.
- Basic Scan:
Enumerates directories ondirsearch -u http://example.com -w /usr/share/wordlists/dirb/common.txtexample.com. - Include Extensions:
Targets specific file extensions.dirsearch -u http://example.com -e php,html,txt - Recursive Scanning:
Recursively scans discovered directories.dirsearch -u http://example.com -e php,html -r - Output to File:
Saves results in JSON format.dirsearch -u http://example.com -e php,html -o dirsearch_results.json
Task: Use Dirsearch to enumerate directories on http://localhost/juice-shop and http://example.com (in your lab), saving results to a file.
Outcome: You can enumerate hidden directories and files to uncover potential entry points.
Detecting Technologies
Identifying the technologies powering a web application (e.g., CMS, frameworks, servers) helps pinpoint known vulnerabilities.
WhatWeb
WhatWeb detects web server software, CMS, frameworks, and plugins.
- Basic Scan:
Identifies technologies onwhatweb http://example.comexample.com. - Aggressive Scan:
Performs a deeper analysis for detailed results.whatweb -a 3 http://example.com - Output to File:
Saves results to a text file.whatweb http://example.com -o whatweb_results.txt - JSON Output:
Exports results in JSON format.whatweb http://example.com --log-json=whatweb_results.json
Task: Run WhatWeb against http://example.com and http://localhost/dvwa in aggressive mode and analyze the detected technologies.
Wappalyzer
Wappalyzer is a browser extension and command-line tool for identifying web technologies.
- Install Wappalyzer CLI (if not pre-installed):
npm install -g @wappalyzer/wappalyzer - Basic Scan:
Detects technologies like CMS, frameworks, and libraries.wappalyzer http://example.com - Output to File:
Saves results in JSON format.wappalyzer http://example.com > wappalyzer_results.json
Alternative: Use the Wappalyzer browser extension in Firefox or Chrome to visually inspect http://example.com.
Task: Use Wappalyzer (CLI or browser extension) to identify technologies on http://example.com and http://localhost/juice-shop.
Outcome: You can identify web technologies to target potential vulnerabilities.
Scanning for Outdated Software
Outdated software often contains known vulnerabilities exploitable via public CVEs (Common Vulnerabilities and Exposures).
Nikto
Nikto scans web servers for misconfigurations, outdated software, and vulnerabilities.
- Basic Scan:
Scansnikto -h http://example.comexample.comfor common issues. - Output to File:
Saves results in HTML format.nikto -h http://example.com -o nikto_results.html - Tuning Options:
Limits scanning to specific tests (e.g., XSS, SQLi, outdated software).nikto -h http://example.com -Tuning 123
Task: Run Nikto against http://example.com and http://localhost/dvwa, saving results to a file, and review for outdated software.
WPScan
WPScan specializes in scanning WordPress sites for vulnerabilities, outdated plugins, and themes.
- Update WPScan:
Updates the vulnerability database.sudo wpscan --update - Basic Scan:
Scanswpscan --url http://example.comexample.comfor WordPress vulnerabilities. - Enumerate Users:
Lists usernames.wpscan --url http://example.com --enumerate u - Plugin Scanning:
Identifies vulnerable plugins.wpscan --url http://example.com --enumerate vp - Output to File:
wpscan --url http://example.com --output wpscan_results.json
Note: If example.com is not a WordPress site, test WPScan on a local WordPress instance set up in your lab.
Task: Install WordPress locally, then run WPScan against http://localhost/wordpress and http://example.com (if applicable) to identify vulnerabilities.
Outcome: You can detect outdated software and vulnerabilities in web servers and WordPress sites.
Subdomain Enumeration
Subdomain enumeration discovers additional domains associated with a target, potentially revealing hidden services or misconfigurations.
Sublist3r
Sublist3r uses OSINT and brute-forcing to enumerate subdomains.
- Basic Enumeration:
Lists subdomains forsublist3r -d example.comexample.com. - Brute-Force Subdomains:
Uses a wordlist for brute-forcing.sublist3r -d example.com -b -w /usr/share/wordlists/subdomains-top1million-5000.txt - Output to File:
sublist3r -d example.com -o sublist3r_results.txt
Task: Run Sublist3r on example.com and your local lab domain (if applicable) to enumerate subdomains.
Amass
Amass is a comprehensive tool for subdomain enumeration and network mapping.
- Basic Enumeration:
Enumerates subdomains foramass enum -d example.comexample.com. - Passive Enumeration:
Uses OSINT without active scanning.amass enum -passive -d example.com - Output to File:
amass enum -d example.com -o amass_results.txt - Brute-Force:
amass enum -brute -d example.com -w /usr/share/wordlists/subdomains-top1million-5000.txt
Task: Use Amass to perform passive and brute-force subdomain enumeration on example.com and compare results with Sublist3r.
Outcome: You can enumerate subdomains to expand the attack surface of a target.
Additional Tools: Wfuzz and Recon-ng
To enhance your reconnaissance capabilities, Parrot OS includes Wfuzz for fuzzing and Recon-ng for advanced OSINT.
Wfuzz
Wfuzz is a versatile fuzzing tool for discovering hidden resources and testing parameters.
- Directory Fuzzing:
Fuzzes directories, hiding 404 responses.wfuzz -u http://example.com/FUZZ -w /usr/share/wordlists/dirb/common.txt --hc 404 - Parameter Fuzzing:
Tests URL parameters.wfuzz -u "http://example.com/index.php?FUZZ=test" -w /usr/share/wordlists/dirb/common.txt --hc 404 - Output to File:
wfuzz -u http://example.com/FUZZ -w /usr/share/wordlists/dirb/common.txt --hc 404 -o wfuzz_results.csv
Task: Use Wfuzz to fuzz directories on http://example.com and http://localhost/dvwa, saving results to a CSV file.
Recon-ng
Recon-ng is a modular framework for OSINT and reconnaissance.
- Launch Recon-ng:
recon-ng - Enumerate Subdomains:
Discovers subdomains using Bing.marketplace install recon/domains-hosts/bing_domain_web modules load recon/domains-hosts/bing_domain_web set SOURCE example.com run - Save Output:
show hosts > reconng_results.txt
Task: Use Recon-ng to enumerate subdomains for example.com and export results to a file.
Outcome: You can use advanced fuzzing and OSINT tools to enhance reconnaissance.
Practical Exercise
- Verify your DVWA and OWASP Juice Shop lab setup.
- Enumerate directories on
http://example.comandhttp://localhost/dvwausing Gobuster and Dirsearch. - Detect technologies on
http://example.comandhttp://localhost/juice-shopwith WhatWeb and Wappalyzer. - Scan for outdated software on
http://example.comandhttp://localhost/dvwausing Nikto. - Run WPScan on a local WordPress instance and
http://example.com(if applicable). - Enumerate subdomains for
example.comusing Sublist3r and Amass. - Test Wfuzz and Recon-ng on
http://example.comand your local lab.
Conclusion
Day 2 of this 7-day web application hacking series has equipped you with advanced reconnaissance and scanning techniques using Parrot OS. By mastering Gobuster and Dirsearch for directory enumeration, WhatWeb and Wappalyzer for technology detection, Nikto and WPScan for identifying outdated software, and Sublist3r and Amass for subdomain enumeration, along with Wfuzz and Recon-ng, you can thoroughly map a target’s attack surface. These skills are critical for identifying vulnerabilities in a controlled, ethical environment. Continue practicing in your lab, and prepare for Day 3, where you will explore web vulnerability exploitation techniques.
Next Steps:
- Combine results from multiple tools to create a comprehensive target profile.
- Explore additional Parrot OS tools like OWASP ZAP for vulnerability scanning.
- Engage with cybersecurity communities on platforms like X to share insights and learn best practices.