I remember that a signature that was matched once in HTTP-Buffer was not alerted again.However, “RULE B” did not match (due to flowbits), so it is questionable that there is no log.
I tested it with the attached signature. The difference is that I removed the flowbits. The transaction identified in the attached pcap consists of two packets. Since there are no flowbits, “RULE B” is alerted first, followed by “RULE A”.
alert http any any -> any any ( msg:"RULE A"; flow: established,to_server; http.method; content:"POST"; http.content_type; content:"x-www-form-urlencoded"; http.request_body; pcre:"/=/"; sid:5;)
alert http any any -> any any ( msg:"RULE B"; flow: established,to_server; http.method; content:"POST"; sid:6; )
[root@idps-pcap ~]# suricata -c /etc/suricata/suricata.yaml --simulate-ips -k none -r /root/pcap/apache_struts_CVE-2017-9791_exploit_runtime.pcapng
Signature without flowbits
[root@idps-pcap ~]# cat fast.log
10/27/2020-20:15:54.455637 [**] [1:6:0] RULE B [**] [Classification: (null)] [Priority: 3] {TCP} 18.255.255.16:46316 → 172.19.1.4:8080
10/27/2020-20:15:54.458066 [**] [1:5:0] RULE A [**] [Classification: (null)] [Priority: 3] {TCP} 18.255.255.16:46316 → 172.19.1.4:8080
Signature without flowbits
[root@idps-pcap ~]# cat rule_perf.log
…
{
“timestamp”: “2020-11-02T22:03:09.297646+0900”,
“sort”: “number of matches”,
“rules”: [{
“signature_id”: 5,
“gid”: 1,
“rev”: 0,
“checks”: 2,
“matches”: 1,
“ticks_total”: 232396,
“ticks_max”: 157732,
“ticks_avg”: 116198,
“ticks_avg_match”: 157732,
“ticks_avg_nomatch”: 74664,
“percent”: 85
}, {
“signature_id”: 6,
“gid”: 1,
“rev”: 0,
“checks”: 1,
“matches”: 1,
“ticks_total”: 37948,
“ticks_max”: 37948,
“ticks_avg”: 37948,
“ticks_avg_match”: 37948,
“ticks_avg_nomatch”: 0,
“percent”: 14
}
…
Signature with flowbits
[root@idps-pcap ~]# cat fast.log
10/27/2020-20:15:54.458066 [**] [1:5:0] RULE A [**] [Classification: (null)] [Priority: 3] {TCP} 18.255.255.16:46316 → 172.19.1.4:8080
Signature with flowbits
{
“timestamp”: “2020-11-02T22:24:02.665481+0900”,
“sort”: “number of matches”,
“rules”: [{
“signature_id”: 5,
“gid”: 1,
“rev”: 0,
“checks”: 2,
“matches”: 1,
“ticks_total”: 110382,
“ticks_max”: 63468,
“ticks_avg”: 55191,
“ticks_avg_match”: 46914,
“ticks_avg_nomatch”: 63468,
“percent”: 95
}, {
“signature_id”: 6,
“gid”: 1,
“rev”: 0,
“checks”: 1,
“matches”: 0,
“ticks_total”: 5420,
“ticks_max”: 5420,
“ticks_avg”: 5420,
“ticks_avg_match”: 0,
“ticks_avg_nomatch”: 5420,
“percent”: 4
}
And I tested raw. TCP raw streams are simply detected as they are identified. When tcp-stream signature is tested against the raw stream, it is alerted twice each according to the set chunk-size (2560, randomize-chunk=no).
alert tcp-stream any any -> any any ( msg:"RULE A"; flow: established,to_server; content:"POST"; content:"x-www-form-urlencoded"; pcre:"/=/"; flowbits: set, test; sid:5;)
alert tcp-stream any any -> any any ( msg:"RULE B"; flowbits: isset, test; flow: established,to_server; content:"POST"; sid:6; )
[root@idps-pcap ~]# cat fast.log
10/27/2020-20:15:54.455637 [**] [1:5:0] RULE A [**] [Classification: (null)] [Priority: 3] {TCP} 18.255.255.16:46316 → 172.19.1.4:8080
10/27/2020-20:15:54.455637 [**] [1:6:0] RULE B [**] [Classification: (null)] [Priority: 3] {TCP} 18.255.255.16:46316 → 172.19.1.4:8080
10/27/2020-20:15:54.458066 [**] [1:5:0] RULE A [**] [Classification: (null)] [Priority: 3] {TCP} 18.255.255.16:46316 → 172.19.1.4:8080
10/27/2020-20:15:54.458066 [**] [1:6:0] RULE B [**] [Classification: (null)] [Priority: 3] {TCP} 18.255.255.16:46316 → 172.19.1.4:8080
[root@idps-pcap ~]# cat rule_perf.log
…
{
“timestamp”: “2020-11-02T22:17:10.948494+0900”,
“sort”: “number of matches”,
“rules”: [{
“signature_id”: 5,
“gid”: 1,
“rev”: 0,
“checks”: 2,
“matches”: 2,
“ticks_total”: 150100,
“ticks_max”: 87294,
“ticks_avg”: 75050,
“ticks_avg_match”: 75050,
“ticks_avg_nomatch”: 0,
“percent”: 70
}, {
“signature_id”: 6,
“gid”: 1,
“rev”: 0,
“checks”: 2,
“matches”: 2,
“ticks_total”: 62208,
“ticks_max”: 31778,
“ticks_avg”: 31104,
“ticks_avg_match”: 31104,
“ticks_avg_nomatch”: 0,
“percent”: 29
}]
}
…