Apache日志分析
debain/ubuntu
- 主配置文件通常位于
/etc/apache2/apache2.conf
或/etc/httpd/apache2.conf
。 - 访问日志 (
access.log
) 通常位于/var/log/apache2/access.log
。 - 错误日志 (
error.log
) 通常位于/var/log/apache2/error.log
。
Red Hat/CentOS
- 主配置文件通常位于
/etc/httpd/conf/httpd.conf
。 - 访问日志可能位于
/var/log/httpd/access_log
。 - 错误日志可能位于
/var/log/httpd/error_log
。
第一题
查询每个ip访问次数
awk ‘{print $1}’ access.log.1 | uniq -c | sort
答案
flag{192.168.200.2}
第二题
查询指定ip的请求头
awk ‘$1 == “192.168.200.2” {print $0}’ access.log.1 | tail
答案:
“Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36”
flag{2D6330F380F44AC20F3A02EED0958F66}
第三题
cat access.log.1 | grep -a “/index.php” | wc -l
答案:
flag{27}
第四题
awk ‘$1 == “192.168.200.2” {print $0}’ access.log.1 | wc -l
答案:
flag{6555}
第五题
grep -a -E ‘03/Aug/2023:08’ access.log.1 | awk ‘{print $1}’ | sort | uniq
答案:
log.1 | awk ‘{print $1}’ | sort | uniq
答案:
flag{5}