Monitor and track AD authentication with Splunk

Monitor and track AD authentication with Splunk

This solution will help you to track Active Directory failed authentication requests. It is based on two “modules” :

  • Task scheduled triggered by event ID
  • Splunk for visualization
Splunk

The first step is to have a running Splunk system. You can there to download it.

Index

Create your first Splunk index :

1. In Splunk Web, navigate to Settings > Indexes and click New.

2. To create a new index, enter:

  • A name for the index. User-defined index names must consist of only numbers, lowercase letters, underscores, and hyphens. They cannot begin with an underscore or hyphen, or contain the word “kvstore”.
  • The path locations for index data storage:
    • Home path; leave blank for default $SPLUNK_DB/<index_name>/db
    • Cold db path; leave blank for default $SPLUNK_DB/<index_name>/colddb
    • Thawed/resurrected db path, leave blank for default $SPLUNK_DB/<index_name>/thaweddb
  • The maximum size of the entire index. Defaults to 500000MB.
  • The maximum size of the hot (currently written to) portion of this index. When setting the maximum size, you should use auto_high_volume for high volume indexes (such as the main index); otherwise, use auto.
  • The frozen archive path. Set this field if you want to archive frozen buckets. For information on bucket archiving, see “Archive indexed data”.

Note: For detailed information on each of these settings, see “Configure index storage”.

3. Click Save.

You can edit an index by clicking on the index name in the Indexes section of the Settings menu in Splunk Web. Properties that you cannot change in Splunk Web are grayed out. To change those properties, edit indexes.conf, then restart the indexer.

Note: Some index properties are configurable only by editing the indexes.conf file. Check the indexes.conftopic for a complete list of properties.

Inputs

You can add data inputs from Splunk Home or Splunk System:

From Splunk Home, select Add Data. This takes you to the Add Data page, with links to recipes for a wide variety of data input types. This is the easiest way to start adding inputs. See “How do you want to add data?”
From anywhere in Splunk Web, select System. Then select Data inputs from the Data section of the System pop-up. This takes you to a page where you can view and manage your existing inputs, as well as add new ones.
The Add Data page offers three options to get data in: Upload, Monitor, and Forward. Clicking one of the icons takes you to a page that lets you define the data you want to upload, monitor, or forward.

For more information on using Splunk Web to configure your inputs, look in the topics covering specific inputs later in this manual. For example, to learn how to use Splunk Web to configure network inputs, see “Get data from TCP and UDP ports.”

You can configure most inputs with Splunk Web. For a small number of input types, you must edit inputs.conf directly. In addition, some advanced settings for other input types are available only through inputs.conf.

When you add an input through Splunk Web, Splunk Enterprise adds that input to a copy of inputs.conf that belongs to the app you’re currently in. This has consequences that you need to consider. For example, if you navigated to Splunk System directly from the Search page and then added an input there, Splunk Enterprise adds the input to $SPLUNK_HOME/etc/apps/search/local/inputs.conf. Make sure you’re in the desired app when you add your inputs. For background on how configuration files work, read “About configuration files”.

For this example we will use the following values :

Normally you can now go to the next step (I’m not a Splunk specialist, only a poor user 🙂 )

Windows Tasks
Auditing Policies

On the domain controllers you want to audit, be sure you have enabled these audit policies :
Audit account logon events
Audit logon events

Scheduled Tasks (triggered by Events)

Create the first task scheduled as described below :

  • copy the script below in c:\temp on the domain controller
  • create a scheduled task with this parameters :
    • name : event 4625
    • Trigger type : “On an event”
    • Trigger Settings : “Custom” > click on the button “New Event Filter” :
      Logs : Security
      Source : Microsoft Windows security auditing.
      Event ID : 4625
    • click on the ok button to close the “New Event Filter” window
    • Action tab : Click “New” > Program/script = powershell.exe
      Argument = -executionpolicy bypass "c:\temp\event4625.ps1" -eventIpPort $(eventIpPort) -eventIpAddress $(eventIpAddress) -eventProcessName $(eventProcessName) -eventWorkstationName $(eventWorkstationName) -eventLogonType $(eventLogonType) -eventSubStatus $(eventSubStatus) -eventStatus $(eventStatus) -eventTargetDomainName $(eventTargetDomainName) -eventTargetUserName $(eventTargetUserName) -eventTargetUserSid $(eventTargetUserSid) -eventSubjectUserSid $(eventSubjectUserSid) -eventSubjectUserName $(eventSubjectUserName) -eventSubjectDomainName $(eventSubjectDomainName)
      Start in = c:\temp
  • Close the windows to validate the creation of the scheduled task
  • Right click the scheduled task > Export
  • open the exported file with a text editor
  • add the following lines :

  • xml

  • save and close the file
  • delete the scheduled task you have created previously
  • right click and then import the modified xml file as a new scheduled task

event4625.ps1 (required libraries)

Create the second task scheduled as described below :

  • copy the script below in c:\temp on the domain controller
  • create a scheduled task with this parameters :
    • name : event 4771
    • Trigger type : “On an event”
    • Trigger Settings : “Custom” > click on the button “New Event Filter” :
      Logs : Security
      Source : Microsoft Windows security auditing.
      Event ID : 4771
    • click on the ok button to close the “New Event Filter” window
    • Action tab : Click “New” > Program/script = powershell.exe
      Argument = -executionpolicy bypass "c:\temp\event4771.ps1" -eventIpPort $(eventIpPort) -eventIpAddress $(eventIpAddress) -eventStatus $(eventStatus) -eventTargetUserName $(eventTargetUserName) -eventTargetUserSid $(eventTargetUserSid) -eventServiceName $(eventServiceName) -eventTicketOptions $(eventTicketOptions) -eventPreAuthType $(eventPreAuthType) -eventCertIssuerName $(eventCertIssuerName) -eventCertSerialNumber $(eventCertSerialNumber) -eventCertThumbprint $(eventCertThumbprint)
      Start in = c:\temp
  • Close the windows to validate the creation of the scheduled task
  • Right click the scheduled task > Export
  • open the exported file with a text editor
  • add the following lines :

  • save and close the file
  • delete the scheduled task you have created previously
  • right click and then import the modified xml file as a new scheduled task

event4771.ps1 (required libraries)

Visualize

Normally you can now view events in the Splunk index you have created : go to the Splunk search page (App: Search & Reporting)
In the search field, enter : index=”ad-auth”

You will have all the events forwarded to the Splunk server.

You can go further and create a new dashboard using the data :
splunk_dash


References

http://docs.splunk.com/Documentation/Splunk/6.2.2/Indexer/Setupmultipleindexes

http://docs.splunk.com/Documentation/Splunk/6.2.2/Data/Configureyourinputs

<>

My Powershell script categories

Leave a Reply

Your email address will not be published. Required fields are marked *