Skip to content

Commit facc799

Browse files
committed
feat: add packet_analysis rules for ARP/ICMP/OSPF/BGP with tshark field extraction
1 parent 51ed78d commit facc799

4 files changed

Lines changed: 547 additions & 0 deletions

File tree

packet_analysis/arp.yaml

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# SPDX-License-Identifier: GPL-3.0-or-later
2+
#
3+
# GNS3-Skills - Packet analysis rules for ARP/NDP
4+
#
5+
# Copyright (C) 2025 Yue Guobin
6+
#
7+
8+
name: "ARP / NDP Packet Analysis"
9+
description: "ARP (Address Resolution Protocol) and IPv6 NDP (Neighbor Discovery Protocol) packet analysis rules"
10+
protocol: "arp or icmpv6.type == 135 or icmpv6.type == 136 or icmpv6.type == 133 or icmpv6.type == 134"
11+
display_filter: "arp or icmpv6.ns or icmpv6.na or icmpv6.rs or icmpv6.ra"
12+
13+
fields:
14+
- label: "Frame Number"
15+
field: "frame.number"
16+
description: "Packet sequence number in capture"
17+
18+
- label: "Source IP"
19+
field: "arp.src.proto_ipv4"
20+
description: "Sender protocol address (IPv4)"
21+
22+
- label: "Target IP"
23+
field: "arp.dst.proto_ipv4"
24+
description: "Target protocol address (IPv4)"
25+
26+
- label: "Source MAC"
27+
field: "arp.src.hw_mac"
28+
description: "Sender hardware address (MAC)"
29+
30+
- label: "Target MAC"
31+
field: "arp.dst.hw_mac"
32+
description: "Target hardware address (MAC, zero in requests)"
33+
34+
- label: "Opcode"
35+
field: "arp.opcode"
36+
description: "ARP operation code: 1=request, 2=reply, 3=reverse-request, 4=reverse-reply"
37+
38+
- label: "Duplicate Detected"
39+
field: "arp.duplicate-address-detected"
40+
description: "Duplicate IP address detection flag"
41+
42+
- label: "IPv6 Source"
43+
field: "ipv6.src"
44+
description: "IPv6 source address (for NDP)"
45+
46+
- label: "IPv6 Destination"
47+
field: "ipv6.dst"
48+
description: "IPv6 destination address (for NDP)"
49+
50+
- label: "ICMPv6 Type"
51+
field: "icmpv6.type"
52+
description: "ICMPv6 type: 133=RS, 134=RA, 135=NS, 136=NA, 137=Redirect"
53+
54+
- label: "ICMPv6 Target"
55+
field: "icmpv6.target_address"
56+
description: "NDP target address (NS/NA target)"
57+
58+
- label: "ICMPv6 Option Type"
59+
field: "icmpv6.option.type"
60+
description: "NDP option type: 1=Source Link-Layer, 2=Target Link-Layer, 3=Prefix Info, 5=MTU"
61+
62+
- label: "ICMPv6 Option MAC"
63+
field: "icmpv6.option.lladdr"
64+
description: "NDP link-layer address from option field"
65+
66+
checks:
67+
- name: "duplicate_ip"
68+
severity: critical
69+
message: "Duplicate IP detected: {arp.src.proto_ipv4} claimed by {arp.src.hw_mac} and existing entry"
70+
condition: "arp.duplicate-address-detected is set to 1"
71+
72+
- name: "arp_no_reply"
73+
severity: major
74+
message: "No ARP reply received from {arp.dst.proto_ipv4}: {arp.src.proto_ipv4} keeps re-sending requests"
75+
condition: "Same arp.dst.proto_ipv4 appears in more than 3 requests without a matching reply"
76+
77+
- name: "arp_flood"
78+
severity: major
79+
message: "Possible ARP scan or flooding from {arp.src.proto_ipv4}: {count} requests in short interval"
80+
condition: "More than 20 ARP requests from same source within 5 seconds"
81+
82+
- name: "gratuitous_arp"
83+
severity: minor
84+
message: "Gratuitous ARP from {arp.src.proto_ipv4} (MAC: {arp.src.hw_mac}) for IP {arp.src.proto_ipv4}/{arp.dst.proto_ipv4}"
85+
condition: "arp.opcode == 2 AND arp.src.proto_ipv4 == arp.dst.proto_ipv4"
86+
87+
- name: "ndp_no_neighbor_advertisement"
88+
severity: major
89+
message: "No NA reply for NS targeting {icmpv6.target_address} from {ipv6.src}"
90+
condition: "icmpv6.type == 135 and no matching icmpv6.type == 136 within expected window"
91+
92+
- name: "ndp_duplicate_address"
93+
severity: critical
94+
message: "DAD (Duplicate Address Detection) indicates {icmpv6.target_address} may be in use"
95+
condition: "icmpv6.type == 135 and icmpv6.target_address matches solicited-node multicast and NA received in response"

packet_analysis/bgp.yaml

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
# SPDX-License-Identifier: GPL-3.0-or-later
2+
#
3+
# GNS3-Skills - Packet analysis rules for BGP
4+
#
5+
# Copyright (C) 2025 Yue Guobin
6+
#
7+
8+
name: "BGP Packet Analysis"
9+
description: "BGP-4 packet analysis for session establishment, route exchange, and notification errors"
10+
protocol: "bgp"
11+
display_filter: "bgp"
12+
13+
fields:
14+
- label: "Frame Number"
15+
field: "frame.number"
16+
description: "Packet sequence number in capture"
17+
18+
- label: "Source IP"
19+
field: "ip.src"
20+
description: "BGP speaker source address (TCP 179 source or destination)"
21+
22+
- label: "Destination IP"
23+
field: "ip.dst"
24+
description: "BGP peer destination address"
25+
26+
- label: "BGP Message Type"
27+
field: "bgp.type"
28+
description: "BGP message type: 1=Open, 2=Update, 3=Notification, 4=Keepalive, 5=RouteRefresh"
29+
30+
- label: "BGP Message Length"
31+
field: "bgp.length"
32+
description: "Total BGP message length in bytes (header + data)"
33+
34+
- label: "BGP Marker"
35+
field: "bgp.marker"
36+
description: "BGP marker (all 0xFF for IPv4, used for synchronization)"
37+
38+
- label: "Open - BGP Identifier"
39+
field: "bgp.router_id"
40+
description: "BGP Router-ID (advertised in OPEN message)"
41+
42+
- label: "Open - AS Number"
43+
field: "bgp.as_path"
44+
description: "AS number from OPEN message (2-byte or 4-byte)"
45+
46+
- label: "Open - Hold Time"
47+
field: "bgp.hold_time"
48+
description: "Hold time advertised in OPEN (negotiated to lower of the two)"
49+
50+
- label: "Open - Optional Parameters"
51+
field: "bgp.optional_parameter.type"
52+
description: "Capabilities advertised: 2=4-byte AS, 64=Graceful Restart, 6=RouteRefresh, 1=Add-Path"
53+
54+
- label: "Update - Withdrawn Routes"
55+
field: "bgp.withdrawn_prefix"
56+
description: "Prefixes being withdrawn in UPDATE message"
57+
58+
- label: "Update - NLRI Prefixes"
59+
field: "bgp.nlri_prefix"
60+
description: "Prefixes being advertised in UPDATE message"
61+
62+
- label: "Update - Next Hop"
63+
field: "bgp.next_hop"
64+
description: "Next-hop IP address in UPDATE path attributes"
65+
66+
- label: "Update - AS Path"
67+
field: "bgp.as_path"
68+
description: "AS path attribute (AS sequence or AS set)"
69+
70+
- label: "Update - Origin"
71+
field: "bgp.origin"
72+
description: "Origin attribute: 0=IGP, 1=EGP, 2=Incomplete"
73+
74+
- label: "Update - Local Preference"
75+
field: "bgp.local_pref"
76+
description: "Local preference attribute (only within AS)"
77+
78+
- label: "Update - Multi-Exit Discriminator"
79+
field: "bgp.med"
80+
description: "MED attribute for inbound path selection"
81+
82+
- label: "Update - Communities"
83+
field: "bgp.community"
84+
description: "BGP community attribute"
85+
86+
- label: "Notification - Error Code"
87+
field: "bgp.notification.code"
88+
description: "Notification error code: 1=MsgHeader, 2=Open, 3=Update, 4=HoldTimer, 5=FSM, 6=Cease"
89+
90+
- label: "Notification - Error Subcode"
91+
field: "bgp.notification.subcode"
92+
description: "Notification error subcode (specific reason)"
93+
94+
- label: "Notification - Data"
95+
field: "bgp.notification.data"
96+
description: "Notification data (hex dump of offending data)"
97+
98+
- label: "Keepalive Interval"
99+
field: "bgp.keepalive"
100+
description: "Keepalive interval derived from negotiated hold time"
101+
102+
- label: "Route Refresh - AFI"
103+
field: "bgp.route_refresh.afi"
104+
description: "Address Family Identifier in Route Refresh"
105+
106+
- label: "Route Refresh - SAFI"
107+
field: "bgp.route_refresh.safi"
108+
description: "Subsequent AFI in Route Refresh"
109+
110+
checks:
111+
- name: "bgp_open_error"
112+
severity: critical
113+
message: "BGP OPEN error from {ip.src} to {ip.dst}: code {bgp.notification.code}, subcode {bgp.notification.subcode}"
114+
condition: "bgp.type == 1 and followed by bgp.type == 3 (Notification)"
115+
116+
- name: "bgp_hold_timer_expired"
117+
severity: critical
118+
message: "BGP hold timer expired for session {ip.src}<->{ip.dst}, session reset"
119+
condition: "bgp.notification.code == 4 (Hold Timer Expired)"
120+
121+
- name: "bgp_update_error"
122+
severity: critical
123+
message: "BGP UPDATE error from {ip.src}: code {bgp.notification.code}, subcode {bgp.notification.subcode}"
124+
condition: "bgp.type == 2 and followed by bgp.type == 3 with notification.code == 3"
125+
126+
- name: "bgp_as_path_loop"
127+
severity: critical
128+
message: "AS path loop detected: AS_PATH {bgp.as_path} from {ip.src}"
129+
condition: "bgp.type == 2 and AS path repeated across multiple UPDATEs (route withdrawn after previous advertisement)"
130+
131+
- name: "bgp_nexthop_unreachable"
132+
severity: major
133+
message: "BGP next-hop {bgp.next_hop} from {ip.src} may not be reachable via IGP"
134+
condition: "bgp.type == 2 and subsequent routing table state shows NHL not resolved in RIB"
135+
136+
- name: "bgp_route_flap"
137+
severity: minor
138+
message: "BGP route flapping: prefix {bgp.nlri_prefix} withdrawn and re-advertised repeatedly by {ip.src}"
139+
condition: "Same bgp.nlri_prefix appears in both withdrawn_prefix and nlri_prefix from same source in short interval"
140+
141+
- name: "bgp_notification_cease"
142+
severity: critical
143+
message: "BGP session terminated: Cease notification from {ip.src} (subcode {bgp.notification.subcode})"
144+
condition: "bgp.notification.code == 6"
145+
146+
- name: "bgp_admin_reset"
147+
severity: major
148+
message: "BGP session administratively reset from {ip.src} to {ip.dst} (Cease subcode 2)"
149+
condition: "bgp.notification.code == 6 and bgp.notification.subcode == 2"
150+
151+
- name: "bgp_max_prefix_exceeded"
152+
severity: major
153+
message: "BGP maximum prefix limit exceeded, session reset from {ip.src}"
154+
condition: "bgp.notification.code == 6 and bgp.notification.subcode == 3 (max prefix reached)"
155+
156+
- name: "bgp_capability_mismatch"
157+
severity: major
158+
message: "BGP capability mismatch between {ip.src} and {ip.dst}: MISSING capability {bgp.optional_parameter.type}"
159+
condition: "bgp.type == 1 and capabilities advertised differ between peers"

packet_analysis/icmp.yaml

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
# SPDX-License-Identifier: GPL-3.0-or-later
2+
#
3+
# GNS3-Skills - Packet analysis rules for ICMP/ICMPv6
4+
#
5+
# Copyright (C) 2025 Yue Guobin
6+
#
7+
8+
name: "ICMP / ICMPv6 Packet Analysis"
9+
description: "ICMP (Internet Control Message Protocol) v4 and v6 packet analysis for connectivity and PMTUD troubleshooting"
10+
protocol: "icmp or icmpv6"
11+
display_filter: "icmp or icmpv6"
12+
13+
fields:
14+
- label: "Frame Number"
15+
field: "frame.number"
16+
description: "Packet sequence number in capture"
17+
18+
- label: "Source IP"
19+
field: "ip.src"
20+
description: "IPv4 source address (present for IPv4 packets)"
21+
22+
- label: "Destination IP"
23+
field: "ip.dst"
24+
description: "IPv4 destination address"
25+
26+
- label: "IPv6 Source"
27+
field: "ipv6.src"
28+
description: "IPv6 source address (present for IPv6 packets)"
29+
30+
- label: "IPv6 Destination"
31+
field: "ipv6.dst"
32+
description: "IPv6 destination address"
33+
34+
- label: "ICMP Type (v4)"
35+
field: "icmp.type"
36+
description: "ICMPv4 type: 0=Echo Reply, 3=Dest Unreachable, 8=Echo, 11=TTL Exceeded, 5=Redirect"
37+
38+
- label: "ICMP Code (v4)"
39+
field: "icmp.code"
40+
description: "ICMPv4 code (sub-type for each type)"
41+
42+
- label: "ICMP Sequence (v4)"
43+
field: "icmp.seq"
44+
description: "ICMPv4 echo request/reply sequence number"
45+
46+
- label: "ICMPv6 Type"
47+
field: "icmpv6.type"
48+
description: "ICMPv6 type: 1=Unreach, 2=PacketTooBig, 3=TimeExceed, 128=EchoReq, 129=EchoRep"
49+
50+
- label: "ICMPv6 Code"
51+
field: "icmpv6.code"
52+
description: "ICMPv6 code (sub-type for each type)"
53+
54+
- label: "ICMPv6 Sequence"
55+
field: "icmpv6.seq"
56+
description: "ICMPv6 echo request/reply sequence number"
57+
58+
- label: "Unreachable Port (v4)"
59+
field: "icmp.dstport.unreachable"
60+
description: "Destination port in ICMPv4 unreachable message"
61+
62+
- label: "PMTU Value (v6)"
63+
field: "icmpv6.mtu"
64+
description: "Path MTU value in ICMPv6 Packet Too Big message"
65+
66+
- label: "Redirect Gateway"
67+
field: "icmp.redirect.gateway"
68+
description: "ICMP redirect: suggested alternative gateway address"
69+
70+
checks:
71+
- name: "ping_timeout"
72+
severity: minor
73+
message: "Ping timeout: no echo reply for seq {icmp.seq} from {ip.dst}"
74+
condition: "icmp.type == 8 and no matching icmp.type == 0 within expected window"
75+
76+
- name: "icmp_unreachable_network"
77+
severity: major
78+
message: "Network unreachable: {ip.src} cannot reach {ip.dst} (ICMP type 3 code 0)"
79+
condition: "icmp.type == 3 and icmp.code == 0"
80+
81+
- name: "icmp_unreachable_host"
82+
severity: major
83+
message: "Host unreachable: {ip.src} cannot reach {ip.dst} (ICMP type 3 code 1)"
84+
condition: "icmp.type == 3 and icmp.code == 1"
85+
86+
- name: "icmp_unreachable_protocol"
87+
severity: major
88+
message: "Protocol unreachable: {ip.dst} does not support protocol requested by {ip.src} (ICMP type 3 code 2)"
89+
condition: "icmp.type == 3 and icmp.code == 2"
90+
91+
- name: "icmp_unreachable_port"
92+
severity: major
93+
message: "Port unreachable: port {icmp.dstport.unreachable} on {ip.dst} not reachable from {ip.src}"
94+
condition: "icmp.type == 3 and icmp.code == 3"
95+
96+
- name: "icmp_frag_needed"
97+
severity: major
98+
message: "Fragmentation needed but DF set: {ip.src} to {ip.dst} — PMTUD issue"
99+
condition: "icmp.type == 3 and icmp.code == 4"
100+
101+
- name: "icmp_redirect"
102+
severity: minor
103+
message: "ICMP redirect from {ip.src}: use {icmp.redirect.gateway} instead of current gateway"
104+
condition: "icmp.type == 5"
105+
106+
- name: "icmp_ttl_exceeded"
107+
severity: minor
108+
message: "TTL exceeded in transit: packet from {ip.src} to {ip.dst} expired at intermediate router"
109+
condition: "icmp.type == 11 and icmp.code == 0"
110+
111+
- name: "icmpv6_unreachable_network"
112+
severity: major
113+
message: "IPv6 network unreachable: {ipv6.src} to {ipv6.dst} (ICMPv6 type 1 code 0)"
114+
condition: "icmpv6.type == 1 and icmpv6.code == 0"
115+
116+
- name: "icmpv6_unreachable_port"
117+
severity: major
118+
message: "IPv6 port unreachable: {ipv6.dst} port not reachable from {ipv6.src}"
119+
condition: "icmpv6.type == 1 and icmpv6.code == 4"
120+
121+
- name: "icmpv6_packet_too_big"
122+
severity: major
123+
message: "IPv6 Path MTU issue: {ipv6.src} to {ipv6.dst}, suggested MTU {icmpv6.mtu}"
124+
condition: "icmpv6.type == 2"
125+
126+
- name: "icmpv6_ttl_exceeded"
127+
severity: minor
128+
message: "IPv6 Hop Limit exceeded: packet from {ipv6.src} to {ipv6.dst} expired in transit"
129+
condition: "icmpv6.type == 3"
130+
131+
- name: "consecutive_ping_loss"
132+
severity: minor
133+
message: "Consecutive ping loss detected: {count} echo requests with no reply from {ip.dst}"
134+
condition: "icmp.type == 8 and more than 3 consecutive seq numbers without matching icmp.type == 0"

0 commit comments

Comments
 (0)