Log Analysis on Web Servers
Log Analysis on Web Servers for Incident Response
Log analysis is critical for identifying malicious activities such as SQL Injection, Directory Traversal, and other web-based attacks. By focusing on access and error logs, incident responders can detect and mitigate these threats effectively.
Key Log Files and Their Locations
Web Server | Log Type | Log Location |
Apache | Access Logs |
|
Error Logs |
| |
Nginx | Access Logs |
|
Error Logs |
| |
IIS | Access Logs |
|
System Logs | General Activity |
|
Case 1: SQL Injection Analysis (Apache)
SQL Injection exploits occur when an attacker inserts malicious SQL queries into input fields, aiming to manipulate the database.
Steps to Analyze SQL Injection Logs
View Access Logs:
Search for Common SQL Injection Payloads: Filter requests containing SQL keywords:
Filter by HTTP 200 Response: Focus on successful injection attempts:
URL Decode Suspicious Entries: Decode encoded URLs to reveal clear SQL queries:
Check Admin Panel Access: After exploitation, verify if the attacker accessed sensitive areas:
Example Decoded URL:
This indicates user credentials extraction.
Case 2: Directory Traversal Attack (Nginx)
Directory Traversal involves navigating outside the web root directory by exploiting file paths like ../
.
Steps to Detect Directory Traversal
Filter for Directory Traversal Attempts:
Check for Sensitive File Access: Look for attempts to access files like
/etc/passwd
:Inspect Successful Attempts: Focus on HTTP 200 responses for sensitive files:
Observation:
If you notice /etc/passwd
being downloaded:
This indicates a successful traversal exploit.
Case 3: Log Analysis on IIS Web Servers
IIS logs provide rich details about HTTP requests, including timestamps, client IPs, and request details.
Sample Log Entry:
Field | Description |
Timestamp | Event time |
Client IP | IP address of the request origin |
HTTP Method | Type of request (GET, POST) |
URL Requested | Resource path |
HTTP Status | Server response (200, 404, 500) |
Steps to Detect Suspicious Activities:
Search for SQL Injection:
Detect Directory Traversal:
Additional Tools for Enhanced Analysis
Wireshark:
Inspect network traffic and POST request payloads.
mod_security or mod_forensic:
Enhance Apache logging by capturing detailed request and response data.
Splunk / ELK Stack:
Centralize logs for real-time correlation and visualization.
Key Log Fields for Analysis
Access Logs:
Example:
IP Address:
192.168.1.1
Timestamp:
[12/Nov/2024:12:34:56 +0000]
Request Method:
GET
URL:
/index.html
Status Code:
200
(Success)Response Size:
1024 bytes
Error Logs:
Example:
Error Level:
[error]
Client IP:
192.168.1.1
Message: File not found error.
Best Practices for Log Analysis
Centralize Logs: Use tools like the ELK Stack (Elasticsearch, Logstash, Kibana) or Graylog to correlate and visualize log data across multiple systems.
Automate Routine Checks: Create reusable shell scripts for recurring analysis tasks:
Set Alerts for Critical Events:
Repeated failed login attempts.
High-frequency 404/500 errors.
Unauthorized access patterns.
Log Retention Policies: Ensure logs are stored securely and retained for an adequate period to support long-term investigations.
Key Points
Web log analysis is a cornerstone of effective incident response. By focusing on patterns related to SQL Injection, Directory Traversal, and other web exploits, analysts can quickly detect malicious activities and take appropriate action. Mastering these techniques and leveraging automation ensures a proactive defense against evolving threats.
Last updated