Nginx access.log 获取详细客户端请求
这几天参与到了攻防演练后端的开发项目,项目进入到最终部署阶段,由于是前后端分离的项目,所以对 nginx 的反向代理进行了学习。发现了 nginx.conf
配置文件中 access.log
字段可以获取到客户端的大部分请求数据,故有了使用反向代理进行钓鱼,获取客户端的登录数据盗取密码的思路。
http {
log_format main '$remote_addr - [$time_local] "$request" $status $body_bytes_sent "Content-Type: $http_content_type" "Request-Body: $request_body" '
'"$http_user_agent"';
access_log /var/log/nginx/access.log main;
...
}
以上是我的 nginx.conf
配置,它能够获取客户端的 IP 地址、访问时间、请求协议和路径、发送的数据长度、请求的类型以及请求的 Body
使用 HackBar 构造以下数据:

access.log记录如下:
IP地址 - [01/Apr/2022:09:46:08 +0800] "POST /api/msg HTTP/1.1" 200 51 "Content-Type: application/x-www-form-urlencoded" "Request-Body: msg=This+is+the+data+sent+from+the+client" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36"