Skip to content

[WMI] Add SAM, LSA and NTDS dump - #1379

Open
zblurx wants to merge 22 commits into
mainfrom
wmi_dump
Open

zblurx wants to merge 22 commits into
mainfrom
wmi_dump

Conversation

@zblurx

@zblurx zblurx commented Aug 26, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Add a full WMI SAM and LSA dump without command execution. There is a required change in Impacket for this to work, but nothing fancy.

I'm also going to implement NTDS dump this way

PR in Impacket : fortra/impacket#2268
For now I pushed the Impacket changes into PennyW0rth fork

Type of change

Insert an "x" inside the brackets for relevant items (do not delete options)

  • 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, Dploot, lsassy, etc)
  • This PR was created with the assistance of AI (list what type of assistance, tool(s)/model(s) in the description)

Setup guide for the review

Any Windows system

Screenshots (if appropriate):

image

Checklist:

Insert an "x" inside the brackets for completed and relevant items (do not delete options)

  • I have ran Ruff against my changes (poetry: 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 (PR here: https://github.com/Pennyw0rth/NetExec-Wiki)

@zblurx zblurx changed the title [WMI] Add SAM and LSA dump without command execution [WMI] Add SAM and LSA dump Aug 26, 2026
@zblurx

zblurx commented Aug 26, 2026 •

Copy link
Copy Markdown
Collaborator Author

Note: Notice a bug when chaining SAM and LSA dump, DCOM session gets disconnected. Maybe it's related to the fact the every time we need a namespace, we instanciate a new one instead of reuse existing one. Maybe some refacto needed here

Comment thread nxc/protocols/wmi.py Fixed
Comment thread nxc/protocols/wmi.py Fixed
Comment thread nxc/protocols/wmi.py Fixed
@zblurx

zblurx commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator Author

Note: Notice a bug when chaining SAM and LSA dump, DCOM session gets disconnected. Maybe it's related to the fact the every time we need a namespace, we instanciate a new one instead of reuse existing one. Maybe some refacto needed here

Update: It was the case. The refacto fixed it. Now NTDS dump is working, and we can chain SAM LSA and NTDS:

image

@zblurx

zblurx commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator Author

Added an option to reuse existing ShadowCopy
image

Comment thread nxc/protocols/wmi/remoteops.py Fixed
@zblurx zblurx changed the title [WMI] Add SAM and LSA dump [WMI] Add SAM, LSA and NTDS dump Aug 27, 2026
@XiaoliChan

XiaoliChan commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

Hi @zblurx, how about the download speed? it's fast or not?

BTW, the download file method is awesome, looks really OPSEC, and another thing is the powershell namespace only works on system >= 2012, win7/08 won't

@zblurx

zblurx commented Aug 27, 2026 •

Copy link
Copy Markdown
Collaborator Author

Hi @zblurx, how about the download speed? it's fast or not?

BTW, the download file method is awesome, looks really OPSEC

Hey, in my lab the ntds.dit file is 16 Mo and it takes approximately 8 seconds to get the file. I have not tested but I guess for big NTDS (like 10K+ users) it can take some time.

and another thing is the powershell namespace only works on system >= 2012, win7/08 won't

Yes, I have not found a workaround for that...

@XiaoliChan

Copy link
Copy Markdown
Contributor

Hey, in my lab the ntds.dit file is 16 Mo and it takes approximately 8 seconds to get the file. I have not tested but I guess for big NTDS (like 10K+ users) it can take some time.

Can U test this patch?
https://github.com/0xthirteen/WMI_Proc_Dump/blob/main/wmi-proc-dump.py#L26

@XiaoliChan

XiaoliChan commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

Yes, I have not found a workaround for that...

Use tradition event subscription to do that XD, if powershell namespace not existed, then fallback to event subscription.

https://github.com/XiaoliChan/wmiexec-Pro/blob/main/lib/modules/hashdump.py#L98

@zblurx

zblurx commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator Author

Hey, in my lab the ntds.dit file is 16 Mo and it takes approximately 8 seconds to get the file. I have not tested but I guess for big NTDS (like 10K+ users) it can take some time.

Can U test this patch? https://github.com/0xthirteen/WMI_Proc_Dump/blob/main/wmi-proc-dump.py#L26

Tested, it does not change anything. I guess the changes I have made in impacket are similar

@XiaoliChan

Copy link
Copy Markdown
Contributor

Tested, it does not change anything. I guess the changes I have made in impacket are similar

Great, great

zblurx and others added 2 commits September 9, 2026 10:41
Signed-off-by: zblurx <68540460+zblurx@users.noreply.github.com>
@zblurx zblurx added the enhancement New feature or request label Sep 9, 2026

@NeffIsBack NeffIsBack left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only problem at the moment seems to be a download limit of somewhere between 50MB and 100MB. Therefore, my 700MB NTDS.dit file couldn't be downloaded and the ntds dump broke.

Rest looks good.

Image

zblurx and others added 2 commits September 14, 2026 16:26
Signed-off-by: zblurx <68540460+zblurx@users.noreply.github.com>
Comment thread nxc/protocols/wmi.py Dismissed
@snowpeacock

Copy link
Copy Markdown

Hello,

Thanks all for the work, I'm a big fan of the "remoteSSwmi" method and can't wait to use it with netexec.

The download method seems really funny but indeed quite slow.
Are you not using the "mapping to a SMB GMT path + SMB download" method because it's in the wmi category or for opsec reasons ?

Is it worth it to create a SMB module to have it or do you find it redundant ?

@XiaoliChan

Copy link
Copy Markdown
Contributor

Is it worth it to create a SMB module to have it or do you find it redundant ?

SMB have remoteSSwmi already, --ntds vss

@snowpeacock

Copy link
Copy Markdown

Is it worth it to create a SMB module to have it or do you find it redundant ?

SMB have remoteSSwmi already, --ntds vss

Indeed but it is using command execution on the host + vssadmin right ? I mean creating shadow copy using wmi and retrieving the file with SMB only to avoid any command execution.

@XiaoliChan

XiaoliChan commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Is it worth it to create a SMB module to have it or do you find it redundant ?

SMB have remoteSSwmi already, --ntds vss

Indeed but it is using command execution on the host + vssadmin right ? I mean creating shadow copy using wmi and retrieving the file with SMB only to avoid any command execution.

No, u can read the source code from impacket, it’s already update by this PR fortra/impacket#1719

The VSS in NetExec is doing same thing as remoteSS stuff, basically remote call win32_shadowcopy

@snowpeacock

Copy link
Copy Markdown

Is it worth it to create a SMB module to have it or do you find it redundant ?

SMB have remoteSSwmi already, --ntds vss

Indeed but it is using command execution on the host + vssadmin right ? I mean creating shadow copy using wmi and retrieving the file with SMB only to avoid any command execution.

No, u can read the source code from impacket, it’s already update by this PR fortra/impacket#1719

The VSS in NetExec is doing same thing as remoteSS stuff, basically remote call win32_shadowcopy

I'm aware of this PR yes, I use it a lot with secretsdump it's surprisingly good opsec for an impacket script :)

But it seems that nxc smb --ntds vss uses -use-vss instead of --use-remoteSS (I have the last commit for both nxc and impacket).
I'm pretty sure as I crashed it on purpose and the stacktrace mentions vssadmin create shadow + defender is detecting traces of wmiexec.

@XiaoliChan

Copy link
Copy Markdown
Contributor

But it seems that nxc smb --ntds vss uses -use-vss instead of --use-remoteSS (I have the last commit for both nxc and impacket). I'm pretty sure as I crashed it on purpose and the stacktrace mentions vssadmin create shadow + defender is detecting traces of wmiexec.

Wait... you are right; I just messed it up, sorry, current didn't add the remoteSSMethodWMINTDS‎

Are you not using the "mapping to a SMB GMT path + SMB download" method because it's in the wmi category or for opsec reasons ?

For this, if we can do it all over WMI, then why do we need to use SMB (to create another connection; this would be really noisy)

@snowpeacock

Copy link
Copy Markdown

But it seems that nxc smb --ntds vss uses -use-vss instead of --use-remoteSS (I have the last commit for both nxc and impacket). I'm pretty sure as I crashed it on purpose and the stacktrace mentions vssadmin create shadow + defender is detecting traces of wmiexec.

Wait... you are right; I just messed it up, sorry, current didn't add the remoteSSMethodWMINTDS‎

No problem!

Are you not using the "mapping to a SMB GMT path + SMB download" method because it's in the wmi category or for opsec reasons ?

For this, if we can do it all over WMI, then why do we need to use SMB (to create another connection; this would be really noisy)

Ok, then do you think this could be a good feature as a SMB module ? If so I will maybe make a PR.

@XiaoliChan

XiaoliChan commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Ok, then do you think this could be a good feature as a SMB module ? If so I will maybe make a PR.

Sure, please add remoteSSWMI to sam and lsa, and add remoteSSWMINTDS to ntds in smb

For sam and lsa, I forgot is secdump is doing execute command reg save xxx or not, if it, the order should be regdump > sswmi > secdump

For ntds it should be drsuapi > remoteSSWMI > VSS

@NeffIsBack

Copy link
Copy Markdown
Member

Why are we using vss instead of remoteSS in the first place if vss does command execution?

@XiaoliChan

Copy link
Copy Markdown
Contributor

Why are we using vss instead of remoteSS in the first place if vss does command execution?

Yes, just check imapcket source code, vss did vssadmin via command execution.

@snowpeacock

Copy link
Copy Markdown

Why are we using vss instead of remoteSS in the first place if vss does command execution?

I believe it's only remains of the past. Should I make a PR ? I believe it would correspond to #1360.

@NeffIsBack

Copy link
Copy Markdown
Member

Why are we using vss instead of remoteSS in the first place if vss does command execution?

Yes, just check imapcket source code, vss did vssadmin via command execution.

Yeah but why are we using vss and not remoteSS then?

@XiaoliChan

XiaoliChan commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Yeah but why are we using vss and not remoteSS then?

No, @snowpeacock is talking about the SMB protocol 😂, current SMB not implement remoteSS

@NeffIsBack

Copy link
Copy Markdown
Member

Why are we using vss instead of remoteSS in the first place if vss does command execution?

I believe it's only remains of the past. Should I make a PR ? I believe it would correspond to #1360.

Hmm okay, what's the advantage over this PR tho? Having everything natively in wmi was the reason we closed #1370 as duplicate.

@NeffIsBack NeffIsBack left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good so far (one small thing/comment that could be improved). Afterwards we should also integrate wmi in dpapi dumping.

Comment thread nxc/protocols/wmi.py

wql = f"SELECT FileSize FROM CIM_DataFile WHERE Name = '{escaped_path}'"
self.wmi_query(wql=wql, namespace="//./root/cimv2", callback_func=callback_func)
# If file is bigger than 70MB, print a warning

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a comment about why we limit it to 70MB? The thing with the default transfer limit and how you can check it, just that we know in the future why we did what we did

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.

Feature request: add sswmi (WMI shadow snapshot) dump method to --sam/--lsa/--ntds

5 participants