Skip to content

[WinRM] Add wmi_invoke and winrm support to rdp, enum_dns, get_netconnections, bitlocker - #1398

Open
XiaoliChan wants to merge 5 commits into
Pennyw0rth:mainfrom
XiaoliChan:winrm-pr2
Open

[WinRM] Add wmi_invoke and winrm support to rdp, enum_dns, get_netconnections, bitlocker#1398
XiaoliChan wants to merge 5 commits into
Pennyw0rth:mainfrom
XiaoliChan:winrm-pr2

Conversation

@XiaoliChan

@XiaoliChan XiaoliChan commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Depends on #1397 — merge that first.

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.SetAllowTSConnections takes AllowTSConnections), and the target instance is addressed by a selector on the class key property.

Four modules gain winrm support:

  • rdp: enable/disable via SetAllowTSConnections, RAM toggling and port query via StdRegProv
  • enum_dns: DNS zone enumeration against root/microsoftdns
  • get_netconnections: network adapter enumeration (tolerant of WSman omitting empty array properties)
  • bitlocker: Win32_EncryptableVolume with the fault code mapping in faults.py

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Deprecation of feature or functionality
  • This change requires a documentation update
  • This requires a third party update (such as Impacket, Dp loot, lsassy, etc)
  • This PR was created with the assistance of AI (Claude Code - implementation and live testing)

Setup guide for the review

Just install pypsrp

Screenshots (if appropriate)

  • RDP module
image
  • enum_dns module
image
  • get_netconnections module
image

Checklist

  • I have ran Ruff against my changes (poetry run ruff check ., use --fix to automatically fix what it can)
  • I have added or updated the tests/e2e_commands.txt file if necessary (new modules or features are required to be added to the e2e tests)
  • If reliant on changes of third party dependencies, such as Impacket, dploot, lsassy, etc, I have linked the relevant PRs in those projects
  • I have linked relevant sources that describes the added technique (blog posts, documentation, etc)
  • I have performed a self-review of my own code (not an AI review)
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation

…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant