RegEx with Splunk for OSSEC
Thanks to Michael Wilde for the information on RegEx in Splunk. For those like me who aren't the best at RegEx, I will show some of the regular expressions I am using for OSSEC.
Server Name
(?i) Location:\s\((?P<FIELDNAME>.*?)\)\s
Windows Event User
(?i) USER: (?P<FIELDNAME>[^:]*);
Server IP
(?i)^[^\)]*\)\s+(?P<FIELDNAME>[^\-]*)\-
Windows Events
(?i)^[^\-]*\-\s+(?P<FIELDNAME>[^\.]*)\.
LogInUser
(?i) Name: (?P<FIELDNAME>\w+)
LogInDomain
(?i) Domain: (?P<FIELDNAME>[^ ]*)[ ]
******************************************************
Now, to add them...
Open your browser and login in to your Splunk server. In the Search application, type sourcetype="ossec"
or click on "ossec" in the Sourcetypes
You should see a bunch of data from the OSSEC server. On the left of the main frame of the webpage, there should be a grey down arrow. Clicking on this I get two options. You want to select Extract Fields.
Here is where it gets fun. Splunk included a graphical RegEx builder based on examples. I ended up playing with this for a while. Once you have found the expression you like, click on the Save button.
Name your RegEx and click Save.
Restart your Splunk server.
Once restarted, on the main search page, on the left sidebar click on Pick fields.
Here you can select the fields that will be displayed on the search page.
When you get back to the search page, you will notice the new fields.
OSSEC and Splunk
I have been playing with OSSEC and Splunk. OSSEC is a Host based Intrusion Detection System (HIDS). Splunk is a log archiving and searching system. OSSEC is open source and is multiple platform. You can run it on Linux/Unix and Windows. I am using OSSEC to forward Windows Event Logs to Splunk. Splunk makes the searching and correlation. Splunk can do WMI. This would be great since no agent would need to be installed. The problems is that if you have more than 30-50 systems, the amount time and traffic would cause issues. Using the OSSEC agent, I am able to push the event logs to the OSSEC server. From there the OSSEC server will upload to the Splunk server via Syslog.
Right now I have the servers all talking but I do need to adjust a few things. Right now Splunk sees all the hosts as the OSSEC server. I believe I just need to tweak the fields. The question is how.
Splunk
http://www.splunk.com
OSSEC
http://www.ossec.net
On-Call
It is that time again for me. On-call at where I work means little sleep and a lot of work. The first wasn't too bad. I stayed busy during the day. I left for home (around an hour drive) and didn't even make it out of town and had to turn around. Worked till 7:30pm and then headed home. Got paged when I was about 15 minutes from my house. Got home and fired up the laptop. I was on that call until 2am. Went to bed and woke up at 5:45am like I normally do. Off to work at 6:50am. Work today has been constant. The bad part is that this is a holiday weekend so there will be no level 1 support fielding the easy calls. This also means that I will get every page this weekend. Could be worse, could be a lot worse.
There is something about on call that is fun. All day long you have that level of anticipation of when the next page is coming. Then when you get the page what is the issue. You got pressure to get it fixed fast as the company could be loosing money by the minute. That rush can be awesome. The lack of family time and sleep is not any fun, but that is the price of the job.
