Cyber Services / All lessons / CEH — Ethical Hacking / CEH Module 13 Guide Web Server Hacking

CEH Module 13 Guide Web Server Hacking

Module 74 of 130 · 8 min read · Free to read

MODULES ↓ Command blocks have a COPY button

Web servers are often the public face of an organization and a primary target for attackers. Module 13 focuses on techniques used to gather information about web servers (reconnaissance and footprinting) and exploit common weaknesses, particularly in associated services like FTP. Understanding these attack vectors is essential for securing web infrastructure.

Why Target Web Servers?
  • Host websites, potentially containing vulnerabilities (XSS, SQLi, File Inclusion).
  • Often run associated services (FTP, SSH, databases) that can be attacked.
  • Can be gateways to internal networks if compromised.
  • Hold potentially sensitive configuration files or user data.
  • Can be defaced for reputational damage or used to host malware.
Ethical Boundaries: All reconnaissance and attack techniques discussed must only be performed against systems for which you have explicit, written authorization. Attacking web servers without permission is illegal.

I. Web Server Reconnaissance & Footprinting

Before launching an attack, understanding the target web server's technology stack, configuration, and potential vulnerabilities is crucial. This involves gathering information passively and actively.

Tool: Skipfish

Skipfish is an active web application security reconnaissance tool developed by Google. It operates by performing a recursive crawl (spidering) of the target website, similar to a search engine bot, but also actively probes discovered pages and parameters for various security misconfigurations and potential vulnerabilities (like SQLi, XSS hints, directory traversal, etc.). It's known for its high speed and thoroughness but can be resource-intensive on the scanning machine and generate significant network traffic ("noisy").

Key Concepts:

  • Active Scanning: Directly interacts with the web application, sending probes.
  • Recursive Crawl: Follows links found on pages to discover more content.
  • Dictionary Probes: Uses wordlists to guess common file/directory names and parameters.
  • Security Checks: Performs various lightweight checks for common vulnerability patterns.

Common Options:

  • -o dir: Required. Specify the output directory to store the report files.
  • -S file: Specify a main dictionary file (wordlist) for brute-forcing filenames/directories. (e.g., complete.wl).
  • -W file: Specify a "do-not-fuzz" dictionary (read-only). Words from this list won't be mutated/fuzzed during checks. Useful for known-good parameters.
  • -I string: Only follow URLs containing the specified substring. Useful for scoping the scan to a specific path (e.g., `-I /app/`).
  • -X string: Exclude URLs containing the specified substring (e.g., `-X /logout`).
  • -d depth: Maximum crawl depth (default: 16). Limits how many links deep Skipfish will follow.
  • -c limit: Maximum concurrent connections (default: 10). Increase carefully, can overwhelm server.
  • -l req/s: Maximum requests per second (default: 100). Lower this to reduce server load/noise.
  • -A user:pass: Credentials for HTTP Basic/Digest Authentication.
  • -C name=val: Add a custom cookie to all requests (e.g., `-C "sessionid=abcdef123"`).
  • -H name=val: Add a custom HTTP header to all requests (e.g., `-H "X-Custom-Header: Test"`).
  • -k duration: Stop scan after specified duration (e.g., `-k 1h`, `-k 30m`).
  • -u: Be less aggressive about binary file types to reduce noise.

Practical Examples:

1. Basic Scan with Default Dictionary:

Scan a target URL, saving results to `/tmp/skipfish_basic`. Skipfish often finds default dictionaries automatically.


skipfish -o /tmp/skipfish_basic http://target-site.com

2. Scan with Specific Dictionary & Limited Depth:

Use the comprehensive dictionary and limit the crawl depth to 5 levels.


skipfish -o /tmp/skipfish_depth5 -S /usr/share/skipfish/dictionaries/complete.wl -d 5 http://target-site.com:8080

Note: Dictionary path might vary slightly depending on installation.

3. Authenticated Scan (HTTP Basic Auth):

Scan a site requiring authentication.


skipfish -o /tmp/skipfish_auth -A testuser:password123 -S /usr/share/skipfish/dictionaries/minimal.wl https://secure.target.com

4. Scan with Cookie for Session Handling:

Include a session cookie obtained after logging in via a browser.


skipfish -o /tmp/skipfish_cookie -C "PHPSESSID=a1b2c3d4e5f6" -S /usr/share/skipfish/dictionaries/complete.wl http://webapp.target.com

5. Scoped Scan (Include Specific Path Only):

Only crawl and test URLs under the `/user/profile/` directory.


skipfish -o /tmp/skipfish_scoped -I /user/profile/ http://large-site.com

6. Excluding Logout Paths:

Prevent Skipfish from hitting logout links which could invalidate sessions.


skipfish -o /tmp/skipfish_no_logout -X /logout -X /signout -C "session=..." http://portal.target.com

7. Slower Scan (Reduced Rate):

Limit requests to 10 per second to be less intrusive.


skipfish -o /tmp/skipfish_slow -l 10 http://sensitive-target.com

Viewing the Report:

After the scan finishes (or is stopped with Ctrl+C), navigate to the specified output directory (`-o dir`). Open the index.html file in a web browser.

firefox /tmp/skipfish_basic/index.html

The report provides a detailed overview of findings categorized by severity and type, showing discovered URLs, potential issues, and risk scores.

Interpreting Results: Skipfish reports often contain many findings, including low-severity items and potential false positives. Prioritize high-risk issues. Always manually verify potential vulnerabilities reported by any automated scanner before including them in a final report. Understand the context of the finding within the application.
Noise & Resource Warning: Skipfish generates a large number of requests. Inform the target organization if running against production systems (with permission!). Ensure your scanning machine has adequate RAM and CPU resources, especially for deep crawls or large sites.
Tool: Uniscan

Another web vulnerability scanner available on Kali Linux. It combines multiple techniques like directory checks, file checks, basic vulnerability checks, and web server fingerprinting.

Common Uniscan Flags (Kali):

# Display help menu
uniscan -h

# Basic scan - Directory checks (-q)
# Syntax: uniscan -u target_url_with_path -q
# Example:
uniscan -u http://10.10.10.12:8080/CEH -q

# Directory and File checks (-q -w)
# Syntax: uniscan -u target_url_with_path -qw
# Example:
uniscan -u http://10.10.10.12:8080/CEH -qw

# Directory and Dynamic checks (-q -d)
# Syntax: uniscan -u target_url_with_path -qd
# Example:
uniscan -u http://10.10.10.12:8080/CEH -qd

# Web fingerprinting and file checks (-w -e)
# Syntax: uniscan -u target_url_with_path -we
# Example:
uniscan -u http://10.10.10.12:8080/CEH -we

Full Scan Example (can be slow and noisy): uniscan -u http://10.10.10.12:8080/CEH -qdew

Reports are typically saved in /usr/share/uniscan/report/.

Windows-Based Footprinting Tools (Mentioned in Notes):
  • httprecon: A tool designed specifically for advanced web server fingerprinting. It attempts to identify the server software (Apache, IIS, Nginx) and its version even if standard banners are obfuscated, by analyzing HTTP header ordering and other subtle characteristics.
  • ID Serve: Another Windows utility focused on identifying web server software and versions by analyzing server response headers.

While these specific tools are Windows-based, similar fingerprinting capabilities exist in Linux tools like Nmap (-sV), Nikto, and dedicated fingerprinting scripts or frameworks.

II. Attacking Associated Services: FTP Credential Cracking

Web servers often run alongside other services like FTP (File Transfer Protocol), which can be a target for attackers if not properly secured. A common attack is brute-forcing login credentials.

Tool: Hydra

A very fast and flexible network logon cracker that supports numerous protocols, including FTP, SSH, Telnet, HTTP Basic/Digest Auth, SMB, various databases, and more. It uses dictionary attacks (wordlists) for usernames and passwords.

Scenario: Brute-Forcing FTP Login with Hydra

1. Identify Open FTP Port (Kali - Prerequisite):

Use Nmap to confirm the target is running an FTP server on the default port 21.

Syntax:

nmap -p 21 Target_IP

Example: nmap -p 21 10.10.10.10

Look for output indicating port 21/tcp is `open` and potentially the FTP service version.

2. Prepare Wordlists (Kali):

You need lists of potential usernames and passwords. Kali often includes common lists in /usr/share/wordlists/. For this example, assume you have custom lists:

  • /root/Desktop/Wordlists/Usernames.txt
  • /root/Desktop/Wordlists/Passwords.txt

3. Launch Hydra Attack (Kali):

Syntax:

# -L userlist_file : Specify the username list file
# -P passlist_file : Specify the password list file
# ftp://Target_IP : Specify the target service (FTP) and IP address

hydra -L userlist_file -P passlist_file ftp://Target_IP

Example: hydra -L /root/Desktop/Wordlists/Usernames.txt -P /root/Desktop/Wordlists/Passwords.txt ftp://10.10.10.10

Tip: Add -V (verbose) to see attempts in real-time. Add -t tasks (e.g., -t 16) to increase parallel connections (can be faster but noisier).

4. Analyze Results:

Hydra will try combinations from the lists. If successful, it will output the valid username and password combination it found.

Brute-forcing can be noisy and may lock out accounts depending on server configuration. Use responsibly during authorized tests.

III. Common Web Server Vulnerabilities & Countermeasures

While this module focuses on reconnaissance and attacking associated services, it's crucial to remember common web application vulnerabilities often hosted on these servers:

  • Misconfiguration: Default credentials, directory listing enabled, verbose error messages, unnecessary services running.
  • Outdated Software: Running old versions of web server software (Apache, Nginx, IIS), CMS (WordPress, Joomla), or underlying components (PHP, Java) with known vulnerabilities (CVEs).
  • Injection Flaws: SQL Injection, Command Injection, LDAP Injection.
  • Cross-Site Scripting (XSS): Reflected, Stored, DOM-based.
  • Insecure Authentication/Session Management: Weak passwords, predictable session IDs, lack of MFA.
  • File Inclusion Vulnerabilities: Local File Inclusion (LFI), Remote File Inclusion (RFI).
  • Insecure File Uploads: Allowing upload of malicious scripts.
Key Countermeasures:
  • Regular Patching & Updates: Keep web server software, CMS, plugins, themes, and OS components up-to-date.
  • Secure Configuration: Disable unnecessary services/modules, disable directory listing, customize error pages, use strong credentials, follow hardening guides for specific software.
  • Web Application Firewall (WAF): Filter malicious requests (SQLi, XSS attempts), enforce security policies.
  • Input Validation & Output Encoding: Critical for preventing injection attacks and XSS.
  • Secure Authentication: Enforce strong password policies, implement MFA, secure session management (HttpOnly/Secure cookies, regeneration).
  • Least Privilege: Run web server processes with minimal necessary permissions. Restrict database user privileges.
  • Vulnerability Scanning & Penetration Testing: Regularly scan web applications and infrastructure (using tools like those mentioned, plus dynamic scanners like OWASP ZAP/Burp Suite) and perform authorized penetration tests.
  • Secure FTP Alternatives: Use SFTP (SSH File Transfer Protocol) or FTPS (FTP over SSL/TLS) instead of plain FTP. Disable anonymous FTP access unless absolutely required. Implement strong FTP passwords and consider IP restrictions.

Conclusion

Hacking web servers often begins with thorough reconnaissance using tools like Skipfish, Uniscan, Nmap, and others to understand the attack surface. Attackers then probe for misconfigurations, outdated software, or vulnerabilities in associated services like FTP, often using brute-force tools like Hydra. Defending web servers requires a defense-in-depth strategy encompassing secure configuration, regular patching, WAFs, secure coding practices, and continuous monitoring and testing.

Modules (130) ← CEH — Ethical Hacking