Monitoring Domain Group Membership Changes With ELK

Khoa previously wrote about monitoring AD Group Membership changes using his Powershell script which can be found here.

In this article we will be setting up a Logstash filter that will look for Event Ids that match the Security Group Management logs generated by your Domain Controller for long term storage. This will allow us to look back through historical data and see when groups were created, deleted, and whether users were added/removed.

These are the Event ID’s that we’re interested in which can be found in this MS Technet article

ID Event Message
4727 A security-enabled global group was created
4728 A member was added to a security-enabled global group
4729 A member was removed from a security-enabled global group
4730 A security-enabled global group was deleted
4731 A security-enabled local group was created
4732 A member was added to a security-enabled local group
4733 A member was removed from a security-enabled local group
4734 A security-enabled local group was deleted
4735 A security-enabled local group was changed
4737 A security-enabled global group was changed
4754 A security-enabled universal group was created
4755 A security-enabled universal group was changed
4756 A member was added to a security-enabled universal group
4757 A member was removed from a security-enabled universal group
4758 A security-enabled universal group was deleted
4764 A group’s type was changed

Note: These events might not be setup to be audited by your Domain Controller, so ensure you are selecting the ones you are interested in.

Knowing these Event ID’s is great; however, it’s difficult just seeing the Event ID’s as they get generated, and having to look at each individual log to see the raw message which tells us what kind of event that is. This is time-consuming; therefore, let’s make it simpler by adding the following to your logstash configuration.

Logstash Config:

Here’s a full Logstash config that includes these changes:

So what changed?

Now anytime a group membership activity is changed, the message will be parsed through logstash and based on the event ID, a short_message field will added which will indicate the type of action that occurred.

Here’s some example of the changes we can see.

  • A Security Group was created
  • A user was added or removed from that particular group

At the end you may create a Dashboard that displays the Event IDs that you might be interested in:

You may search by specific Usernames (Such as your Domain admins, and see who has made any changes).

Here’s the Raw logs along with the field names which will help in creating your Dashboard in Kibana.

Active directory is great, and leveraging Windows Event Forwarder + ELK is a great free alternative to purchasing an vendor-provided application; however, you do have to spend some time setting it up.

Since you read this far, I’ll show you how to create a simple visualization in Kibana to filter these Security Group Management events generated in your environment.

In Kibana

  1. Navigate to Visualization
  2. Create New Visualization
  3. Select “Data Table”
  4. Select your Index
  5. On the search bar paste the following query:
  6. Click on Add Metrics:
    Aggregation: Terms
    Field: Event_id
  7. Add Metrics again
    Aggregation: Terms
    Field: short_message.keyword
  8. Click on the Search button to see your visualization generated. Here’s an example of the past 24 hours and the events it found.

You may then create a dashboard and add other visualizations that you might find interesting.

Note: You will need to forward your windows event logs using Winlogbeat so that your field names match the ones shown in this article. I wrote an article on setting that up in your endpoint which may be accessed here.

Here’s some useful fields to start off with:

event_data.SubjectUserName = The individual that made the changes (e.g. Domain Admin)

event_data.SamAccountName = The Group that was modified (e.g. SuperSecretGroup)

event_data.MemberName = The Individual that was added/removed to a group. (e.g. CN=Pablo Delgado,OU=Users,DC=SuperSecret,DC=com)

I hope this helps out, the next article I will be focusing on other Active directory dashboards such as Account Failure/Lockouts/Account Creations, etc.

Thank you


Leave a Reply

Be the First to Comment!

Notify of