Identifying Interactive or RemoteInteractive Session From Service Account
KQL Queries:
KQL query for discovering Interactive or RemoteInteractive logon sessions initiated by service accounts using the DeviceLogonEvents
table in Microsoft Sentinel or Azure Log Analytics:
Key Details:
Service Account Identification:
ServiceAccountPatterns
: A list of patterns that match typical service account naming conventions (e.g.,svc_
,service_
,sa_
).Uses
matches regex
to check if theAccountName
matches these patterns. Customise patterns to fit your organisation.
Logon Type Filtering:
Filters for
Interactive
andRemoteInteractive
logon types, which are uncommon for service accounts.
Logon Status:
Separates successful and failed logon attempts using
countif(LogonType == "LogonSuccess")
andcountif(LogonType == "LogonFailed")
.
Aggregation:
Groups by
AccountName
andLogonType
to summarise:TotalLogons
: Total logon attempts.SuccessfulLogons
: Number of successful logons.FailedAttempts
: Number of failed logon attempts.UniqueDevices
: Number of unique devices involved.
Time Binning:
Group results into 1-hour intervals using
bin(Timestamp, 1h)
.
Results:
Displays key fields, sorted by the number of total logon attempts:
Timestamp
,AccountName
,LogonType
,TotalLogons
,SuccessfulLogons
,FailedAttempts
, andUniqueDevices
.
Customisation:
Service Account Patterns:
Modify
ServiceAccountPatterns
to include all patterns used in your environment.
Time Range:
Add a specific time filter, e.g.,
| where Timestamp between (startTime .. endTime)
.
Use Case:
Identifies potential misuse of service accounts, as they should not typically perform interactive or remote interactive logons.
Splunk Query
Splunk query to discover Interactive or RemoteInteractive logon sessions initiated by service accounts. This query works with Windows Security Event Logs or similar authentication-related data sources. Note: The fields in your Splunk logs may differ slightly; for example, AccountName may be displayed as Account_Name.
Query Details:
Event Code Filtering:
EventCode=4624
: Represents successful logon events.If you want to include failed logons, use
EventCode=4625
.
Logon Type Description:
Maps numeric
LogonType
values:2
: Interactive logon.10
: RemoteInteractive logon.
Service Account Identification:
Uses
match()
to identify accounts matching service account naming conventions (svc_
,service_
,sa_
,admin_
). Modify as needed for your environment.
Filtering for Service Accounts:
Filters the results to only include logons initiated by service accounts (
IsServiceAccount="Yes"
).
Statistics:
Aggregates logon events to show:
TotalLogons
: Total logon attempts.SuccessfulLogons
: Successful logons.FailedLogons
: Failed logons (if EventCode=4625 is included).UniqueDevices
: Unique destination devices.UniqueAccounts
: Count of distinct service accounts involved.
Output:
Displays the key details:
AccountName
,LogonTypeDescription
,TotalLogons
,SuccessfulLogons
,FailedLogons
,UniqueDevices
, andUniqueAccounts
.
Customisation:
Index and Sourcetype:
Replace
index=your_index
andsourcetype=your_sourcetype
with the appropriate values for your data source.
Service Account Patterns:
Adjust the regex in
match()
to align with your organization's naming conventions.
Time Range:
Add a time filter such as
earliest=-24h
or use the Splunk time picker.
This query identifies anomalous use of service accounts in interactive or remote sessions, helping detect potential misuse or compromise.
Last updated