Documente Academic
Documente Profesional
Documente Cultură
Guide
April 26, 2017 — Revision A
LogRhythm-MPE-RuleBuilderGuide-revA
LogRhythm Inc.
4780 Pearl East Circle
Boulder, CO 80301
(303) 413-8745
www.logrhythm.com
LogRhythm Customer Support
support@logrhythm.com
Fields denoted with † are available for parsing and investigations, and they are viewable in the Web
Console. These fields will be available in all product features in the LogRhythm 7.3 release.
Object Type † A category type for the object (e.g., <objecttype> \w+
file, image, pdf, etc.).
User Agent † The User Agent string from web <useragent> \w+
server logs.
Threat Name † The name of a threat described in the log message <threatname> \w+
(e.g., malware, exploit name, signature name). Do
not overload with Policy.
MAC Address The MAC address from which activity <smac> (\w{2}(:|-)?){6}
(Origin) originated (i.e., attacker, client).
MAC Address The MAC address that was affected <dmac> (\w{2}(:|-)?){6}
(Impacted) by the activity (i.e., target, server).
Location Tab
Display Field Description Tag(s) Default Regex
Entity (Origin) A value determined based on the origin host’s assigned N/A N/A
entity.
Entity (Impacted) A value determined based on the impacted host’s N/A N/A
assigned entity.
Zone (Origin) A value determined based on the zone of the origin host N/A N/A
— Internal, External, DMZ, or Unknown.
Zone (Impacted) A value determined based on the zone of the impacted N/A N/A
host — Internal, External, DMZ, or Unknown.
Location (Origin) A value determined by resolving the parsed origin IP N/A N/A
address against a Geo-IP database.
Location (Impacted) A value determined by resolving the parsed impacted IP N/A N/A
address against a Geo-IP database.
Country (Origin) The country in which the determined origin location exists. N/A N/A
Country (Impacted) The country in which the determined impacted location N/A N/A
exists.
\w+
TCP/UDP Port (Origin) The port from which activity <sport> \d+
originated (i.e., client, attacker port).
TCP/UDP Port The port to which activity was <dport> \d+
(Impacted) targeted (i.e., server, target port).
NAT TCP/UDP Port The Network Address Translated <snatport> \d+
(Origin) (NAT) port from which activity
originated (i.e., client, attacker port).
NAT TCP/UDP Port The Network Address Translated <dnatport> \d+
(Impacted) (NAT) port to which activity was
targeted (i.e., server, target port).
Rule Names
When naming a rule, follow these accepted best practices:
• When the matching log message contains a vendor message ID such as an event ID in Windows Event
Logs, it is good to include the ID in the name of the rule. This makes searching for the rule easier and also
makes the rule more descriptive of the log that it matches.
• If the rule matches a log from a logging system that generates logs for a wide variety of services, such as
the Windows Application Event Log, the service that generated the log message should be included in the
rule name.
• All rule names should contain a brief description of the action described by the log.
For example: EVID 528 : Failed Authentication : Bad Username or Password
Match Characters
Notation Characters Matched Example
\d Any digit from 0 to 9 \d\d\d matches 101 but not 10a
\D Any character that is not a numeric digit (0 to 9) \D\D\D matches abc but not 101
\w Any word character, for example, a-z, A-Z, 0-9, \w\w\w matches abc but not &@#
and the underscore character _ (will also match
Unicode based word characters from non-Latin
alphabets and scripts)
\W Any non-word character \W\W\W matches $#! but not abc
\s Matches any whitespace character \s\s\s matches (three spaces) but not abc
\S Matches any non-whitespace character \S\S\S matches a1_ but not (three spaces)
. Matches any character . matches any character except line breaks
[] Any character between the square brackets [abc] matches a or b or c but no other character
[^ ] Matches any character except the characters [^abc] matches def but not abc
appearing after the ^ and before the ]
Positional Characters
Notation Description
^ The following pattern must be at the start of the string, or for a multi-line string, at the beginning
of a line. For multi-line text (string containing a carriage return), the multi-line flag option needs to
be set.
$ The preceding pattern must be at the end of the string, or for a multi-line string, at the end of a
line.
\A The preceding pattern must be at the start of the string; the multi-line flag is ignored.
\Z The preceding pattern must be at the end of the string; the multi-line pattern is ignored.
\b Matches a word boundary, essentially the point between a word character (a-z, A-Z, 0-9, _) and a
non-word character (the start of a word).
\B Matches a position that is not a word boundary (not the start of a word).
Grouping
Notation Characters Matched Example
()? Matches the pattern inside the brackets 0 or 1 times. (Error)? Matches Error or nothing
()+ Matches the pattern inside the brackets 1 or more times. (\w+\s)+ Matches AA AA
()* Matches the pattern inside the brackets 0 or more times. (\w+\s)* Matches nothing or AA AA
Reserved Characters
The regex engine used by LogRhythm has 12 reserved characters that have special meaning. If any of these
characters need to be used as a literal character they will need to be escaped using the backslash (\) character,
otherwise known as the escape character. The reserved characters are:
• The opening square bracket [
• The opening round bracket (
• The closing round bracket )
• The backslash \
• The caret ^
• The dollar sign $
• The period .
• The vertical bar or pipe symbol |
• The question mark ?
• The asterisk or Kleene star *
• The plus sign +
• The opening curly bracket {
• The closing curly bracket }
The following regex, which is meant to match any IPv4 address (a.b.c.d), is a simple example of how to escape
reserved characters:
\d+\.\d+\.\d+\.\d+
As you can see each of the periods of the IP address are escaped meaning the regex engine will look for the actual
period (.) character in the string instead of looking for any character. Without the escape slash, the period refers to
any character, which would radically change the meaning of the expression.