Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
slapdash:windows_logging [2017/04/18 21:38] – created mgupton | slapdash:windows_logging [2023/03/21 16:41] (current) – mgupton | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ======Windows Logging====== | + | ======Windows Logging |
- | ======wevtutil====== | + | <WRAP round info> |
- | * // | + | This is a slapdash, slipshod, scattershot, |
- | * [[http:// | + | </WRAP> |
- | * [[http:// | + | |
- | ====Terminology==== | + | ======Terminology====== |
+ | * Windows Event Log | ||
* channels | * channels | ||
* publishers | * publishers | ||
Line 11: | Line 11: | ||
* streams | * streams | ||
- | ======Examples====== | + | ======wevtutil====== |
+ | * // | ||
+ | * [[http:// | ||
+ | * [[http:// | ||
+ | |||
+ | ======Specific Events of Note====== | ||
+ | * [[Windows Administrator Activity Events]] | ||
+ | |||
+ | ======Listing Log Channels and Publishers====== | ||
====Enumerate a list of all log channels==== | ====Enumerate a list of all log channels==== | ||
< | < | ||
Line 52: | Line 61: | ||
</ | </ | ||
- | |||
- | ====Log Message Query==== | ||
- | Query for logs in the // | ||
- | |||
- | < | ||
- | wevtutil qe System / | ||
- | Event[0]: | ||
- | Log Name: System | ||
- | Source: Microsoft-Windows-Winlogon | ||
- | Date: 2014-06-18T09: | ||
- | Event ID: 7001 | ||
- | Task: N/A | ||
- | Level: Information | ||
- | Opcode: Info | ||
- | Keyword: N/A | ||
- | User: S-1-5-18 | ||
- | User Name: NT AUTHORITY\SYSTEM | ||
- | Computer: E5420_MGupton.alertlogic.net | ||
- | Description: | ||
- | User Logon Notification for Customer Experience Improvement Program | ||
- | |||
- | </ | ||
=====Execute Against a Remote System===== | =====Execute Against a Remote System===== | ||
Line 86: | Line 73: | ||
======Event Queries====== | ======Event Queries====== | ||
+ | * The following shows how to query Windows Event Log for events. | ||
* One way to get the XPath queries used by the /q option of // | * One way to get the XPath queries used by the /q option of // | ||
- | Query the last 5 logs from the //Security// log channel. | + | ===Query the last 5 logs from the Security log channel.=== |
+ | |||
+ | * Using %%/ | ||
- | Using %%/ | ||
< | < | ||
- | wevtutil qe Security /c:5 /rd:true / | + | wevtutil qe Security /c:5 /rd:true /f:text |
</ | </ | ||
+ | < | ||
+ | wevtutil qe Security /c:5 /rd:true /f:text / | ||
+ | </ | ||
Example: | Example: | ||
Line 134: | Line 125: | ||
< | < | ||
wevtutil qe System / | wevtutil qe System / | ||
+ | </ | ||
+ | |||
+ | ====Log Message Query==== | ||
+ | Query for logs in the // | ||
+ | |||
+ | < | ||
+ | wevtutil qe System / | ||
+ | Event[0]: | ||
+ | Log Name: System | ||
+ | Source: Microsoft-Windows-Winlogon | ||
+ | Date: 2014-06-18T09: | ||
+ | Event ID: 7001 | ||
+ | Task: N/A | ||
+ | Level: Information | ||
+ | Opcode: Info | ||
+ | Keyword: N/A | ||
+ | User: S-1-5-18 | ||
+ | User Name: NT AUTHORITY\SYSTEM | ||
+ | Computer: E5420_MGupton.alertlogic.net | ||
+ | Description: | ||
+ | User Logon Notification for Customer Experience Improvement Program | ||
+ | |||
</ | </ | ||
Line 294: | Line 307: | ||
wevtutil qe System /c:1 /rd:true /f:xml | wevtutil qe System /c:1 /rd:true /f:xml | ||
</ | </ | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | ======Windows Events/ | ||
+ | For each event record Windows has a unique record number. The name of this value may vary depending on how the event data is accessed. For example, in the Windows Event Viewer GUI the value is identified as // | ||
+ | |||
+ | ====Terminology==== | ||
+ | * channel, stream | ||
+ | * provider, publisher | ||
+ | |||
+ | ======Tools, | ||
+ | * [[wevtutil]] | ||
+ | * [[Microsoft Log Parser]] | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * [[http:// | ||
+ | |||
+ | ====Relevant Registry Keys==== | ||
+ | < | ||
+ | HKEY_LOCAL_MACHINE | ||
+ | | ||
+ | CurrentControlSet | ||
+ | | ||
+ | Eventlog | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | </ | ||
+ | ====§§§===== | ||
+ | * [[http:// | ||
+ | |||
+ | ======Topics====== | ||
+ | * Windows Event Forwarding | ||
+ | * [[http:// | ||
+ | ====Logging Policy==== | ||
+ | * [[http:// | ||
+ | ======Windows Events====== | ||
+ | ====Windows 2003 Server==== | ||
+ | ===Windows 2003 Server==== | ||
+ | * Logon/ | ||
+ | ====Disabling Logs==== | ||
+ | ==WFP/ | ||
+ | < | ||
+ | auditpol /set / | ||
+ | </ | ||
+ | ==Windows Logon Auditing== | ||
+ | In the gpedit.msc GUI: | ||
+ | < | ||
+ | Computer Confiuguration\Windows Settings\Security Settings\Audit Policy. | ||
+ | </ | ||
+ | < | ||
+ | auditpol /get / | ||
+ | </ | ||
+ | < | ||
+ | auditpol /get / | ||
+ | </ | ||
+ | < | ||
+ | auditpol /set / | ||
+ | </ | ||
+ | |||
+ | ====Set Maximum Log File Size==== | ||
+ | * [[http:// | ||
+ | |||
+ | ====Set Log Retention Policy==== | ||
+ | * [[http:// | ||
+ | |||
+ | ======Slapdash====== | ||
+ | ===Writing events to the Event Log==== | ||
+ | * Powershell cmdlet Write-EventLog | ||
+ | * [[http:// | ||
+ | |||
+ | The following is an example of using the write-eventlog Powershell cmdlet to write an log messages to the Application log stream. | ||
+ | |||
+ | Note the //source// must be a registered source. | ||
+ | |||
+ | < | ||
+ | | ||
+ | </ | ||
+ | |||
+ | ====Get Events==== | ||
+ | * get-eventlog | ||
+ | |||
+ | |||
+ | ====Use Powershell cmdlet to list Event Log channels==== | ||
+ | < | ||
+ | Get-WinEvent -listlog * | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | Get-EventLog -list | ||
+ | </ | ||
+ | |||
+ | ====Windows Event Log API===== | ||
+ | * [[http:// | ||
+ | |||
+ | ====Log Provider/ | ||
+ | < | ||
+ | reg query hklm\system\currentcontrolset\services\eventlog | ||
+ | </ | ||
+ | |||
+ | |||
+ | ======To Explore====== | ||
+ | ====Understanding How Windows Event Log Works==== | ||
+ | *[[http:// | ||
+ | * Info on creating and using a event message file by creating a string table in a Windows resource. | ||
+ | * [[http:// | ||
+ | * [[http:// | ||
+ | * [[http:// | ||
+ | * [[http:// | ||
+ | * [[http:// | ||
+ | |||
+ | ====Inaccessible Event Log Channels/ | ||
+ | * EvtOpenPublisherMetadata API function | ||
+ | * [[http:// | ||
+ | * EvtOpenSession API function | ||
+ | * [[http:// | ||
+ | |||
+ | ======auditing/ | ||
+ | Get audit policy categories and subcategories. | ||
+ | < | ||
+ | auditpol /list / | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | auditpol /get / | ||
+ | </ | ||
+ | |||
+ | The category //Security Group Management// | ||
+ | < | ||
+ | C: | ||
+ | System audit policy | ||
+ | Category/ | ||
+ | Account Management | ||
+ | Security Group Management | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | C: | ||
+ | System audit policy | ||
+ | Category/ | ||
+ | System | ||
+ | Security System Extension | ||
+ | System Integrity | ||
+ | IPsec Driver | ||
+ | Other System Events | ||
+ | Security State Change | ||
+ | Logon/ | ||
+ | Logon | ||
+ | Logoff | ||
+ | Account Lockout | ||
+ | IPsec Main Mode No Auditing | ||
+ | IPsec Quick Mode No Auditing | ||
+ | IPsec Extended Mode No Auditing | ||
+ | Special Logon | ||
+ | Other Logon/ | ||
+ | Network Policy Server | ||
+ | Object Access | ||
+ | File System | ||
+ | Registry | ||
+ | Kernel Object | ||
+ | SAM | ||
+ | Certification Services | ||
+ | Application Generated | ||
+ | Handle Manipulation | ||
+ | File Share Success and Failure | ||
+ | Filtering Platform Packet Drop Success and Failure | ||
+ | Filtering Platform Connection | ||
+ | Other Object Access Events | ||
+ | Privilege Use | ||
+ | Sensitive Privilege Use No Auditing | ||
+ | Non Sensitive Privilege Use No Auditing | ||
+ | Other Privilege Use Events | ||
+ | Detailed Tracking | ||
+ | Process Termination | ||
+ | DPAPI Activity | ||
+ | RPC Events | ||
+ | Process Creation | ||
+ | Policy Change | ||
+ | Audit Policy Change | ||
+ | Authentication Policy Change | ||
+ | Authorization Policy Change | ||
+ | MPSSVC Rule-Level Policy Change | ||
+ | Filtering Platform Policy Change | ||
+ | Other Policy Change Events | ||
+ | Account Management | ||
+ | User Account Management | ||
+ | Computer Account Management | ||
+ | Security Group Management | ||
+ | Distribution Group Management | ||
+ | Application Group Management | ||
+ | Other Account Management Events | ||
+ | DS Access | ||
+ | Directory Service Changes | ||
+ | Directory Service Replication | ||
+ | Detailed Directory Service Replication | ||
+ | Directory Service Access | ||
+ | Account Logon | ||
+ | Kerberos Service Ticket Operations | ||
+ | Other Account Logon Events | ||
+ | Kerberos Authentication Service | ||
+ | Credential Validation | ||
+ | </ | ||
+ | |||
+ | ======Powershell====== | ||
+ | * get-eventlog | ||
+ | * get-winevent | ||
+ | |||
+ | The //Index// value is the uniqure record number for the event. | ||
+ | < | ||
+ | get-eventlog -log Security -newest 2 | ||
+ | </ | ||
+ | |||
+ | ====Slapdash==== | ||
+ | < | ||
+ | get-eventlog -log Security -newest 2 | where {$_.eventID -eq 4672} | format-list -property * | ||
+ | |||
+ | |||
+ | Get-WinEvent -FilterHashTable @{LogName=' | ||
+ | |||
+ | Get-WinEvent -FilterHashTable @{LogName=' | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | powershell -executionpolicy bypass -command " | ||
+ | </ | ||
+ | ======WMI/ | ||
+ | * [[http:// | ||
+ | |||
+ | Get metadata for the specified log channel. | ||
+ | < | ||
+ | strComputer = " | ||
+ | strChannel = " | ||
+ | |||
+ | Set objWMIService = GetObject(" | ||
+ | & " | ||
+ | strComputer & " | ||
+ | Set colLogFiles = objWMIService.ExecQuery _ | ||
+ | (" | ||
+ | & "Where LogFileName='" | ||
+ | | ||
+ | Wscript.Echo " | ||
+ | | ||
+ | For Each objLogFile in colLogFiles | ||
+ | Wscript.Echo " | ||
+ | Wscript.Echo " | ||
+ | & objLogfile.MaxFileSize | ||
+ | Wscript.Echo "Log filename: " & objLogFile.Drive & objLogFile.Path & objLogFile.LogfileName & " | ||
+ | Next | ||
+ | </ | ||
+ | Get the number of records (events) in the specified log channel. | ||
+ | < | ||
+ | strComputer = " | ||
+ | Set objWMIService = GetObject(" | ||
+ | & " | ||
+ | & strComputer & " | ||
+ | Set colLogFiles = objWMIService.ExecQuery _ | ||
+ | (" | ||
+ | & "Where LogFileName=' | ||
+ | For Each objLogFile in colLogFiles | ||
+ | Wscript.Echo objLogFile.NumberOfRecords | ||
+ | Next | ||
+ | </ | ||
+ | |||
+ | ======Logman====== | ||
+ | List log providers and GUID values. | ||
+ | < | ||
+ | logman query providers | ||
+ | </ | ||
+ | |||
+ | ======Resources====== | ||
+ | * [[https:// | ||
+ | * webinars | ||
+ | * forum | ||
+ | * [[https:// | ||
+ | |||
+ | ====== Windows Object Auditing ====== | ||
+ | * #FIM | ||
+ | * [[https:// | ||
+ |