[WinRM] Add --wmi-query to the winrm protocol via native WSMan WQL filter - #1397
Open
XiaoliChan wants to merge 4 commits into
Open
[WinRM] Add --wmi-query to the winrm protocol via native WSMan WQL filter#1397XiaoliChan wants to merge 4 commits into
XiaoliChan wants to merge 4 commits into
Conversation
…MConnection When running over the wmi protocol the module now reuses the protocol's authenticated IWbemLevel1Login instead of creating its own DCOMConnection to the same target - whose disconnect would clash with the protocol's own on impacket versions that do not guard the INTERFACE.CONNECTIONS thread entry (KeyError: ThreadPoolExecutor-x_x). Over smb nothing changes: the module still creates its own DCOMConnection since the protocol has none.
…nd DCOMConnection Same pattern as the rdp module fix: BitLockerWMI creates its own DCOMConnection to the same target the wmi protocol already holds one for, and disconnecting it removes the shared INTERFACE.CONNECTIONS thread entry, so the protocol-level disconnect afterwards raises KeyError on impacket versions that do not guard it. Reuse the protocol's IWbemLevel1Login instead - over smb nothing changes.
Enumerating the shell resource succeeds for any WinRM-authorized user, so every valid login was reported as (Pwn3d!). admin_privs now comes from a WinRM configuration read - admin only, milliseconds on both paths. Command execution is probed separately by opening each shell endpoint (cmd and PowerShell runspace have separate SDDLs) without running a command, shown SSH-style: [+] dom\admin:pass (Pwn3d!) Shell access! (all) [+] dom\user:pass Shell access! (cmd only)
…lter The query is sent as a wsman:Filter with the Microsoft WQL dialect and executed server-side (projection and WHERE included) - no PowerShell process on the target and no DCOM access. Results are pulled until EndOfSequence. Gated by requires_admin: the WinRM service WMI plugin only serves Administrators, Interactive and Remote Management Users (network logons lack the Interactive group), and the namespace itself needs Remote Enable on top.
XiaoliChan
requested review from
Marshall-Hallenbeck,
NeffIsBack,
mpgn and
zblurx
as code owners
September 6, 2026 13:27
This was referenced Sep 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds
--wmi-query/--wmi-namespaceto the winrm protocol: native WQL execution over WS-Management (wsman:Filter with the Microsoft WQL dialect, Enumerate+Pull paging). No PowerShell runspace or DCOM — the query runs entirely at the WSMan protocol level.Gated by
@requires_admin: the WinRM service WMI plugin only serves Administrators, Interactive and Remote Management Users (network logons lack the Interactive group), and the namespace itself needs Remote Enable on top (Administrators by default).Type of change
Setup guide for the review
Just install pypsrp
Screenshots (if appropriate)
Checklist
poetry run ruff check ., use--fixto automatically fix what it can)tests/e2e_commands.txtfile if necessary (new modules or features are required to be added to the e2e tests)