1. We have a winform program test.exe, which is the target program to be shelled.
2. Create a winform project, delete form1, and create a new class. As follows.
3. Copy test.exe to the project directory as an embedded resource.
Using system;
Using system. Windows. forms;
Using system. Resources;
Using system. reflection;
Using system. IO;
Namespace Test
{
Static class Program
{
[Stathread]
Static void main (string [] ARGs)
{
Stream stream = assembly. getexecutingassembly (). getmanifestresourcestream ("test.code.exe ");
Byte [] BS = new byte [stream. Length];
Stream. Read (BS, 0, (INT) stream. Length );
Assembly ASM = assembly. Load (BS );
Methodinfo info = ASM. entrypoint;
Parameterinfo [] parameters = info. getparameters ();
If (parameters! = NULL) & (parameters. length> 0 ))
Info. Invoke (null, (object []) ARGs );
Else
Info. Invoke (null, null );
}
}
}
The compiled program automatically loads and runs the target file in the resource. Continue to use the program. We can increase the Startup Password and add the target program
Bytes ---------------------------------------------------------------------------------------------------
Stream streamobj = This. GetType (). Assembly. getmanifestresourcestream ("test_exeinresource.alltest.exe ");
Byte [] B = new byte [streamobj. Length];
Streamobj. Read (B, 0, B. Length );
Assembly A = assembly. Load (B );
Type [] mytypes = A. gettypes ();
Bindingflags flags = (bindingflags. nonpublic | bindingflags. Public |
Bindingflags. Static | bindingflags. instance | bindingflags. declaredonly );
Foreach (type T in mytypes)
{
Methodinfo [] MI = T. getmethods (flags );
Object OBJ = activator. createinstance (t );
Foreach (methodinfo m in MI)
{
If (M. Name = "Main ")
{
Maindelegate MD = (maindelegate) Delegate. createdelegate (typeof (maindelegate), M );
Md. begininvoke (null, null );
}
}
}