Skip to content

Commit 295b1fe

Browse files
committed
tests: add firewall icmp with icode keyword test
1 parent dbe4605 commit 295b1fe

File tree

5 files changed

+113
-0
lines changed

5 files changed

+113
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
drop:packet icmp:pre_flow any any -> any any (itype:8; icode:1; sid:100; noalert;)
2+
accept:packet icmp:all any any -> any any (itype:8; icode:0; msg:"Ping!"; flow:to_server; alert; sid:101;)
3+
accept:packet icmp:all any any -> any any (itype:0; icode:0; msg:"Pong!"; flow:to_client,established; alert; sid:102;)
4+
5+
# Implicit drop all else
Binary file not shown.
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
%YAML 1.1
2+
---
3+
4+
vars:
5+
# more specific is better for alert accuracy and performance
6+
address-groups:
7+
HOME_NET: "[192.168.0.0/16,10.0.0.0/8,172.16.0.0/12]"
8+
#HOME_NET: "[192.168.0.0/16]"
9+
#HOME_NET: "[10.0.0.0/8]"
10+
#HOME_NET: "[172.16.0.0/12]"
11+
#HOME_NET: "any"
12+
13+
EXTERNAL_NET: "!$HOME_NET"
14+
#EXTERNAL_NET: "any"
15+
16+
HTTP_SERVERS: "$HOME_NET"
17+
SMTP_SERVERS: "$HOME_NET"
18+
SQL_SERVERS: "$HOME_NET"
19+
DNS_SERVERS: "$HOME_NET"
20+
TELNET_SERVERS: "$HOME_NET"
21+
AIM_SERVERS: "$EXTERNAL_NET"
22+
DC_SERVERS: "$HOME_NET"
23+
DNP3_SERVER: "$HOME_NET"
24+
DNP3_CLIENT: "$HOME_NET"
25+
MODBUS_CLIENT: "$HOME_NET"
26+
MODBUS_SERVER: "$HOME_NET"
27+
ENIP_CLIENT: "$HOME_NET"
28+
ENIP_SERVER: "$HOME_NET"
29+
30+
port-groups:
31+
HTTP_PORTS: "80"
32+
SHELLCODE_PORTS: "!80"
33+
ORACLE_PORTS: 1521
34+
SSH_PORTS: 22
35+
DNP3_PORTS: 20000
36+
MODBUS_PORTS: 502
37+
FILE_DATA_PORTS: "[$HTTP_PORTS,110,143]"
38+
FTP_PORTS: 21
39+
GENEVE_PORTS: 6081
40+
VXLAN_PORTS: 4789
41+
TEREDO_PORTS: 3544
42+
SIP_PORTS: "[5060, 5061]"
43+
44+
# Global stats configuration
45+
stats:
46+
enabled: yes
47+
interval: 8
48+
49+
# Configure the type of alert (and other) logging you would like.
50+
outputs:
51+
- eve-log:
52+
enabled: yes
53+
filetype: regular #regular|syslog|unix_dgram|unix_stream|redis
54+
filename: eve.json
55+
types:
56+
- stats
57+
- flow
58+
- alert
59+
- tls:
60+
extended: yes # enable this for extended logging information
61+
- drop:
62+
alerts: yes # log alerts that caused drops
63+
flows: all # start or all: 'start' logs only a single drop
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
requires:
2+
min-version: 8
3+
4+
args:
5+
- --simulate-ips
6+
7+
checks:
8+
- filter:
9+
count: 1
10+
match:
11+
pcap_cnt: 1
12+
event_type: alert
13+
alert.signature_id: 101
14+
icmp_type: 8
15+
icmp_code: 0
16+
- filter:
17+
count: 1
18+
match:
19+
pcap_cnt: 3
20+
event_type: alert
21+
alert.signature_id: 102
22+
icmp_type: 0
23+
icmp_code: 0
24+
- filter:
25+
count: 1
26+
match:
27+
pcap_cnt: 2
28+
event_type: drop
29+
icmp_type: 8
30+
icmp_code: 1
31+
- filter:
32+
count: 1
33+
match:
34+
event_type: flow
35+
flow.pkts_toserver: 1
36+
flow.pkts_toclient: 1
37+
flow.state: "established"
38+
flow.alerted: true
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env python
2+
from scapy.all import *
3+
pkts = []
4+
pkts += Ether(dst='05:04:03:02:01:00', src='00:01:02:03:04:05')/IP(src="10.0.0.1", dst="1.2.3.4")/ICMP(type=8, code=0, seq=123)
5+
pkts += Ether(dst='05:04:03:02:01:00', src='00:01:02:03:04:05')/IP(src="10.0.0.1", dst="1.2.3.4")/ICMP(type=8, code=1, seq=321)
6+
pkts += Ether(src='05:04:03:02:01:00', dst='00:01:02:03:04:05')/IP(dst="10.0.0.1", src="1.2.3.4")/ICMP(type=0, code=0, seq=123)
7+
wrpcap('icmp-ping-plus-weird-code.pcap', pkts, snaplen=262144)

0 commit comments

Comments
 (0)