-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SECRETSDUMP] New Dump Method - Shadow Snapshot Method via WMI #1719
[SECRETSDUMP] New Dump Method - Shadow Snapshot Method via WMI #1719
Conversation
…ely? Too much noise I think :S
… back to RCE; noisy :(
Hello, this implementation is similar to this PR #1470, now open for more than a year. Hopefully one of these will get merged. |
Hello, I know it may sound stupid from my side, but, is it possible to make it retrieve NTDS.dit file as well? |
Hi @daviosardinha, yeah, it could be possible. But I focused on retrieve SAM because impacket already can retrieve NTDS.dit via Shadow Snapshot with the -use-vss parameter. This option (-use-vss) uses a differente aproach, executing "vssadmin create..." remotely. As @SAERXCIT mentioned, there is a enhanced version of this in this PR #1470 using WMI for retriving NTDS.dit via Shadow Snapshot. Maybe this two efforts should be combined in order to get all options, SAM, SYSTEM, SECURITY (this PR) and NTDS.dit (@SAERXCIT PR) |
Nice one! |
Hi @Veids, as far as I have tested I do not think so. It is possible to list Shadow Snapshot from Impacket's smbclient but apparently not possible to access them. Also note that the format is incorrect (#1718) I have also tried SAMBA smbclient with no success. And in Windows an error is obtained like when accessing SAM/SYSTEM/SECURITY directly on disk. Maybe I am failing at some point, it would be nice if you could give an example please. Thanks! |
Nice @Veids, thanks mate. Then I did not implemented it well (19a310c#diff-8a6b9e2198823742cf22bdbbe05f402809f595772c73e31cba6bf5f9aeb7855fR1068) At my first try, I tried to download them directly through SMB. I am idiot :S. I will review it and try to avoid executing code remotely. Thank you! |
The |
Thanks to @Veids and its advice, it is now working without RCE. It was my mistake that I implemented it bad, but now it is working. SAM/SYSTEM/SECURITY are downloaded via SMB from the Shadow Snapshot. I have to clear a little bit the code, but it is working fine. |
reviewing this one |
impacket/examples/secretsdump.py
Outdated
LOG.debug('Got %s %s' % (obj.DeviceObject,obj.VolumeName)) | ||
return (obj.DeviceObject,obj.VolumeName) | ||
|
||
def __WMIcopy(self, sourcePath, destinationPath): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove unused method
impacket/examples/secretsdump.py
Outdated
# Trying to avoid RCE and download via SMB | ||
|
||
#LOG.debug('Trying to copy the files to Temp directory') | ||
#self.__executeRemote('%%COMSPEC%% /C copy %s\\Windows\\System32\\Config\\SAM %s\\%s' % (ssVolume, pathToCopy, randomNameSAM)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove code commented lines
Excellent! One last thing I forgot to mention, is that shadow copies created duting the attack should be deleted. Do you think this could be implemented? |
Ok @anadrianmanrique, I will try to implement that this weekend. Apparently the Delete method is not documented (https://learn.microsoft.com/en-us/previous-versions/windows/desktop/legacy/aa394428(v=vs.85) but it is available also via WMI.
|
Hi, just to clarify one thing. I have tested it and yes, the SS can be deleted remotely via WMI. I am moving forward to implement it. The Delete method is inherited from ManagementObject (https://learn.microsoft.com/es-es/dotnet/api/system.management.managementobject?view=dotnet-plat-ext-7.0)
|
Shadow Snapshot is now deleted after downloading SAM/SYSTEM/SECURITY The Delete method of ManagementObject (https://learn.microsoft.com/es-es/dotnet/api/system.management.managementobject?view=dotnet-plat-ext-7.0) actually is a call to DeleteInstance or DeleteClass. The implementation of the .NET method can be found here: https://github.com/dotnet/runtime/blob/d099f075e45d2aa6007a22b71b45a08758559f80/src/libraries/System.Management/src/System/Management/ManagementObject.cs#L1939. |
Great job! Thanks for your PR. Now merging |
Hi @anadrianmanrique, a blank file called SAM' was at the root of the repo and has been pushed. I didn´t detected that mistake, I am sorry about that. |
thanks for letting me know! |
[UPDATE]
Thanks to @Veids and its advice, it is now working without RCE. It was my mistake that I implemented it bad, but now it is working. SAM/SYSTEM/SECURITY are downloaded via SMB from the Shadow Snapshot. I have to clear a little bit the code, but it is working fine.
#1719 (comment)
A new method for dumping local credentials has been developed that does not depend on the registry. This technique involves creating a Shadow Snapshot on the remote computer through WMI and downloading the SAM, SYSTEM, and SECURITY files for local analysis. Although Impacket implements a method for utilizing Shadow Snapshot, this method is distinct. The method currently in use targets NTDS in Domain Controllers using vssadmin create. Since the create command is not available in vssadmin on client computers, it is not possible to create a Shadow Snapshot remotely with this built-in tool. However, creation is feasible using WMI.
Regrettably, I was unable to find a method to directly access the Shadow Snapshot remotely, leading me to resort to code execution to transfer the SAM, SYSTEM, and SECURITY files to a temporary local directory, which is more intrusive.Attempts to copy the files via WMI's CIM_LogicalFile were unsuccessful,
yet I opted not to remove the __WMIcopy method.Following the creation of the Shadow Snapshot
and the transfer of files to a temporary directory, the SAM, SYSTEM, and SECURITY files are downloaded through SMB and parsed locally.This update introduces the following parameters:
Example:
The following example use this method: python3 secretsdump.py -use-remoteSSMethod -debug "./Admin:[email protected]"
The Shadow Snapshot has been created.
And the files were downloaded remotely via SMB.