I try to invoke and load functions from an Shellcode looks like that
public static byte[] uc = {
0x4D,0x5A,0x90,0x00,0x03,0x00};//example
In this code are my classes and functions
I have found some invoke methods for dll files ,but how to load the functions from my shellcode(Shellcode from an c# dll)?
As example:
I have an dll and get an shelcode from it via
public static void WriteShell()
{
using (StreamWriter fs = new StreamWriter("shellcode.cs"))
{
byte[] Data = ReadFile("now.dll", GetSize("now.dll"));
int Size = GetSize("now.dll");
fs.Write("public static class ShellCode\n{\n\t");
fs.Write("public static byte[] ucShell = {\t");
for (int i = 0; i < Size; ++i)
{
if (i != 0)
{
fs.Write(',');
}
if ((i % 15) == 0)
fs.Write("\n\t");
fs.Write("0x" + Data[i].ToString("X2"));
}
fs.Write("};");
fs.Write("\n\n\tpublic const int ulSize = {0};\n", Size);
fs.Write("}");
}
the output is like this
public static byte[] uc = {
0x4D,0x5A,0x90,0x00,0x03,0x00};
in the dll i have a class and some functions, example a msgbox or something similar.
example:
public static class now
{
static void run()
{
Messagebox.Show("test");
}
}
now i try to call this function with an invoke like this, Dynamically calling a dll and method with arguments