19.1.3. Eve JSON 'jq' 使用示例

jq工具对于快速解析和过滤JSON文件非常有用。本页面包含各种将其与Suricata的Eve.json结合使用的示例。

基础用法可参考这里:

19.1.3.1. 彩色输出

tail -f eve.json | jq -c '.'

19.1.3.2. DNS NXDOMAIN响应

tail -f eve.json|jq -c 'select(.dns.rcode=="NXDOMAIN")'

19.1.3.3. 独特的HTTP用户代理

cat eve.json | jq -s '[.[]|.http.http_user_agent]|group_by(.)|map({key:.[0],value:(.|length)})|from_entries'

来源:https://twitter.com/mattarnao/status/601807374647750657

19.1.3.4. 主机数据使用量

tail -n500000 eve.json | jq -s 'map(select(.event_type=="netflow" and .dest_ip=="192.168.1.3").netflow.bytes)|add'|numfmt --to=iec
1.3G

注意:可能占用大量内存。 来源:https://twitter.com/pkt_inspector/status/605524218722148352

19.1.3.5. 监控部分统计信息

$ tail -f eve.json | jq -c 'select(.event_type=="stats")|.stats.decoder'

19.1.3.6. 检查警报数据

cat eve.json | jq -r -c 'select(.event_type=="alert")|.payload'|base64 --decode

19.1.3.7. Top 10目标端口

cat eve.json | jq -c 'select(.event_type=="flow")|[.proto, .dest_port]'|sort |uniq -c|sort -nr|head -n10