[WinRM] Add wmi_invoke and winrm support to rdp, enum_dns, get_netconnections, bitlocker - #1398
Open
XiaoliChan wants to merge 5 commits into
Open
[WinRM] Add wmi_invoke and winrm support to rdp, enum_dns, get_netconnections, bitlocker#1398XiaoliChan wants to merge 5 commits into
XiaoliChan wants to merge 5 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.
…nections, bitlocker wmi_invoke on the winrm protocol executes a WMI method natively over WS-Management (method INPUT body in the class resource URI namespace, instance addressed by a selector on the class key property) - no PowerShell process, the WinRM equivalent of the smb/wmi protocols calling WMI methods over DCOM. Four modules gain winrm support on top of the wmi_query and wmi_invoke primitives: rdp (enable/disable, RAM, port), enum_dns, get_netconnections and bitlocker, with the fault code mapping in faults.py.
XiaoliChan
requested review from
Marshall-Hallenbeck,
NeffIsBack,
mpgn and
zblurx
as code owners
September 6, 2026 13:28
14 tasks
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_invoke()to the winrm protocol: native WSMan ExecMethod for WMI method calls without PowerShell or DCOM. Parameter names match the class schema (not always MSDN, e.g.Win32_TerminalServiceSetting.SetAllowTSConnectionstakesAllowTSConnections), and the target instance is addressed by a selector on the class key property.Four modules gain winrm support:
SetAllowTSConnections, RAM toggling and port query viaStdRegProvroot/microsoftdnsWin32_EncryptableVolumewith the fault code mapping infaults.pyType 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)