Skip to main content

impair defenses | indicator blocking | ETW - event tracing for windows | autologger | wmi

https://attack.mitre.org/techniques/T1562/006/ 

https://medium.com/palantir/tampering-with-windows-event-tracing-background-offense-and-defense-4be7ac62ac63

 

synopsis:

Attacker always wants to cover their tracks. so they delete or disable windows event logs, audit logs, they even interrupt logging system or agent from the host so the host cannot send their logs to siem. 

attacker may change the following registry to achieve that:

HKLM\SYSTEM\CurrentControlSet\Control\WMI\Autologger\AUTOLOGGER_NAME\{Provider_GUID}

it can also be done by utilizing some administrative utilities like powershell, windows management instrumentation etc. 

now the question is how can we know the autologger name, GUID etc?

you can know that by navigating to the above registry path. or we can dig deeper the followings:

ETW architecture:

events providers

event tracing sessions

event consumers

 

tracing sessions are responsible for collecting events from event providers and relaying them to log files and consumers. sessions are created and configured by controllers like the windows built-in logman.exe command line utility. now we will see some existing commands for exploring existing trace sessions and their respective ETW providers. note that, need to execute these commands with elevated context. 

list all running trace sessions:

logman query -ets


 data collector set which we call autologger name / ETW provider. 

 

list all providers that a trace session is subscribed to:

logman query "EventLog-Application" -ets

you will get the GUID besides the provider name. 

 

ETW tempering techniques:

ETW provides a stealthy mechanism to affect logging without itself generating an event log trail. here is the log supply cut off procedure--

1. you can alter the registry setting. change the start value from 1 to 0. 

no need to reboot this is called ephemeral. where the attack can take place without a reboot. 

2. attacker can delete the whole registry

HKLM\SYSTEM\CurrentControlSet\Control\WMI\Autologger\AUTOLOGGER_NAME{PROVIDER_GUID}

the above techniques involves the removal of a provider entry from a configured autologger. removing a provider registration from an autologger will cause events to cease the flow to the respective trace session.

i.e. Remove-EtwTraceProvider -AutologgerName EventLog-Application -Guid '{A0C1853B-5C40-4B15-8766-3CF1C58F985A}'

THE ABOVE EXAMPLE, the guid refers to the Microsoft-Windows-PowerShell ETW provider. this command will end up deleting the following registry key:

HKLM\SYSTEM\CurrentControlSet\Control\WMI\Autologger\EventLog-Application\{A0C1853B-5C40-4B15-8766-3CF1C58F985A} 

 

3. Provider enable property modificaition:

HKLM\SYSTEM\CurrentControlSet\Control\WMI\Autologger\AUTOLOGGER_NAME{PROVIDER_GUID} - EnableProperty (REG_DWORD)

this technique involves altering the Enable keyword of an autologger session. for example, by default all ETW provider entries in the EventLog-Application autologger session are set to 0x41 which translates to

EVENT_ENABLE_PROPERTY_SID and  EVENT_ENABLE_PROPERTY_ENABLE_KEYWORD_0.

EVENT_ENABLE_PROPERTY_ENABLE_KEYWORD_0 is not documented. it specifies that any events generated for a provider should be logged even if the keyword value is set to 0. so what attacker can do is, EVENT_ENABLE_PROPERTY_IGNORE_KEYWORD_0 which resulting value 0x11 which further specifies all events where the vaule is 0 and ignore, those not to be logged. 

example:

Set-EtwTraceProvider -Guid '{A0C1853B-5C40-4B15-8766-3CF1C58F985A}' -AutologgerName EventLog-Application -Property 0x11

the guid is for Microsoft-Windows-PowerShell event logging.

the above example will end up setting:

HKLM\SYSTEM\CurrentControlSet\Control\WMI\Autologger\EventLog-Application\{A0C1853B-5C40-4B15-8766-3CF1C58F985A}\EnableProperty to 0x11

upon rebooting events will cease to be reported to the powershell event log. 

 

standard Logging level:

0 log always

1 log critical

2 error

3 warning

4 informational

5 verbose 

 

4. ETW provider removal from a trace session

tempering category: ephemeral

permission required: system

detection artifacts: unfortunately no file, registry, event logs are associated with this event. logman.exe will be issued to perform this attack. an attacker can obfuscate their techniques by using win32 api directly, wmi, dcom, powershell etc. 

the techniques involves removing an ETW provider from a trace session, cutting off its ability to supply events to log file or consumer until a reboot occurs or until the attacker restores the ETW provider. 

here is the following powershell code that attacker can apply:

logman update trace EventLog-Application --p Microsoft-PowerShell -ets

 

Splunk:

check event id 8 and 12 for detection.  

check image or process logman.exe or Image="*\\logman.exe" or Image="*\\wpr.exe"

CommandLine="*query*" or CommandLine="*update trace*"

TargetObject=”HKLM\\SYSTEM\\CurrentControlSet\\Control\\WMI\\Autologger*” 

https://securebug.se/blog/category/detection-rules/

https://gist.github.com/guitarrapc/35a94b908bad677a7310

 

 

 


 attacker can change the start value as 0 instead of 1. 

but a user with non-admin privileges can not even view the permission of this registry. 

permissions should be Administrators, EventLog and SYSTEM

 

 

Comments

Popular posts from this blog

Install Nessus from docker

The below two commands you need to run first one by one:  docker run -itd --name=ramisec_nessus -p 8834:8834 ramisec/nessus docker exec -it ramisec_nessus /bin/bash /nessus/update.sh Username: admin And you need to change the password: #Enter the command line of the docker container docker exec -it ramisec_nessus bash #Execute the following commands in sequence # Enter this directory cd /opt/nessus/sbin # List logged in users ./nessuscli lsuser # Modify the password of the specified user (take admin as an example) ./nessuscli chpasswd admin After access to the nessus, make sure you turn off the automatic updates otherwise crack will not work after some time. Before any scan you need to run the update.sh command (shown above) to have the latest plugins. Now everytime your system reboots, your docker instance will be shutdown. You need to up it again manually. Here are the commands.  1. docker ps -a    Now note down the container id. 2. docker start <container id> C

net command cheat sheet

  To see what users present in the system: net user To see local groups in the system: net localgroup To see domain groups. This should be run on a domain controller: net group To see the details of a user along with his/her group membership: net user mahim To see who are the members of a particular group (local machine): net localgroup "administrators"    (These are not case sensitive. You can use administrators or Administrators. Both will give you same result. To see who are the members of a particular group (domain machine): net group "domain admins" Create a local user: net user localuser1 MyP@ssw0rd /add Create a domain user: net user domainuser1 MyP@ssw0rd /add /domain Add the local user to local admin group: net localgroup Administrators localuser1 /add Add the user to domain admin group: net group "Domain Admins" domainuser1 /add /domain Avi