-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Windows event 5140 missing field in output #204
Comments
@gaelmuller or @mstarks01 have you guys run into this? I don't know the Windows events very well and figure I would ping you and cheat before starting down this rabbit hole. @denied39 I see what you are saying looks like decoders might need to be updated. |
I haven't noticed this. This is a good catch! I have wondered what the need for vista_sec.csv is though. It strikes me as unnecessary and error-prone to refer to an external file in order to parse Windows events if that's what it is for. I don't know if it's related. I know I have tried to delete it and ossec fails to start, so it is needed in some way. I have written an enhanced Windows decoder but not published it because of inconsistencies like this that I run across. It seems to me that, at least on Vista+ systems, the proper way to read Windows events would be to refer to their XML representations. Then there would be no ambiguity involved. |
If I change the vista_sec.csv file line for event 5140 to the following: it formats correctly for Windows 7:
I'm not sure what that might do for any older OS versions, but it'll work for now. |
I just did a little research on the event id 5140 and it turns out that there is a possible inconsistency between vista, 2008 and 2008 R2 with respect to the content of the id. It's also hard to find log samples. This is the log sample that fits the current id in vista_sec.txt and says it is valid for vista and 2008: http://eventopedia.cloudapp.net/EventDetails.aspx?id=7ed0559e-e64d-4d93-8c5f-bd9682c19fd7 Since we know that 2008 and 2008 R2 are different operating systems as far as Microsoft is concerned, they may have slipped in another attribute. |
I still don't understand the purpose of this file. Shouldn't OSSEC just pull the event info from the log, format it and send it along? |
From what I deduct from the code where the vista_sec.txt file is used: The content of the textfile is used to create a descriptive message see: It seems not only to be used for Vista but also 2008 R2. |
It probably gets used for anything > Windows XP unless you are using event channel. |
Since everyone seems to share the same confusion and mystery surrounding the vista_sec.txt, including myself, I read through the code and will try to explain what all is happening the best I can. My hope is by doing this it will clear up some of the confusion and also serve as good reference for myself and anyone else who might have questions about it in the future. On Windows, when the agent starts up the vista_sec.txt file is read into a hash map basically. The file itself is formatted as:
The number before the first comma is an event ID. Everything after the comma is a event log message. When looking at the file take note how the messages are formatted:
Specifically, the Now that the file's contents are loaded in memory as a hash map sort of thing, OSSEC can look up the event ID's quickly and get the associated message. As OSSEC's logcollector is reading event logs we come to this crossroads in the code that looks something like this (note this is a bit of pseudo code):
Basically the above is sending any event on a 2008 (non-R2) or newer machine that came from the Security event logs through In If the event ID is found then things continue on in This function can be used in a few ways but when in
This is where those This whole replacement thing is pretty decently documented on the So to answer @mstarks01 question, no, the Eventlog WinAPI's don't just give you the message. Only the values for the "fields". The message still needs to be formatted. This is where shit gets weird though. Our handy The second method which is what The second method seems a lot better to me since you don't have to maintain this separate file unless you want to format things in your own way which shouldn't be necessary with OSSEC for the most part. Why it is/was necessary to do this for All in all though I'd probably move to the event channel stuff (once 2.9 comes out) which works differently using newer API's and seems to be the future for Windows anyway. |
Wow, great writeup @awiddersheim! I wonder how Snare and NXLog handles this. I imagine they have already identified the pain points and come up with the most workable solutions. |
Thanks. Not sure. I used NXLog as a source reference for a lot of the EventChannel stuff I did recently. I'll probably return to them for this as well when time permits. |
After reading through the The replacement stuff done by For now, I'd suggest changing the Hopefully, getting rid of Any one see any other solutions? Any objections on closing this issue? |
Closing this. Will work on #550 which will hopefully make this better. |
I am using OSSEC v2.7.1 on a Windows 2008 R2 server. The results for Windows event 5140 are as follows:
2014 May 08 01:22:33 (server) x.x.x.x->WinEvtLog WinEvtLog: Security: AUDIT_SUCCESS(5140): Microsoft-Windows-Security-Auditing: (no user): no domain: mycompany.company.com: A network share object was accessed. Subject: Security ID: sidnumber Account Name: username Account Domain: mydomain Logon ID: 0xhex Network Information: Source Address: File Source Port: x.x.x.x Share Name: 49626
Here is what the output looks like from a Windows event log:
I am using the eventlog log format. It looks like the "Object Type:" field is getting dropped for some reason and it is shifting the results to the right one place.
(Hopefully I did the markdown correctly for the OSSEC log entry)
The text was updated successfully, but these errors were encountered: