I am building an alert based on file accesses to certain files. This is what I have so far:
index=wineventlog sourcetype=WinEventLog:Security EventCode=560 OR EventCode=4663 OR EventCode=5145 NOT user=*$
| lookup lookup_wild_folder folder_lookup AS folder_name, server AS host OUTPUT group_lookup user_lookup file_exceptions
| eval user=if(isnull(Object_Name),null,user)
| eval user=if(match(Object_Name,folder_lookup),null,user)
| eval user=if(match(user_lookup,user),null,user)
| eval user=mvfilter(match(Object_Name,file_exceptions))
| table user host folder_lookup folder_name Object_Name Message group_lookup
| ldapfilter domain=default search="(sAMAccountName=$user$)" attrs="memberOf"
| rex field=memberOf "^CN=(?<group_name>[^,]+)"
| eval user=mvfilter(match(group_name,group_lookup))
| search user!=null
| table user host folder_lookup folder_name Object_Name Message group_lookup group_name
My problems are in the mvfilter lines. What I want is to check if the user is a member of an Active Directory group that is in the list of owners for the files (e.g. is user foo in group bar or baz), and is the file something we care about (e.g. does Object_Name contain one of the various file names from the lookup). The mvfilter command LOOKS similar to what I want, but in reverse (the mv variables are the regexes, of which any match is a reason to exit the search). Do I need to create a junk variable to do this?
If you make sure that your lookup values have known delimiters, then you can do it like this. Let's assume you are using a pair of colons ( :: ) to make your list and your input files look something like this (notice the delimiter on both ends of the strings, too):