{"id":75,"date":"2009-07-30T22:12:46","date_gmt":"2009-07-31T04:12:46","guid":{"rendered":"http:\/\/www.anthonyreinke.com\/?p=75"},"modified":"2009-07-30T22:12:46","modified_gmt":"2009-07-31T04:12:46","slug":"regex-with-splunk-for-ossec","status":"publish","type":"post","link":"https:\/\/anthonyreinke.com\/index.php\/2009\/07\/30\/regex-with-splunk-for-ossec\/","title":{"rendered":"RegEx with Splunk for OSSEC"},"content":{"rendered":"<p>Thanks to <strong><a rel=\"external nofollow\" href=\"http:\/\/splunkninja.com\/\">Michael Wilde<\/a><\/strong> for the information on RegEx in Splunk.\u00a0 For those like me who aren&#8217;t the best at RegEx, I will show some of the regular expressions I am using for OSSEC.<\/p>\n<p>Server Name<br \/>\n(?i) Location:s((?P&lt;FIELDNAME&gt;.*?))s<\/p>\n<p>Windows Event User<br \/>\n(?i) USER: (?P&lt;FIELDNAME&gt;[^:]*);<\/p>\n<p>Server IP<br \/>\n(?i)^[^)]*)s+(?P&lt;FIELDNAME&gt;[^-]*)-<\/p>\n<p>Windows Events<br \/>\n(?i)^[^-]*-s+(?P&lt;FIELDNAME&gt;[^.]*).<\/p>\n<p>LogInUser<br \/>\n(?i) Name: (?P&lt;FIELDNAME&gt;w+)<\/p>\n<p>LogInDomain<br \/>\n(?i) Domain: (?P&lt;FIELDNAME&gt;[^ ]*)[ ]<\/p>\n<p>******************************************************<\/p>\n<p>Now, to add them&#8230;<\/p>\n<p>Open your browser and login in to your Splunk server.\u00a0 In the Search application, type sourcetype=&#8221;ossec&#8221;<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-76\" title=\"Type Search ossec\" src=\"http:\/\/www.anthonyreinke.com\/wp-content\/uploads\/2009\/07\/Type-Search-ossec.JPG\" alt=\"Type Search ossec\" width=\"166\" height=\"45\" \/><\/p>\n<p>or click on &#8220;ossec&#8221; in the Sourcetypes<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-77\" title=\"Click Search ossec\" src=\"http:\/\/www.anthonyreinke.com\/wp-content\/uploads\/2009\/07\/Click-Search-ossec.JPG\" alt=\"Click Search ossec\" width=\"215\" height=\"260\" \/><\/p>\n<p>You should see a bunch of data from the OSSEC server.\u00a0 On the left of the main frame of the webpage, there should be a grey down arrow.\u00a0 Clicking on this I get two options.\u00a0 You want to select\u00a0 Extract Fields.<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-78\" title=\"Click Extract Fields\" src=\"http:\/\/www.anthonyreinke.com\/wp-content\/uploads\/2009\/07\/Click-Extract-Fields.JPG\" alt=\"Click Extract Fields\" width=\"125\" height=\"189\" \/><\/p>\n<p>Here is where it gets fun.\u00a0 Splunk included a graphical RegEx builder based on examples.\u00a0 I ended up playing with this for a while.\u00a0 Once you have found the expression you like, click on the Save button.<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-79\" title=\"Click Save RegEx\" src=\"http:\/\/www.anthonyreinke.com\/wp-content\/uploads\/2009\/07\/Click-Save-RegEx.JPG\" alt=\"Click Save RegEx\" width=\"300\" height=\"103\" \/><\/p>\n<p>Name your RegEx and click Save.<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-80\" title=\"Save Field\" src=\"http:\/\/www.anthonyreinke.com\/wp-content\/uploads\/2009\/07\/Save-Field.JPG\" alt=\"Save Field\" width=\"409\" height=\"186\" \/><\/p>\n<p>Restart your Splunk server.<br \/>\nOnce restarted, on the main search page, on the left sidebar click on Pick fields.<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-81\" title=\"AddField\" src=\"http:\/\/www.anthonyreinke.com\/wp-content\/uploads\/2009\/07\/AddField.JPG\" alt=\"AddField\" width=\"200\" height=\"155\" \/><\/p>\n<p>Here you can select the fields that will be displayed on the search page.<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-82\" title=\"SelectFields\" src=\"http:\/\/www.anthonyreinke.com\/wp-content\/uploads\/2009\/07\/SelectFields.JPG\" alt=\"SelectFields\" width=\"645\" height=\"530\" \/><\/p>\n<p>When you get back to the search page, you will notice the new fields.<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-83\" title=\"Showing\" src=\"http:\/\/www.anthonyreinke.com\/wp-content\/uploads\/2009\/07\/Showing.JPG\" alt=\"Showing\" width=\"326\" height=\"53\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Thanks to Michael Wilde for the information on RegEx in Splunk.\u00a0 For those like me who aren&#8217;t the best at RegEx, I will show some of the regular expressions I am using for OSSEC. Server Name (?i) Location:s((?P&lt;FIELDNAME&gt;.*?))s Windows Event User (?i) USER: (?P&lt;FIELDNAME&gt;[^:]*); Server IP (?i)^[^)]*)s+(?P&lt;FIELDNAME&gt;[^-]*)- Windows Events (?i)^[^-]*-s+(?P&lt;FIELDNAME&gt;[^.]*). LogInUser (?i) Name: (?P&lt;FIELDNAME&gt;w+) LogInDomain [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-75","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/anthonyreinke.com\/index.php\/wp-json\/wp\/v2\/posts\/75","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/anthonyreinke.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/anthonyreinke.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/anthonyreinke.com\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/anthonyreinke.com\/index.php\/wp-json\/wp\/v2\/comments?post=75"}],"version-history":[{"count":0,"href":"https:\/\/anthonyreinke.com\/index.php\/wp-json\/wp\/v2\/posts\/75\/revisions"}],"wp:attachment":[{"href":"https:\/\/anthonyreinke.com\/index.php\/wp-json\/wp\/v2\/media?parent=75"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/anthonyreinke.com\/index.php\/wp-json\/wp\/v2\/categories?post=75"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/anthonyreinke.com\/index.php\/wp-json\/wp\/v2\/tags?post=75"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}