Eve JSON 'jq' 使用示例 ====================== jq工具对于快速解析和过滤JSON文件非常有用。本页面包含各种将其与Suricata的Eve.json结合使用的示例。 基础用法可参考这里: * https://www.stamus-networks.com/2015/05/18/looking-at-suricata-json-events-on-command-line/ 彩色输出 --------------- :: tail -f eve.json | jq -c '.' DNS NXDOMAIN响应 ------------ :: tail -f eve.json|jq -c 'select(.dns.rcode=="NXDOMAIN")' 独特的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 主机数据使用量 ------------------- :: 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 监控部分统计信息 ------------------------- :: $ tail -f eve.json | jq -c 'select(.event_type=="stats")|.stats.decoder' 检查警报数据 ------------------ :: cat eve.json | jq -r -c 'select(.event_type=="alert")|.payload'|base64 --decode Top 10目标端口 ------------------------ :: cat eve.json | jq -c 'select(.event_type=="flow")|[.proto, .dest_port]'|sort |uniq -c|sort -nr|head -n10