Skip to content

Instantly share code, notes, and snippets.

@evilz
Last active August 29, 2015 14:11
Show Gist options
  • Save evilz/35372712265e5a71c231 to your computer and use it in GitHub Desktop.
Save evilz/35372712265e5a71c231 to your computer and use it in GitHub Desktop.
Infector review1
using DllInjection.Services;
using EasyHook;
using System;
using System.CodeDom.Compiler;
using System.Diagnostics;
using System.IO;
using System.Runtime.Remoting;
namespace DllInfector
{
class Program
{
static void Main(string[] args)
{
string ChannelName = CreateIpcServer();
var pi = Process.Start(new ProcessStartInfo(Environment.CurrentDirectory + @"\TargetManagedProcess.exe")
{
UseShellExecute = false,
RedirectStandardOutput = true
});
Hook(ChannelName, pi.Id);
while (!pi.StandardOutput.EndOfStream)
{
string line = pi.StandardOutput.ReadLine();
Console.WriteLine(line);
}
pi.WaitForExit();
}
private static string CreateIpcServer()
{
string ChannelName = null;
RemoteHooking.IpcCreateServer<MessengerService>(ref ChannelName, WellKnownObjectMode.Singleton);
return ChannelName;
}
private static void Hook(string ChannelName, int processId)
{
RemoteHooking.Inject(
processId,
Environment.CurrentDirectory + @"\DllInjection.dll", // 32 bits
Environment.CurrentDirectory + @"\DllInjection.dll", // 64 bits
ChannelName);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment