© 2020 Caendra Inc. - Threat Hunting Professional v2 - Hunting With Splunk (Lab 3)
© 2020 Caendra Inc. - Threat Hunting Professional v2 - Hunting With Splunk (Lab 3)
The IT Security manager has provided you with a Splunk instance that has ingested a
dataset containing numerous Active Directory attacks. He tasked you with creating Splunk
searches that can be used to proactively hunt for them.
The learning objective of this lab is the rule generation ability and becoming more familiar
with Splunk.
The learning objective of this lab is to not only get familiar with Splunk’s architecture and
detection capabilities but also to learn effective Splunk search writing.
Specifically, you will learn how to use Splunk’s capabilities in order to:
• Have better visibility over a network
• Respond to incidents timely and effectively
• Proactively hunt for threats
Splunk: 172.16.84.103
Before proceeding to this lab’s tasks make sure that you have studied “Detection of Active
Directory attacks”, especially if you are not aware of how Active Directory attacks work.
For this task you will have to identify the events/artifacts/traces related to various brute
force attacks inside an Active Directory environment. Specifically, hunt for:
For this task you will have to identify the events/artifacts/traces related to Kerberoasting
activity inside an Active Directory environment. Specifically, hunt for:
Below, you can find solutions for each task. Remember though, that you can follow your own
strategy, which may be different from the one explained in the following lab.
This search looks for events 4768 auditing Kerberos authentication ticket (TGT) requests
and filters them on the Status field equal to code 0x6. This value means that the submitted
username does not exist [3]. The transaction command is used to group subsequent
attempts coming from the same IP address with a maximal pause of 5 minutes between
them. Only transactions containing more than five events are preserved. These are the
conditions that define parameters of a brute force attack. If there is an IP address of
localhost in the event, the computer name is taken as a source. The number of different
usernames is calculated with the mvcount function of the eval command. The rule triggers
only in the case there are attempts towards more than two different accounts.
How to Implement: Logging on domain controllers needs to be set up to log TGT requests.
It can be done by configuring Audit Kerberos Authentication Service auditing setting [3]. The
Known False Positives: Common false positives are attempts with misspelled usernames.
These can be limited by adjusting the search constants precisely for the particular
environment.
This search looks for events 4776 auditing NTLM authentication and filters them on the
Status field equal to code 0xC0000064. This value means that the submitted username does
not exist [4]. The transaction command is used to group subsequent attempts coming from
the same source workstation with a maximal pause of 5 minutes between them. Only
transactions containing more than five events are preserved. These are the conditions that
define parameters of a brute force attack. The number of different usernames is calculated
with mvcount function of the eval command. The rule triggers only in the case there are
attempts towards more than two different accounts.
Known False Positives: Common false positives are attempts with misspelled usernames.
These can be limited by adjusting the search constants precisely for the particular
environment.
This search detects password brute force attempts coming from one source. Those may be
targeting one or multiple accounts, which means this search is also able to identify a
password spraying activity. It searches for attempts where Kerberos authentication was
used. The rule can be useful even if the lockout policy is applied in the domain because it
can detect attempts from adversaries that are aware of the policy. The search filters events
4771 that are logged for several status codes [3]. Among them, there is the code 0x18
which means invalid pre-authentication information, usually a wrong password.
Known False Positives: If there are lots of false positive detections, optionally a condition
where accounts > 1 can be added to the search. However, the condition should be added
only in the case that the Account Lockout Policy is set up in the environment. If there are
multiple IP addresses in use for the same host, the rule can trigger more times for events
which should be grouped together in a single result. Users using multiple accounts on one
computer may trigger this rule by accidentally typing the wrong password. This behavior
can be limited by setting the search constants precisely for the needs of a particular
environment.
Known False Positives: If there are lots of false positive detections, optionally a condition
where accounts > 1 can be added to the search. However, the condition should be added
only in the case that the Account Lockout Policy is set up in the environment. If there are
multiple IP addresses in use for the same host, the rule can trigger more times for events
which should be grouped together in a single result. Users using multiple accounts on one
computer may trigger this rule by accidentally typing the wrong password. This behavior
can be limited by setting the search constants precisely for the needs of a particular
environment.
This search detects password brute force attempts towards one target account. Unlike
previous searches, this rule is set up to capture trials coming from several sources. Both
Kerberos and NTLM authentication events are filtered for status code meaning bad
password. That is the status code 0xC000006A for event 4776 and the status code 0x18 for
event 4771. Transactions are made on TargetUserName field with the maxpause parameter
set to 5 minutes between single events. Only transactions that contain more than five
events in total and events from more than two different sources are preserved as results.
These constants should be changed to values that fit the particular environment.
Known False Positives: If some hosts use multiple IP addresses, the number of source
hosts may be evaluated wrongly. If the condition for sources is sources > 1, the rule can
trigger false-positively for the same source host, showing as two events. This happens
because the event 4776 logs hostname, while event 4771 logs IP addresses only. It can be
fixed by using lookup. A single user logging on multiple computers in a short time may
trigger this rule by accidentally typing the wrong password. This behavior can be limited
by setting the search constants precisely.
This search detects several account lockouts made by a single source in a short time. This
anomaly can be caused by adversaries trying to guess passwords on multiple accounts in
the case they are not aware of the Account Lockout Policy in the domain. The search is
looking into events 4740 - A user account was locked out [5]. The transaction command is
used with the field TargetDomainName. This is the field containing the name of computer
account from which logon attempt was received. This applies to XML event format; the field
is called Caller Computer Name in the standard event format. The condition triggers when
there is more than one account locked from the same source computer.
How to Implement: User Account Management auditing setting enables logging for
account lockout events (4740). The constants in the conditions that appear in the search,
such as maxpause, and accounts, need to reflect Account Lockout Policy settings of the
domain environment. Replacing the condition accounts > 1 by eventcount > 1 returns also
repetitive lockout attempts for the same account. It can be useful in the case that accounts
are being unlocked automatically after some time.
Known False Positives: A user may lock his own multiple accounts by accidentally typing
a wrong password. If some computers are shared among several users, these users can lock
their accounts in a short time from a single computer.
This search identifies repetitive logon attempts with the use of disabled accounts. This rule
detects attempts where Kerberos authentication was used. An attacker may want to exploit
forgotten accounts that are no longer used in the environment. Or eventually, also default
Windows built-in accounts in the case they are disabled. The search is focusing on events
4768 with the status code 0x12, which means that the account is disabled [3]. Transactions
are made on the IpAddress field, and only those containing more than five matches are kept
in the results. This condition detects signs of a brute force activity. The number of target
accounts is evaluated by using the mvcount function on the field TargetUserName. Only
transactions with more than two accounts are displayed.
Known False Positives: Some logon attempts can occur shortly after the account is
disabled by an administrator.
This search finds sources that requested service tickets with weak cipher suites. These
encryption types should be no longer used by modern operating systems in the domain.
Therefore, they are likely signs of possible Kerberoasting activity. The search looks at
events 4769 auditing service ticket requests. It filters for any ticket requests with
encryption type constants equal to the values of vulnerable cipher suites. List of all
encryption types can be found at [8]. All requests for tickets with these encryption types
are displayed.
How to Implement: Domain controllers can log Kerberos TGS service ticket requests
(event 4769) by configuring Audit Kerberos Service Ticket Operations [8]. As the amount of
these events can be quite high, filtering for particular encryption types may also be applied
to log forwarding.
Known False Positives: Using older operating systems or services that do not support AES
encryption types may create false positives. In such a case, the search needs to be modified
to allow the particular encryption type to the specific service.
Requests for several different service names (not related to each other) within a short time
period from a single account are suspicious. Even more so if weak encryption was used in
the service tickets. This search may help to reveal such activities. Service ticket requests for
krbtgt service and computer account service names (those ending with $) are filtered out
from the results. The search focuses on service accounts that were created for specific
services. Subsequent events are grouped on the IpAddress field by the transaction
command. Number of services in each transaction is calculated to display only results
where the number is higher than the one specified in the condition.
How to Implement: Domain controllers can log Kerberos TGS service ticket requests
(event 4769) by configuring Audit Kerberos Service Ticket Operations [8]. The search
constant indicating the number of services needs to be tuned to the needs of a particular
domain environment.
Known False Positives: The assessment of whether services are related or not needs to be
added to the search if possible. Otherwise it needs to be done manually by a security
analyst. Narrowing the search for particular ticket encryption types may prevent false
positives. This search may also be combined with detection search S02D01 which could
help to prevent false positive detections.
The above is due to the Source being logged improperly. There is no such activity in this
lab’s dataset.
This search tracks service requests by examining the IP address and port number. Unusual
values indicate the use of outbound connection for the service request, which is suspicious.
The search examines the IpPort and IpAddress fields in events 4769. Port values under
1024 and any non-private IP addresses are those of interest. The search displays results
whenever such values appear in the request, together with details about the requestor.
How to Implement: Domain controllers can log Kerberos TGS service ticket requests
(event 4769) by configuring Audit Kerberos Service Ticket Operations [8]. If there is a
legitimate service using port beyond 1024 or external IP address, it needs to be whitelisted
in the search.
This search uses a detection method for Kerberoasting based on a honeypot. Honeypot is a
fake service account that is never really used in the environment, but it is set up to look like
a legitimate service account with high privileges assigned. A service ticket requests for this
account are only made by an adversary and will be revealed by this search. The search
filters all events auditing service requests (4769) for ServiceName equal to the honeypot
service account (Honeypot01). The search directly produces results that detect malicious
TGS requests.
How to Implement: Domain controllers can log Kerberos TGS service ticket requests
(event 4769) by configuring Audit Kerberos Service Ticket Operations [8]. A fake account (in
the search named as Honeypot01) needs to be created, and a fake SPN must be registered
for it. Preferably, both account name and SPN should seem as legitimate as possible. The
account can also be part of a fake administrator group (set AdminCount attribute to 1) to
raise its attractivity for an attacker. More details about the implementation can be found at
[9].
Known False Positives: There should not be any false positives. There is no reason to
request a service ticket for the honeypot service by a legitimate user.
This search is provided for completeness’ sake. It won’t produce any results.
This search detects attempts to manipulate with service accounts via PowerShell.
PowerShell is a tool commonly used by attackers. The search may catch SPN scanning
activity or successful acquisition of the service ticket hash. Computers that appear in the
results of this search with an extensive amount of events are worth to investigate. The
search is built on events from PowerShell Operational log. A transaction is created for all
subsequent PowerShell events coming from a single workstation. A new field named raw is
created and assigned the entire raw event. This is a preparation for the full-text search
used in the next step. The search looks for the occurrence of any service account in the raw
data of the PowerShell events. The list of service accounts is provided by a lookup file
service_accounts.csv. Only the transactions containing more suspicious events than the
specified threshold are displayed in the results.
index="ad_hunting" source="xmlwineventlog:microsoft-windows-
sysmon/operational" EventCode=8 OR EventCode=10 NOT
GrantedAccess=0x1400 NOT GrantedAccess=0x1000 NOT
GrantedAccess=0x100000 | where (TargetImage LIKE "%lsass.exe") |
This search detects possible dump of the LSASS process (lsass.exe) memory via Sysmon
events. The process memory contains various credentials while the OS is running. To create
a dump of the lsass.exe process Administrator or SYSTEM privileges are required, especially
SeDebugPrivilege or SeTcbPrivilege [16]. These are the primary detection artifacts used in
this search. It is essential to focus on processes that accessed lsass.exe with these privileges.
The search is focusing on Sysmon events with event codes 10 (ProcessAccess) and 8
(CreateRemoteThread). These events are logged when a process creates another process or
thread. The search focuses on processes interacting with lsass.exe with access mask
specifying higher privileges. This is achieved by whitelisting the low-privileged access
masks. List of access masks can be found at [17]. It is possible to whitelist some processes
that commonly access lsass.exe, such as wininit.exe. However, it is strongly recommended
to specify the full path to the process, as the name and the location of the executable can be
easily changed to look like a legitimate process. The transaction command is used to group
accesses of the same process in a short period. Process name and ID are displayed for
further investigation.
Known False Positives: Some processes may need to access lsass.exe with higher
privileges. Depending on the services used in the environment, these processes can be
whitelisted to prevent false positives. Examples are common Windows processes or AV
solution processes (e.g., Windows Defender).
How to Implement: For event 4656 to be logged, auditing settings under Object Access
category must be enabled [19]. Whitelisting of processes needs to be done carefully. Only
full process paths should be whitelisted. Malicious processes may have their name spoofed
to look like a legitimate process.
Known False Positives: Some processes may need to access lsass.exe with higher
privileges. Depending on the services used in the environment, some processes can be
whitelisted to prevent false positives. Examples are common Windows processes or AV
solution processes (e.g., Windows Defender).
index="ad_hunting" source="xmlwineventlog:microsoft-windows-
sysmon/operational" EventCode=11 TargetFilename=*dmp | table _time,
host, Image, ProcessId, TargetFilename | sort - _time | rename _time
AS "Time", host AS "Host", Image AS "Process", ProcessId AS "Process
ID", TargetFilename AS "Filename" | convert ctime(Time)
How to Implement: Sysmon must be deployed and configured to log file creation (event
11). The logs must be ingested and parsed by using TA for Microsoft Sysmon [18].
Known False Positives: Dump files created for any process may trigger this rule. They can
be created by administrators or developers for debugging purposes. In case this happens
regularly, narrowing the search or whitelisting particular files may help to prevent false
positives.
index="ad_hunting" source="xmlwineventlog:microsoft-windows-
sysmon/operational" EventCode=6 Signed=false | table _time, host,
ImageLoaded, SHA1, SignatureStatus | sort - _time | rename _time AS
"Time", host AS "Host", ImageLoaded AS "Image Loaded", SignatureStatus
AS "Signature Status" | convert ctime(Time)
Some tools used for credential dumping, such as Mimikatz [16], may attempt to install its
own driver to the system. This search aims to detect such attempts by looking at the driver
signature. It may also reveal suspicious installations of other drivers to the system beyond
the scope of this story. Such events happening on critical systems are surely worth of
investigation. The search looks for Sysmon event 6 (Driver loaded) with the value of field
Signed equal to false. By this, loading of unsigned drivers on the monitored systems can be
spotted. Filename with path and hashes can be then used for investigation. Correlation
search S03C04 can be used to gain more information.
Known False Positives The number of false positives depends on the usage of different
software in the environment. Use of legitimate drivers can be logged and found by this
search. If that is the case, whitelisting may be applied to prevent FP detections.
Group Policy Preferences can be used to distribute passwords across the domain. GPP data
is stored in a domain-wide share SYSVOL, to which all Authenticated Users have read access.
Therefore, SYSVOL is a common place for attackers to look for credentials. Such attempts
can be detected by creating a honeypot (fake group policy with no effective settings) and
logging accesses to it. Any access to this file is suspicious, as there are no reasons to access
it. [20] Windows event 5145 (A network share object was checked to see whether client can
be granted desired access) will provide the desired information. The search filters these
events to the honeypot policy file (field RelativeTargetName) and displays information
about the origin of the action. The transaction command is used to group multiple events
from the same source in a short time to a single one.
A fake group policy needs to be created in SYSVOL and deny permissions needs to be set for
it. For instance: policy test.local\Policies\{12345} and permissions Everyone:Deny. The
policy file structure should look as legitimate as possible; the attacker should not suspect
that the policy is a honeypot.
Known False Positives: This rule should not trigger false positives, as there is no reason
to access the file except its creation. However, vulnerability scanners may access the share
and trigger the rule false-positively.
How to Implement: Sysmon must be deployed and configured to log process creation
(event 1). The logs must be ingested and parsed by using TA for Microsoft Sysmon [18]. For
event 4688 to be logged, Audit Process Creation setting must be enabled. Furthermore,
additional settings must be enabled to include command line parameters in the event [24].
Known False Positives: Volume Shadow Copy Service can be used as a backup solution in
the environment. Also, some of the tools included in this search can be used by
Another method for gaining domain credentials is to abuse the Directory Replication
Service Remote protocol used by domain controllers for replication of data. Mimikatz
includes a feature DCSync[16],which effectively “impersonates” a domain controller and
requests account password data from a real domain controller [14]. This rule may help to
hunt it. The search focuses onevent 4662 (An operation was performed on an object). This
event contains field Properties, which enables to determine the access rights used [25].
Therefore, the search filters events based on this field to only those related to DC
replication. Then, the Logon ID of the user should be taken from the results and correlated
with an authentication event 4624 to see further details about the user session. Most
importantly, to determine source workstation and IP address of the activity. The identified
IP addresses from the correlation should be those of Domain Controllers, otherwise we are
dealing with another endpoint/workstation that has been compromised by an attacker and
is impersonating a Domain Controller.
192.168.56.104 is a Win7 machine (see the accompanying thesis for the lab configuration),
certainly not a Domain Controller.
How to Implement: The auditing setting Directory Service Access determines whether the
operating system generates audit events when an Active Directory Domain Services (AD
DS) object is accessed. This is necessary to log event 4662 [26]. A lookup file containing IP
addresses of all domain controllers in the environment must be provided.