| PyEtwMonitor (version 0.0.1) |
index pyetwmonitor.py |
Real-time Windows ETW monitoring module.
This module provides a real-time Event Tracing for Windows (ETW)
monitoring solution implemented entirely with Python's standard
library and
It enables the collection, decoding, filtering, and display of
events generated by modern Windows kernel providers.
Supported providers:
file:
Microsoft-Windows-Kernel-File
{EDD08927-9CC4-4E65-B970-C2560FB5C289}
process:
Microsoft-Windows-Kernel-Process
{22FB2CD6-0E7B-422B-A0C7-2FAD1FD0E716}
network:
Microsoft-Windows-Kernel-Network
{7DD42A49-5329-4832-8DFD-43D979153A88}
registry:
Microsoft-Windows-Kernel-Registry
{70EB4F03-C1DE-4F73-A051-33D13D5413BD}
memory:
Microsoft-Windows-Kernel-Memory
{D1D93EF7-E1F2-4F45-9943-03D245FE6C00}
Main features:
- Real-time ETW session creation and management.
- Multiple simultaneous kernel provider activation.
- Event consumption through OpenTraceW and ProcessTrace.
- Event metadata retrieval using the Windows TDH API.
- Automatic decoding of supported ETW property types.
- Filtering by process ID, event ID, and provider name.
- Configurable trace verbosity.
- Graceful shutdown and session cleanup.
Architecture:
1. Parse command-line arguments and configure filters.
2. Validate administrator privileges.
3. Create a private real-time ETW tracing session.
4. Enable the selected ETW providers.
5. Open an event consumer and register the callback.
6. Process incoming events in a dedicated worker thread.
7. Decode and display event metadata and properties.
8. Close the consumer and stop the tracing session.
Requirements:
- Windows operating system.
- Python 3.9 or later.
- Administrator privileges for kernel provider access.
- No third-party Python dependencies.
Usage:
python PyEtwMonitor.py
python PyEtwMonitor.py --providers file,process
python PyEtwMonitor.py --pid 4821 9100 --event-id 12 15
python PyEtwMonitor.py --providers network,registry --level verbose
python PyEtwMonitor.py --list-providers
Command-line arguments:
--providers:
Comma-separated list of providers to enable.
Accepts 'all' to enable every registered provider.
--pid:
Restrict displayed events to the specified process IDs.
--event-id:
Restrict displayed events to the specified event IDs.
--provider-filter:
Restrict displayed events to selected provider names.
--level:
Set the provider trace level ('info' or 'verbose').
--list-providers:
Display registered providers and exit.
Notes:
- ETW sessions are managed through Windows APIs.
- Event decoding depends on provider metadata availability.
- Some providers or events may require additional privileges.
- The module is designed for diagnostic and system monitoring
purposes.
Usage examples:
Monitor process creation:
python PyEtwMonitor.py --providers process --event-id 1
Monitor a specific process:
python PyEtwMonitor.py --pid <id>
Monitor network activity:
python PyEtwMonitor.py --providers network
Monitor file open events:
python PyEtwMonitor.py --providers file --event-id 12
Monitor file creation events:
python PyEtwMonitor.py --providers file --event-id 10
Monitor file deletion events:
python PyEtwMonitor.py --providers file --event-id 11 18
Monitor image loading by a specific process:
python PyEtwMonitor.py --pid <id> --providers process --event-id 5
Monitor registry key open events:
python PyEtwMonitor.py --providers registry --event-id 2
Monitor registry key creation events:
python PyEtwMonitor.py --providers registry --event-id 1
Monitor registry value modification events:
python PyEtwMonitor.py --providers registry --event-id 5
File:
• 10 : NameCreate
• 11 : NameDelete
• 12 : Create / Create_V1
• 13 : Cleanup / Cleanup_V1
• 14 : Close / Close_V1
• 15 : Read / Read_V1
• 16 : Write / Write_V1
• 17 : SetInformation / SetInformation_V1
• 18 : SetDelete / SetDelete_V1
• 19 : Rename / Rename_V1
• 20 : DirEnum / DirEnum_V1
• 21 : Flush / Flush_V1
• 22 : QueryInformation / QueryInformation_V1
• 23 : FSCTL / FSCTL_V1
• 24 : OperationEnd
• 25 : DirNotify / DirNotify_V1
• 26 : DeletePath / DeletePath_V1
• 27 : RenamePath / RenamePath_V1
• 28 : SetLinkPath / SetLinkPath_V1
• 29 : Rename29 / Rename29_V1
• 30 : CreateNewFile / CreateNewFile_V1
• 31 : SetSecurity_V1
• 32 : QuerySecurity_V1
• 33 : SetEA_V1
• 34 : QueryEA_V1
Memory:
• 1 : MemInfo_V1
• 2 : MemInfoWS / MemInfoWS_V1 / MemInfoWS_V2
• 3 : MemInfoSessionWS / MemInfoSessionWS_V1 / MemInfoSessionWS_V2
• 4 : WorkingSetOutSwapStart / WorkingSetOutSwapStart_V1
• 5 : WorkingSetOutSwapStop / WorkingSetOutSwapStop_V1
• 6 : WorkingSetInSwapStart / WorkingSetInSwapStart_V1
• 7 : WorkingSetInSwapStop
• 8 : Acg
• 9 : WorkingSetInSwap
• 10 : MdlAllocation
• 11 : ContAllocation
• 12 : MemInfoNode
Network:
• 10 : KERNEL_NETWORK_TASK_TCPIPDatasent.
• 11 : KERNEL_NETWORK_TASK_TCPIPDatareceived.
• 12 : KERNEL_NETWORK_TASK_TCPIPConnectionattempted.
• 13 : KERNEL_NETWORK_TASK_TCPIPDisconnectissued.
• 14 : KERNEL_NETWORK_TASK_TCPIPDataretransmitted.
• 15 : KERNEL_NETWORK_TASK_TCPIPConnectionaccepted.
• 16 : KERNEL_NETWORK_TASK_TCPIPReconnectattempted.
• 17 : KERNEL_NETWORK_TASK_TCPIPTCPconnectionattemptfailed.
• 18 : KERNEL_NETWORK_TASK_TCPIPProtocolcopieddataonbehalfofuser.
• 26 : KERNEL_NETWORK_TASK_TCPIPDatasent.26
• 27 : KERNEL_NETWORK_TASK_TCPIPDatareceived.27
• 28 : KERNEL_NETWORK_TASK_TCPIPConnectionattempted.28
• 29 : KERNEL_NETWORK_TASK_TCPIPDisconnectissued.29
• 30 : KERNEL_NETWORK_TASK_TCPIPDataretransmitted.30
• 31 : KERNEL_NETWORK_TASK_TCPIPConnectionaccepted.31
• 32 : KERNEL_NETWORK_TASK_TCPIPReconnectattempted.32
• 34 : KERNEL_NETWORK_TASK_TCPIPProtocolcopieddataonbehalfofuser.34
• 42 : KERNEL_NETWORK_TASK_UDPIPDatasentoverUDPprotocol.
• 43 : KERNEL_NETWORK_TASK_UDPIPDatareceivedoverUDPprotocol.
• 49 : KERNEL_NETWORK_TASK_UDPIPUDPconnectionattemptfailed.
• 58 : KERNEL_NETWORK_TASK_UDPIPDatasentoverUDPprotocol.58
• 59 : KERNEL_NETWORK_TASK_UDPIPDatareceivedoverUDPprotocol.59
Process:
• 1 : ProcessStart / ProcessStart_V1 / ProcessStart_V2 / ProcessStart_V3
• 2 : ProcessStop / ProcessStop_V1 / ProcessStop_V2
• 3 : ThreadStart / ThreadStart_V1
• 4 : ThreadStop / ThreadStop_V1
• 5 : ImageLoad
• 6 : ImageUnload
• 7 : CpuBasePriorityChange
• 8 : CpuPriorityChange
• 9 : PagePriorityChange
• 10 : IoPriorityChange
• 11 : ProcessFreezeStart / ProcessFreezeStart_V1
• 12 : ProcessFreezeStop / ProcessFreezeStop_V1
• 13 : JobStart
• 14 : JobTerminateStop
• 15 : ProcessRundown / ProcessRundown_V1
• 16 : task_0
• 17 : PsDiskIoAttributionStart
• 18 : PsDiskIoAttributionStop
• 19 : PsIoRateControlStart / PsIoRateControlStart_V1 / PsIoRateControlStart_V2
• 20 : PsIoRateControlStop / PsIoRateControlStop_V1 / PsIoRateControlStop_V2
• 21 : ThreadWorkOnBehalfUpdate
• 22 : JobServerSiloStart
• 23 : JobServerSiloStart23
• 24 : JobServerSiloStartStop
• 25 : JobServerSiloStart25
• 26 : JobServerSiloStartStop26
Registry:
• 1 : task_0CreateKey
• 2 : task_0OpenKey
• 3 : task_0DeleteKey
• 4 : task_0QueryKey
• 5 : task_0SetValueKey
• 6 : task_0DeleteValueKey
• 7 : task_0QueryValueKey
• 8 : task_0EnumerateKey
• 9 : task_0EnumerateValueKey
• 10 : task_0QueryMultipleValueKey
• 11 : task_0SetInformationKey
• 12 : task_0FlushKey
• 13 : task_0CloseKey
• 14 : task_0QuerySecurityKey
• 15 : task_0SetSecurityKey
• 16 : Thisgroupofeventstrackstheperformanceofmountinghivesfromexistingfiles.Start
• 17 : Thisgroupofeventstrackstheperformanceofmountinghivesfromexistingfiles.RegPerfOpHiveMountBaseFileMounted
• 18 : Thisgroupofeventstrackstheperformanceofmountinghivesfromexistingfiles.RegPerfOpHiveMountLogEntryApplied
• 19 : Thisgroupofeventstrackstheperformanceofmountinghivesfromexistingfiles.Stop
• 20 : Thisgroupofeventstrackstheperformanceofunloadinghives.Start
• 21 : Thisgroupofeventstrackstheperformanceofunloadinghives.Stop
• 22 : Thisgroupofeventstrackstheperformanceofflushinghives.Start
• 23 : Thisgroupofeventstrackstheperformanceofflushinghives.RegPerfOpHiveFlushBecameActiveFlusher
• 24 : Thisgroupofeventstrackstheperformanceofflushinghives.RegPerfOpHiveFlushGatheredLogData
• 25 : Thisgroupofeventstrackstheperformanceofflushinghives.RegPerfOpHiveFlushGatheredPrimaryData
• 26 : Thisgroupofeventstrackstheperformanceofflushinghives.RegPerfOpHiveFlushWroteLogFile
• 27 : Thisgroupofeventstrackstheperformanceofflushinghives.RegPerfOpHiveFlushWrotePrimaryFile
• 28 : Thisgroupofeventstrackstheperformanceofflushinghives.RegPerfOpHiveFlushBoostedActiveFlusher
• 29 : Thisgroupofeventstrackstheperformanceofflushinghives.RegPerfOpHiveFlushStartWaitForActive
• 30 : Thisgroupofeventstrackstheperformanceofflushinghives.RegPerfOpHiveFlushFinishWaitForActive
• 31 : Thisgroupofeventstrackstheperformanceofflushinghives.Stop
• 32 : Thisgroupofeventstrackstheperformanceofregistryshutdown.Start
• 33 : Thisgroupofeventstrackstheperformanceofregistryshutdown.Start33
• 34 : Thisgroupofeventstrackstheperformanceofregistryshutdown.RegPerfOpShutdownFlushStart
• 35 : Thisgroupofeventstrackstheperformanceofregistryshutdown.RegPerfOpShutdownFlushStop
• 36 : Thisgroupofeventstrackstheperformanceofregistryshutdown.Stop
• 37 : Thisgroupofeventstrackstheperformanceofloadinghives.Start
• 38 : Thisgroupofeventstrackstheperformanceofloadinghives.Stop
• 39 : Thisgroupofeventstrackstheperformanceofrestoringhives.Start
• 40 : Thisgroupofeventstrackstheperformanceofrestoringhives.Stop
• 41 : Thisgroupofeventstrackstheperformanceofexportinghives.Start
• 42 : Thisgroupofeventstrackstheperformanceofexportinghives.RegPerfOpSaveFileCopied
• 43 : Thisgroupofeventstrackstheperformanceofexportinghives.RegPerfOpSaveTreeCopied
• 44 : Thisgroupofeventstrackstheperformanceofexportinghives.RegPerfOpSaveFileWritten
• 45 : Thisgroupofeventstrackstheperformanceofexportinghives.Stop
| Classes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Functions | ||
| ||
| Data | ||
| PROVIDERS = {'file': 'EDD08927-9CC4-4E65-B970-C2560FB5C289', 'memory': 'D1D93EF7-E1F2-4F45-9943-03D245FE6C00', 'network': '7DD42A49-5329-4832-8DFD-43D979153A88', 'process': '22FB2CD6-0E7B-422B-A0C7-2FAD1FD0E716', 'registry': '70EB4F03-C1DE-4F73-A051-33D13D5413BD'} PROVIDER_GUID_TO_NAME = {} SESSION_NAME = 'PyEtwMonitor' __all__ = ['PROVIDERS', 'PROVIDER_GUID_TO_NAME', 'EVENT_RECORD_CALLBACK', 'SESSION_NAME', 'ENABLE_TRACE_PARAMETERS', 'ETW_BUFFER_CONTEXT', 'EVENT_DESCRIPTOR', 'EVENT_HEADER', 'EVENT_PROPERTY_INFO', 'EVENT_RECORD', 'EVENT_TRACE', 'EVENT_TRACE_HEADER', 'EVENT_TRACE_LOGFILEW', 'EVENT_TRACE_PROPERTIES', 'GUID', 'PROPERTY_DATA_DESCRIPTOR', 'SYSTEMTIME', 'TIME_ZONE_INFORMATION', 'TRACE_EVENT_INFO_HEADER', 'TRACE_LOGFILE_HEADER', ...] __author_email__ = 'mauricelambert434@gmail.com' __copyright__ = '\nPyEtwMonitor Copyright (C) 2026 Maurice Lambe...ome to redistribute it\nunder certain conditions.\n' __description__ = '\nReal-time Windows ETW monitoring module.\n' __license__ = 'GPL-3.0 License' __maintainer__ = 'Maurice Lambert' __maintainer_email__ = 'mauricelambert434@gmail.com' __url__ = 'https://github.com/mauricelambert/PyEtwMonitor' | ||
| Author | ||
| Maurice Lambert | ||