【玄机】日志分析-apache日志分析

文章详细分析了cataccess.log文件中的数据,揭示黑客IP地址、使用的浏览器指纹,以及对特定页面的访问频率和时间分布,展示了通过Apache服务器日志进行安全审计的方法。
摘要由CSDN通过智能技术生成

题目地址:https://xj.edisec.net/challenges/29

1、提交当天访问次数最多的IP,即黑客IP:

cat access.log.1 | grep "03/Aug/2023:08:" | awk '{print $1}' | sort | uniq -c | sort -nr | head -n 10
​
flag{192.168.200.2}

2、黑客使用的浏览器指纹是什么,提交指纹的md5:

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}

3、查看index.php页面被访问的次数,提交次数:

cat access.log.1 | grep "/index.php" | wc -l
flag{27}

4、查看黑客IP访问了多少次,提交次数:

cat access.log.1 | grep "192.168.200.2 - -"  | wc -l
​
flag{6555}

5、查看2023年8月03日8时这一个小时内有多少IP访问,提交次数:

cat access.log.1 | grep "03/Aug/2023:08:" | awk '{print $1}' | sort -nr| uniq -c 
      1 192.168.200.48
      5 192.168.200.38
      1 192.168.200.211
   6555 192.168.200.2
     29 ::1
​
​
flag{5}

回顾下日志格式

11.104.211.13 -- [03/Mar /2020:15:23:17 +0800] "POST  /perbank/add.do HTTP/1.1"   200  254  0  "https://pbank.psbc/com/preperbank/index.html" "Mozilla/5.0 (windows NT 10.0 wow64) AppleweKit/537.36(KHTML, like Gecko) Chrome/77.0.3865 Safari/537.36"
117.136.38.168 -- [03/Mar /2020:15:23:17 +0800] "POST  /preperbank/add.do HTTP/1.1"   200  254  0  "https://pbank.psbc/com/preperbank/index.html" "Mozilla/5.0 (windows NT 10.0 wow64) AppleweKit/537.36(KHTML, like Gecko) Chrome/77.0.3865 Safari/537.36"
​
​
1.11.104.211.13 : 远端主机地址,客户端发送到apach服务器时服务器的地址,服务器返回数据时客户端的地址,如果 客户端使用了代理服务器,那么这里的ip就是代理服务器的地址。
​
2.- 远端登录名(由identd而来,如果支持的话),除非IdentityCheck设为"On",否则将得到一个"-"。
The "hyphen" in the output indicates that the requested piece of information is not available. In this case, the information that is not available is the RFC 1413 identity of the client determined by identd on the clients machine. This information is highly unreliable and should almost never be used except on tightly controlled internal networks. Apache httpd will not even attempt to determine this information unless IdentityCheck is set to On.
​
3.- 远程用户名(根据验证信息而来;如果返回status(%s)为401,可能是假的)
​
4.[03/Mar /2020:15:23:17 +0800] 请求的时间,格式为[day/month/year:hour:minute:second zone],最后的+0800表示服务器所处的时区为东八区
​
5."POST /perbank/add.do HTTP/1.1" 请求的第一行,请求方法/访问路径/协议
​
6.200 这是一个状态码,由服务器端发送回客户端,它告诉我们客户端的请求是否成功,或者是重定向,或者是碰到了什么样的错误,这项值为200,表示服务器已经成 功的响应了客户端的请求,一般来说,这项值以2开头的表示请求成功,以3开头的表示重定向,以4开头的标示客户端存在某些的错误,以5开头的标示服务器端 存在某些错误,详细的可以参见 HTTP specification (RFC2616 section 10).
​
7.254 以CLF格式显示的除HTTP头以外传送的字节数,也就是当没有字节传送时显示'-'而不是0。它告诉我们传输是否被打断(该数值是否和文件的大小相同)。把日志记录中的这些值加起来就可以得知服务器在一天、一周或者一月内发送了多少数据。
​
8.0 "%{Referer}i" 接收的字节数,包括请求头的数据,并且不能为零。要使用这个指令你必须启用mod_logio模块。
​
9."https://pbank.psbc/com/preperbank/index.html" "Mozilla/5.0 (windows NT 10.0 wow64) AppleweKit/537.36(KHTML, like Gecko) Chrome/77.0.3865 Safari/537.36" 客户端的浏览器信息
​
10.格式定义再/etc/httpd/conf/httpd.conf
​
11.LogFormat "%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i"" combined
​

使用脚本进行分析

1.查看apache的进程数

ps -aux | grep httpd | wc -l

2.分析日志查看当天的ip连接数

cat access.log | grep "10/Dec/2010" | awk '{print $2}' | sort | uniq -c | sort -nr

3.查看指定的ip在当天究竟访问了什么url

cat access.log | grep "10/Dec/2010" | grep "218.19.140.242" | awk '{print $7}' | sort | uniq -c | sort -nr

4.查看当天访问排行前10的url

cat access.log | grep "10/Dec/2010" | awk '{print $7}' | sort | uniq -c | sort -nr | head -n 10

5.看到指定的ip究竟干了什么

cat access.log | grep 218.19.140.242 | awk '{print $1"\t"$8}' | sort | uniq -c | sort -nr | less

6.查看访问次数最多的几个分钟(找到热点)

awk '{print $4}' access.log |cut -c 14-18|sort|uniq -c|sort -nr|head
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值