grippo 0.1.1

Parse, match and scrub data at scale.
Documentation
# ScreenOS traffic log: `NetScreen device_id=NAME [Root]system-notification-NNNNN(traffic): start_time="..." duration=N policy_id=N service=S proto=N src zone=Z dst zone=Z action=A sent=N rcvd=N src=IP dst=IP src_port=N dst_port=N src-xlated ip=IP port=N dst-xlated ip=IP port=N session_id=N reason=R`.
NETSCREENSESSIONLOG %{SYSLOGTIMESTAMP:date} %{IPORHOST:device} %{IPORHOST}: NetScreen device_id=%{WORD:device_id}[^:]*: start_time=%{QUOTEDSTRING:start_time} duration=%{INT:duration} policy_id=%{INT:policy_id} service=%{DATA:service} proto=%{INT:proto} src zone=%{DATA:src_zone} dst zone=%{DATA:dst_zone} action=%{WORD:action} sent=%{INT:sent} rcvd=%{INT:rcvd} src=%{IPORHOST:src_ip} dst=%{IPORHOST:dst_ip} src_port=%{INT:src_port} dst_port=%{INT:dst_port} src-xlated ip=%{IPORHOST:src_xlated_ip} port=%{INT:src_xlated_port} dst-xlated ip=%{IPORHOST:dst_xlated_ip} port=%{INT:dst_xlated_port} session_id=%{INT:session_id} reason=%{GREEDYDATA:reason}

# Cisco ASA syslog: `<pri>timestamp host : %ASA-severity-id: text`, where severity is 0-7 and the id is a six-digit message number.
CISCO_TAGGED_SYSLOG ^<%{NONNEGINT:syslog_pri}>%{CISCOTIMESTAMP:timestamp}(?: %{SYSLOGHOST:sysloghost})? ?: %%{CISCOTAG:ciscotag}:
CISCOTIMESTAMP %{MONTH} +%{MONTHDAY}(?: %{YEAR})? %{TIME}
CISCOTAG [A-Z0-9]+-[0-7]-[0-9]+
# Words that recur in the message reference: actions, directions, hit-count intervals, translation types, and a free-text reason such as `TCP FINs` or `TCP Reset-I`.
CISCO_ACTION (?:Built|Teardown|Deny|denied by ACL|Denied|denied|requested|permitted|discarded|est-allowed|Dropping|created|deleted)
CISCO_REASON [A-Za-z0-9_-]+(?: [A-Za-z0-9_-]+)*
CISCO_DIRECTION (?:Inbound|inbound|Outbound|outbound)
CISCO_INTERVAL (?:first hit|%{INT}-second interval)
CISCO_XLATE_TYPE (?:static|dynamic)
# 104001-104004: failover state changes.
CISCOFW104001 \((?:Primary|Secondary)\) Switching to ACTIVE - %{GREEDYDATA:switch_reason}
CISCOFW104002 \((?:Primary|Secondary)\) Switching to STANDBY - %{GREEDYDATA:switch_reason}
CISCOFW104003 \((?:Primary|Secondary)\) Switching to FAILED\.
CISCOFW104004 \((?:Primary|Secondary)\) Switching to OK\.
# 105003-105009: failover interface monitoring.
CISCOFW105003 \((?:Primary|Secondary)\) Monitoring on [Ii]nterface %{GREEDYDATA:interface_name} waiting
CISCOFW105004 \((?:Primary|Secondary)\) Monitoring on [Ii]nterface %{GREEDYDATA:interface_name} normal
CISCOFW105005 \((?:Primary|Secondary)\) Lost Failover communications with mate on [Ii]nterface %{GREEDYDATA:interface_name}
CISCOFW105008 \((?:Primary|Secondary)\) Testing [Ii]nterface %{GREEDYDATA:interface_name}
CISCOFW105009 \((?:Primary|Secondary)\) Testing on [Ii]nterface %{GREEDYDATA:interface_name} (?:Passed|Failed)
# 106001: `Inbound TCP connection denied from IP/port to IP/port flags FLAGS on interface NAME`.
CISCOFW106001 %{CISCO_DIRECTION:direction} %{WORD:protocol} connection %{CISCO_ACTION:action} from %{IP:src_ip}/%{INT:src_port} to %{IP:dst_ip}/%{INT:dst_port} flags %{GREEDYDATA:tcp_flags} on interface %{GREEDYDATA:interface}
# 106006, 106007, 106010: `Deny inbound UDP from IP/port to IP/port on interface NAME` or `due to REASON`, with an optional (user) after either address.
CISCOFW106006_106007_106010 %{CISCO_ACTION:action} %{CISCO_DIRECTION:direction} %{WORD:protocol} (?:from|src) %{IP:src_ip}/%{INT:src_port}(?:\(%{DATA:src_fwuser}\))? (?:to|dst) %{IP:dst_ip}/%{INT:dst_port}(?:\(%{DATA:dst_fwuser}\))? (?:on interface %{DATA:interface}|due to %{CISCO_REASON:reason})
# 106014: `Deny inbound icmp src IFACE:IP dst IFACE:IP (type N, code N)`.
CISCOFW106014 %{CISCO_ACTION:action} %{CISCO_DIRECTION:direction} %{WORD:protocol} src %{DATA:src_interface}:%{IP:src_ip}(?:\(%{DATA:src_fwuser}\))? dst %{DATA:dst_interface}:%{IP:dst_ip}(?:\(%{DATA:dst_fwuser}\))? \(type %{INT:icmp_type}, code %{INT:icmp_code}\)
# 106015: `Deny TCP (no connection) from IP/port to IP/port flags FLAGS on interface NAME`.
CISCOFW106015 %{CISCO_ACTION:action} %{WORD:protocol} \(%{DATA:policy_id}\) from %{IP:src_ip}/%{INT:src_port} to %{IP:dst_ip}/%{INT:dst_port} flags %{DATA:tcp_flags} on interface %{GREEDYDATA:interface}
# 106021: `Deny tcp reverse path check from IP to IP on interface NAME`.
CISCOFW106021 %{CISCO_ACTION:action} %{WORD:protocol} reverse path check from %{IP:src_ip} to %{IP:dst_ip} on interface %{GREEDYDATA:interface}
# 106023: `Deny tcp src IFACE:IP/port dst IFACE:IP/port by access-group "NAME" [0x..., 0x...]`, with an optional ICMP type and code.
CISCOFW106023 %{CISCO_ACTION:action}(?: protocol)? %{WORD:protocol} src %{DATA:src_interface}:%{DATA:src_ip}(?:/%{INT:src_port})?(?:\(%{DATA:src_fwuser}\))? dst %{DATA:dst_interface}:%{DATA:dst_ip}(?:/%{INT:dst_port})?(?:\(%{DATA:dst_fwuser}\))?(?: \(type %{INT:icmp_type}, code %{INT:icmp_code}\))? by access-group "?%{DATA:policy_id}"? \[%{DATA:hashcode1}, %{DATA:hashcode2}\]
# 106100, 106102, 106103: `access-list NAME permitted tcp for user 'U' IFACE/IP(port) -> IFACE/IP(port) hit-cnt N first hit [0x..., 0x...]`.
CISCOFW106100_2_3 access-list %{NOTSPACE:policy_id} %{CISCO_ACTION:action} %{WORD:protocol} for user '%{DATA:src_fwuser}' %{DATA:src_interface}/%{IP:src_ip}\(%{INT:src_port}\) -> %{DATA:dst_interface}/%{IP:dst_ip}\(%{INT:dst_port}\) hit-cnt %{INT:hit_count} %{CISCO_INTERVAL:interval} \[%{DATA:hashcode1}, %{DATA:hashcode2}\]
# 106100: the same without the user, and with an optional (user) after each address.
CISCOFW106100 access-list %{NOTSPACE:policy_id} %{CISCO_ACTION:action} %{WORD:protocol} %{DATA:src_interface}/%{IP:src_ip}\(%{INT:src_port}\)(?:\(%{DATA:src_fwuser}\))? -> %{DATA:dst_interface}/%{IP:dst_ip}\(%{INT:dst_port}\)(?:\(%{DATA:dst_fwuser}\))? hit-cnt %{INT:hit_count} %{CISCO_INTERVAL:interval} \[%{DATA:hashcode1}, %{DATA:hashcode2}\]
# 304001: `IP Accessed URL IP:url`.
CISCOFW304001 %{IP:src_ip}(?:\(%{DATA:src_fwuser}\))? Accessed URL %{IP:dst_ip}:%{GREEDYDATA:dst_url}
# 110002: `Failed to locate egress interface for TCP from IFACE:IP/port to IP/port`.
CISCOFW110002 %{CISCO_REASON:reason} for %{WORD:protocol} from %{DATA:src_interface}:%{IP:src_ip}/%{INT:src_port} to %{IP:dst_ip}/%{INT:dst_port}
# 302010: `N in use, N most used`.
CISCOFW302010 %{INT:connection_count} in use, %{INT:connection_count_max} most used
# 302013-302016: `Built inbound TCP connection ID for IFACE:IP/port (IP/port) to IFACE:IP/port (IP/port)`, and the Teardown form adds `duration H:MM:SS bytes N REASON (user)`.
CISCOFW302013_302014_302015_302016 %{CISCO_ACTION:action}(?: %{CISCO_DIRECTION:direction})? %{WORD:protocol} connection %{INT:connection_id} for %{DATA:src_interface}:%{IP:src_ip}/%{INT:src_port}(?: \(%{IP:src_mapped_ip}/%{INT:src_mapped_port}\))?(?:\(%{DATA:src_fwuser}\))? to %{DATA:dst_interface}:%{IP:dst_ip}/%{INT:dst_port}(?: \(%{IP:dst_mapped_ip}/%{INT:dst_mapped_port}\))?(?:\(%{DATA:dst_fwuser}\))?(?: duration %{TIME:duration} bytes %{INT:bytes})?(?: %{CISCO_REASON:reason})?(?: \(%{DATA:user}\))?
# 302020, 302021: `Built inbound ICMP connection for faddr IP/seq gaddr IP/code laddr IP/code`.
CISCOFW302020_302021 %{CISCO_ACTION:action}(?: %{CISCO_DIRECTION:direction})? %{WORD:protocol} connection for faddr %{IP:dst_ip}/%{INT:icmp_seq_num}(?:\(%{DATA:fwuser}\))? gaddr %{IP:src_xlated_ip}/%{INT:icmp_code_xlated} laddr %{IP:src_ip}/%{INT:icmp_code}(?: \(%{DATA:user}\))?
# 305011: `Built dynamic TCP translation from IFACE:IP/port to IFACE:IP/port`.
CISCOFW305011 %{CISCO_ACTION:action} %{CISCO_XLATE_TYPE:xlate_type} %{WORD:protocol} translation from %{DATA:src_interface}:%{IP:src_ip}(?:/%{INT:src_port})?(?:\(%{DATA:src_fwuser}\))? to %{DATA:src_xlated_interface}:%{IP:src_xlated_ip}/%{DATA:src_xlated_port}
# 313001, 313004, 313008: `Denied ICMP type=N, code=N from IP on interface NAME`.
CISCOFW313001_313004_313008 %{CISCO_ACTION:action} %{WORD:protocol} type=%{INT:icmp_type}, code=%{INT:icmp_code} from %{IP:src_ip} on interface %{DATA:interface}(?: to %{IP:dst_ip})?
# 313005: `No matching connection for ICMP error message: icmp src IFACE:IP dst IFACE:IP (type N, code N) on IFACE interface. Original IP payload: tcp src IP/port dst IP/port`.
CISCOFW313005 %{CISCO_REASON:reason} for %{WORD:protocol} error message: %{WORD:err_protocol} src %{DATA:err_src_interface}:%{IP:err_src_ip}(?:\(%{DATA:err_src_fwuser}\))? dst %{DATA:err_dst_interface}:%{IP:err_dst_ip}(?:\(%{DATA:err_dst_fwuser}\))? \(type %{INT:err_icmp_type}, code %{INT:err_icmp_code}\) on %{DATA:interface} interface\. +Original IP payload: %{WORD:protocol} src %{IP:orig_src_ip}/%{INT:orig_src_port}(?:\(%{DATA:orig_src_fwuser}\))? dst %{IP:orig_dst_ip}/%{INT:orig_dst_port}(?:\(%{DATA:orig_dst_fwuser}\))?
# 321001: `Resource 'conns' limit of N reached for system`.
CISCOFW321001 Resource '%{WORD:resource_name}' limit of %{POSINT:resource_limit} reached for system
# 402117, 402119: IPsec packet errors.
CISCOFW402117 %{WORD:protocol}: Received a non-IPSec packet \(protocol= %{WORD:orig_protocol}\) from %{IP:src_ip} to %{IP:dst_ip}
CISCOFW402119 %{WORD:protocol}: Received an %{WORD:orig_protocol} packet \(SPI= %{DATA:spi}, sequence number= %{DATA:seq_num}\) from %{IP:src_ip} \(user= %{DATA:user}\) to %{IP:dst_ip} that failed anti-replay checking
# 419001, 419002: TCP normalisation drops.
CISCOFW419001 %{CISCO_ACTION:action} %{WORD:protocol} packet from %{DATA:src_interface}:%{IP:src_ip}/%{INT:src_port} to %{DATA:dst_interface}:%{IP:dst_ip}/%{INT:dst_port}, reason: %{GREEDYDATA:reason}
CISCOFW419002 %{CISCO_REASON:reason} from %{DATA:src_interface}:%{IP:src_ip}/%{INT:src_port} to %{DATA:dst_interface}:%{IP:dst_ip}/%{INT:dst_port} with different initial sequence number
# 500004: `Invalid transport field for protocol=TCP, from IP/port to IP/port`.
CISCOFW500004 %{CISCO_REASON:reason} for protocol=%{WORD:protocol}, from %{IP:src_ip}/%{INT:src_port} to %{IP:dst_ip}/%{INT:dst_port}
# 602303, 602304: `IPSEC: An outbound LAN-to-LAN SA (SPI= 0x...) between IP and IP (user= NAME) has been created`.
CISCOFW602303_602304 %{WORD:protocol}: An %{CISCO_DIRECTION:direction} %{GREEDYDATA:tunnel_type} SA \(SPI= %{DATA:spi}\) between %{IP:src_ip} and %{IP:dst_ip} \(user= %{DATA:user}\) has been %{CISCO_ACTION:action}
# 710001-710006: `TCP access requested from IP/port to IFACE:IP/port`.
CISCOFW710001_710002_710003_710005_710006 %{WORD:protocol} (?:request|access) %{CISCO_ACTION:action} from %{IP:src_ip}/%{INT:src_port} to %{DATA:dst_interface}:%{IP:dst_ip}/%{INT:dst_port}
# 713172: IKE NAT detection status, with variable padding between words.
CISCOFW713172 Group = %{GREEDYDATA:group}, IP = %{IP:src_ip}, Automatic NAT Detection Status:\s+Remote end\s*%{DATA:is_remote_natted}\s*behind a NAT device\s+This\s+end\s*%{DATA:is_local_natted}\s*behind a NAT device
# 733100: `[ SOURCE ] drop RATE exceeded. Current burst rate is N per second, max configured rate is N; Current average rate is N per second, max configured rate is N; Cumulative total count is N`.
CISCOFW733100 \[\s*%{DATA:drop_type}\s*\] drop %{DATA:drop_rate_id} exceeded\. Current burst rate is %{INT:drop_rate_current_burst} per second, max configured rate is %{INT:drop_rate_max_burst}; Current average rate is %{INT:drop_rate_current_avg} per second, max configured rate is %{INT:drop_rate_max_avg}; Cumulative total count is %{INT:drop_total_count}

# Netfilter LOG target output, with the chain and disposition in the Shorewall log prefix: `IN= OUT= MAC=dst:src:type SRC= DST= LEN= TOS= PREC= TTL= ID= [CE] [DF] [MF] [FRAG:n] PROTO= SPT= DPT=`.
SHOREWALL %{SYSLOGTIMESTAMP:timestamp} %{WORD:nf_host} .*Shorewall:(?:%{WORD:nf_action1})?:(?:%{WORD:nf_action2})?: ?IN=(?:%{USERNAME:nf_in_interface})? OUT=(?:%{USERNAME:nf_out_interface})?(?: MAC=(?:%{COMMONMAC:nf_dst_mac}:%{COMMONMAC:nf_src_mac}(?::[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2})?)?)? SRC=%{IPV4:nf_src_ip} DST=%{IPV4:nf_dst_ip} LEN=%{WORD:nf_len} TOS=%{WORD:nf_tos} PREC=%{WORD:nf_prec} TTL=%{INT:nf_ttl} ID=%{INT:nf_id}(?: CE)?(?: DF)?(?: MF)?(?: FRAG:[0-9]+)? PROTO=%{WORD:nf_protocol}(?: SPT=%{INT:nf_src_port} DPT=%{INT:nf_dst_port})?.*
# The same netfilter output from the SuSE firewall, whose prefix is `SFW2-INext-ACTION`.
SFW2 (?:%{SYSLOGTIMESTAMP:timestamp}|%{TIMESTAMP_ISO8601:timestamp}) +%{HOSTNAME} +kernel\S* +(?:%{NAGIOSTIME} *)?SFW2-INext-%{NOTSPACE:nf_action} +IN=%{USERNAME:nf_in_interface} OUT=(?: *%{USERNAME:nf_out_interface})? *MAC=(?:%{COMMONMAC:nf_dst_mac}:%{COMMONMAC:nf_src_mac}(?::[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2})?)? .*?SRC=%{IP:nf_src_ip} DST=%{IP:nf_dst_ip}.*PROTO=%{WORD:nf_protocol}(?:.*SPT=%{INT:nf_src_port}.*DPT=%{INT:nf_dst_port})?.*