Skip to content

[WinRM] Fix check_if_admin false positive, add Shell access detection - #1396

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

[WinRM] Fix check_if_admin false positive, add Shell access detection#1396
XiaoliChan wants to merge 3 commits into
Pennyw0rth:mainfrom
XiaoliChan:winrm-pr1a

Conversation

@XiaoliChan

@XiaoliChan XiaoliChan commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Depends on #1390 — merge that first.

Description

Fixes a check_if_admin false positive: 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)

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

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