Hi,
I'm trying to identify failed logins to our Linux servers and created a detection rule for that. Different servers yield slightly different messages that are stored in `metadata.description`. For example, one server would yield the following value:
metadata.description = "Failed none for jlxx from 10.0.0.142 port 57835 ssh2"
While another server would yield this value:
metadata.description = "pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=10.0.0.142 user=jlxx"
That's what I put in the `events` section of the rule, to capture both options:
events:
$e.metadata.event_type = "STATUS_UPDATE"
$e.metadata.product_event_type = "sshd"
$e.metadata.product_name = "AuditD"
$e.principal.namespace = "LAN"
re.regex($e.metadata.description, `^Failed none for |^pam_unix(sshd:auth): authentication failure;`)
But I'm struggling with creating the extraction of the relevant info (user & IP) in the `outcome` section. These lines aren't accepted by the rule editor:
$event_source_ip = if(re.regex($e.metadata.description, `^Failed none for`), re.capture($e.metadata.description, `from\\s+([\\d.]+)\\s+port`), re.capture($e.metadata.description, `/rhost=([\\d.]+)\\s{2}user=/gm`))
$event_user = if(re.regex($e.metadata.description, `^Failed none for`), re.capture($e.metadata.description, `for\\s+(\\S+)\\s+from`), re.capture($e.metadata.description, `user=(.*)`))
Can anyone help me fix the rule to be able to extract the desire content and assign it to variables that I'd be able to use in the SOAR?
Thank you in advance for your guidance and support