Skip to content

[WinRM] Add --wmi-query to the winrm protocol via native WSMan WQL filter - #1397

Open
XiaoliChan wants to merge 3 commits into
Pennyw0rth:mainfrom
XiaoliChan:winrm-pr1b
Open

XiaoliChan wants to merge 3 commits into
Pennyw0rth:mainfrom
XiaoliChan:winrm-pr1b

Conversation

@XiaoliChan

@XiaoliChan XiaoliChan commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Depends on #1396 — merge that first.

Description

Adds --wmi-query / --wmi-namespace to 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

  • 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)

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

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.
@NeffIsBack NeffIsBack added the enhancement New feature or request label Sep 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants