Project

General

Profile

Actions

Feature #8133

open
AI CT

Relative pcre with negative distance to previous content match

Feature #8133: Relative pcre with negative distance to previous content match

Added by Ambre Iooss 10 months ago. Updated 12 days ago.

Status:
Triaged
Priority:
Normal
Target version:
Effort:
Difficulty:
Label:

Description

Currently Suricata implements the R PCRE modifier to allow the equivalent of distance:0. This is enough in most use case, except when using PCRE extraction.

See for example this rule:
alert ip any any -> any any (flow:to_server; content: "ECSC_"; pcre: "/(ECSC_[A-Za-z0-9\/+]{32})/, flow:match"; sid: 1;)
Because the extraction needs to contain the ECSC_ prefix, the R modifier cannot be used.

This is problematic when trying to extract multiple values, as PCRE will return the first found match.

PA Updated by Philippe Antoine about 1 month ago Actions #1

  • Status changed from New to Triaged
  • Assignee set to Community Ticket

OM Updated by Omar Merroun 12 days ago Actions #2

I see the need for this feature (native extract of multiple structured values from a single packet).
You could ofc write a lua script that could do the trick.
But I would suggest adding a new modifier to pcre, let's call it G, that iterates the following pcre extraction across every MPM hit of the anchoring content. Then captured values are collected in an ordered list (with a configurable cap) in the alert output.

Actions

Also available in: PDF Atom