15.4. 自定义HTTP日志记录

从Suricata 1.3.1开始,您可以启用自定义HTTP日志记录选项。

在suricata.yaml中,找到http日志部分,然后按如下方式编辑:

- http-log:
      enabled: yes
      filename: http.log
      custom: yes # enable the custom logging format (defined by custom format)
      customformat: "%{%D-%H:%M:%S}t.%z %{X-Forwarded-For}i %{User-agent}i %H %m %h %u %s %B %a:%p -> %A:%P"
      append: no
      #extended: yes     # enable this for extended logging information
      #filetype: regular # 'regular', 'unix_stream' or 'unix_dgram'

在http.log文件中,您将得到以下信息,例如:

8/28/12-22:14:21.101619 - Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:11.0) Gecko/20100101 Firefox/11.0  HTTP/1.1 GET us.cnn.com /video/data/3.0/video/world/2012/08/28/hancocks-korea-typhoon-bolavan.cnn/index.xml 200 16856 192.168.1.91:45111 -> 157.166.255.18:80
08/28/12-22:14:30.693856 - Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:11.0) Gecko/20100101 Firefox/11.0  HTTP/1.1 GET us.cnn.com /video/data/3.0/video/showbiz/2012/08/28/conan-reports-from-rnc-convention.teamcoco/index.xml 200 15789 192.168.1.91:45108 -> 157.166.255.18:80

支持的格式字符串列表如下:

  • %H-主机HTTP头(远程主机名)。ie:google.com

  • %H-请求协议。即:http/1.1

  • %M-请求方法。IE:获取

  • %u-url,包括查询字符串。ie:/搜索?Q=测量

  • %header_name i-定义的HTTP请求头名称的内容。即:

  • %用户代理i:mozilla/5.0(x11;ubuntu;linux i686;rv:11.0)gecko/20100101 firefox/11.0

  • %x-forwarded-for i:输出x-forwarded-for-http头中包含的IP地址(由反向代理插入)

  • %S-返回状态代码。如果是301和302,它将在括号中打印URL。即:200

  • %B-响应大小(字节)。即:15789

  • %header_name o-定义的HTTP响应头名称的内容

  • %strftime_format]t-所选strftime格式的HTTP事务的时间戳。即:08/28/12-22:14:30

  • %z—使用秒的精确时间。电话:693856

  • %A-客户端IP地址

  • %P-客户端端口号

  • %A-服务器IP地址

  • %P-服务器端口号

任何不可打印的字符都将以十六进制格式的字节值表示(其中,xx是十六进制代码)