Effective Apache Log Analysis Techniques on Linux: A Comprehensive Guide

Network security

1. Submit the IP with the most visits on the same day, i.e., the hacker’s IP

The middleware is identified as Apache running on Linux, and typical log paths for Apache log analysis are usually:

  1. /var/log/apache/
  2. /var/log/apache2/
  3. /var/log/httpd/

Here the log path is located at /var/log/apache2. Using the command ls -lah to determine the log file based on size, we find that the log file is access.log.1, because the size of access.log is 0.

Apache log analysis

Using the command cat access.log.1 | cut -d ' ' -f 1 | sort | uniq -c | sort -nr reveals that the IP address with the most visits is: 192.168.200.2.

Apache log analysis

flag{192.168.200.2}

2. What is the browser fingerprint used by the hacker? Submit the fingerprint’s MD5

Using the command cat access.log.1 | grep 192.168.200.2 | cut -d '"' -f 6 | sort | uniq -c | sort -nr reveals two browser fingerprints, with the most frequent one being: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36.

Using the command echo -n "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36" | md5sum calculates the MD5 value, resulting in: 2D6330F380F44AC20F3A02EED0958F66.

It is important to note that, by default, the echo command automatically adds a newline character at the end of the output text, which affects the MD5 result. Therefore, the echo command needs to include the -n parameter to suppress the newline output, otherwise, the calculated MD5 value will be incorrect.

flag{2D6330F380F44AC20F3A02EED0958F66}

3. Determine the number of times the index.php page was accessed using Apache log analysis and record the count

Using the command cat access.log.1 | grep ' /index.php ' calculates the number of times the /index.php page was accessed (note that grep includes spaces before and after /index.php), which is 2 times, but this is not the answer.

Using the command cat access.log.1 | grep '/index.php ' calculates the number of times pages ending with /index.php were accessed (grep includes a space before /index.php), which is 24 times, but this is not the answer.

Using the command cat access.log.1 | grep '/index.php' calculates the number of times pages, as well as referring pages (Referer), containing /index.php were accessed (grep has no space before /index.php), which is 27 times, and this is the answer.

Although the answer is flag{27}, I believe the real answer should be flag{2}.

4. Check how many times the hacker’s IP was accessed, submit the number of times

As identified in the first question, the hacker’s IP address is: 192.168.200.2. Therefore, the number of accesses is: 6555.

Apache log analysis

flag{6555}

5. Check how many IPs accessed within the hour at 8 AM on August 3, 2023, submit the number of IPs

Using the command Aug/2023:08: | cut -d ' ' -f 1 | sort | uniq -c | sort -nr filters the source IP addresses from the access records at 8 AM on August 3, 2023, and counts to be 5.

flag{5}

Share this