Splunk Search

Splunk Query

whitecat001
Explorer

Can i get a Splunk query that shows the last logon date for a group of active directory service account 

 

 

Thanks 

Labels (1)
0 Karma

antoniolamonica
Explorer

index=wineventlog
sourcetype=WinEventLog
EventCode=4624
user="svc*"

| eval EventTime=_time
| eval EventTime=strftime(_time, "%m/%d/%Y %H:%M:%S %Z"

| stats latest(EventTime) as lastlogon by user
| table lastlogon, user
Tags (2)
0 Karma

emdaax
Explorer

Hi @whitecat001,

Assuming your Active Directory logs are being indexed under "index=windows" and you are forwarding the logon events EventCode=4624 (successful logons), you can use the following query:

 

index=windows* source="WinEventLog:Security" sourcetype=xmlwineventlog host=* user!="*$" EventCode=4624 dest_nt_domain=<your domain name> Logon_Type=5
| stats max(_time) as last_login by index, host, dest, dest_nt_domain, user, src_ip, Logon_Type
| eval last_login=strftime(last_login, "%Y-%m-%d %H:%M:%S")

 

The EventCode=4624  filters the logs to only include successful logon events.

You can use the field "Logon_Type", which points out how the user logged on.
There are a total of nine different types of logons, the most common logon types are: logon type 2 (interactive) and logon type 3 (network).

Any logon type other than 5 (which denotes a service startup) is a red flag.

Logon TypeLogon TitleDescription
0SystemUsed only by the System account, for example at system startup.
2InteractiveA user logged on to this computer.
3NetworkA user or computer logged on to this computer from the network.
4BatchBatch logon type is used by batch servers, where processes may be executing on behalf of a user without their direct intervention.
5ServiceA service was started by the Service Control Manager.
7UnlockThis workstation was unlocked.
8NetworkCleartextA user logged on to this computer from the network. The user's password was passed to the authentication package in its unhashed form. The built-in authentication packages all hash credentials before sending them across the network. The credentials do not traverse the network in plaintext (also called cleartext).
9NewCredentialsA caller cloned its current token and specified new credentials for outbound connections. The new logon session has the same local identity, but uses different credentials for other network connections.
10RemoteInteractiveA user logged on to this computer remotely using Terminal Services or Remote Desktop.
11CachedInteractiveA user logged on to this computer with network credentials that were stored locally on the computer. The domain controller was not contacted to verify the credentials.
12CachedRemoteInteractiveSame as RemoteInteractive. This is used for internal auditing.
13CachedUnlockWorkstation logon.

 

best regards,

P.S.: Karma Points are always appreciated 😉

0 Karma

PickleRick
SplunkTrust
SplunkTrust

First and foremost - what data do you have in your Splunk?

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @whitecat001 ,

you could try with something like this:

index=your_index
| stats latest(_time) AS _time BY Account_name

if you don't like to use the _time field, but you want to rename it, remember that _time is in epochtime and that's automaticay displayed in Human readable, if you rename, you have aso to convert in Human Readable format.

index=your_index
| stats latest(_time) AS latest BY Account_name
| eval latest=strftime(latest),"%Y-%m-%d %H:%M:%S")

Ciao.

Giuseppe

0 Karma

whitecat001
Explorer

can i pls get another search that can show last logon date for active directory service account

0 Karma

whitecat001
Explorer

its not working

0 Karma
Get Updates on the Splunk Community!

.conf24 | Day 0

Hello Splunk Community! My name is Chris, and I'm based in Canberra, Australia's capital, and I travelled for ...

Enhance Security Visibility with Splunk Enterprise Security 7.1 through Threat ...

 (view in My Videos)Struggling with alert fatigue, lack of context, and prioritization around security ...

Troubleshooting the OpenTelemetry Collector

  In this tech talk, you’ll learn how to troubleshoot the OpenTelemetry collector - from checking the ...