using System; namespace Communication { class comLink { #region vars delegate void d(); event d connectionStarted; System.Text.StringBuilder _myCommands = new System.Text.StringBuilder(); public string MyCommands { get { return _myCommands.ToString(); } } Pipe.Client myClientPipe = new Pipe.Client(); System.Collections.Generic.SortedDictionary commandList = new System.Collections.Generic.SortedDictionary(); string delimiter = " "; string commandDelimiter = ":"; protected string nameOfThisHack = "LeetConverter"; protected string tagLine = "LeetThis"; #endregion ---vars--- #region con public comLink() { loadDefaultCommands(); Init(); } void Init() { try { // build temp event to do on connection comLink.d tempEvent = null; // inline the new event // this could be a function call but I like to inline to show the scope tempEvent = new comLink.d(delegate { // do this on connection checkIN(); // un-connect the delegate from connectionStarted connectionStarted -= tempEvent; }); // add the delegate to the connectionStarted event connectionStarted += tempEvent; System.Windows.Forms.Application.ApplicationExit += new EventHandler(Application_ApplicationExit); } catch { #if DEBUG System.Windows.Forms.MessageBox.Show("Error - Init #ojch8sh7df8"); #endif } } void Application_ApplicationExit(object sender, EventArgs e) { RunCommand("kill"); } #endregion ---con--- #region com functions protected void Connect() { System.Threading.Thread tempThread_connect = null; try { tempThread_connect = new System.Threading.Thread(new System.Threading.ThreadStart(delegate { bool connected = false; while (!connected) { connected = myClientPipe.Connect(); if (connected) myClientPipe.MessageReceived += new Pipe.Client.MessageReceivedHandler(RunCommand); else System.Threading.Thread.Sleep(1000); } if (connectionStarted != null) connectionStarted(); })); tempThread_connect.Start(); tempThread_connect.IsBackground = true; } catch { if (tempThread_connect != null) tempThread_connect.Abort(); #if DEBUG System.Windows.Forms.MessageBox.Show("Error - Connect #87fhy87eqgwhof8"); #endif } } bool isDisposed = false; void loadDefaultCommands() { AddCommand("kill", (d)delegate { if (!isDisposed) { isDisposed = true; try { myClientPipe.SendMessage(this.tagLine + "-----------I-DIE------------"); } catch { // could not talk to server pipe, ok don't care } System.Windows.Forms.Application.Exit(); System.Environment.Exit(0); } }); AddCommand("commands?", (d)delegate { myClientPipe.SendMessage(_myCommands.ToString()); }); AddCommand("openWindows?", (d)delegate { System.Text.StringBuilder sb = new System.Text.StringBuilder(); foreach (System.Windows.Forms.Form frm in System.Windows.Forms.Application.OpenForms) { if (sb.Length > 0) sb.Append(" --- "); sb.Append(frm.Name + frm.Location.ToString()); } myClientPipe.SendMessage("Forms:" + sb.ToString()); }); } /// /// Build and send the Data On this process and hack /// void checkIN() { HackInfo hackInfo = new HackInfo(); try { string exeName = System.Windows.Forms.Application.ExecutablePath; int pathSize = exeName.LastIndexOf('\\') + 1; exeName = exeName.Substring(pathSize, exeName.LastIndexOf('.') - pathSize); hackInfo.Name = tagLine + "->" + exeName; hackInfo.PID = System.Diagnostics.Process.GetCurrentProcess().Id; hackInfo.HackUsed = nameOfThisHack; hackInfo.ExePath = System.Windows.Forms.Application.ExecutablePath; hackInfo.UserName = System.Environment.UserName; hackInfo.AppName = System.AppDomain.CurrentDomain.FriendlyName; try { hackInfo.AssemblyName = System.Reflection.Assembly.GetEntryAssembly().FullName; } catch { hackInfo.AssemblyName = "ERROR"; } hackInfo.Commands = MyCommands; try { // send my Hack Data to the server myClientPipe.SendObject(hackInfo); } catch { #if DEBUG System.Windows.Forms.MessageBox.Show("Error - send checkIN - " + hackInfo.Name + " #8sd9hf89ds89f"); #endif } } catch { #if DEBUG System.Windows.Forms.MessageBox.Show("Error - " + hackInfo.Name + " - checkIN #98her98hrv"); #endif try { myClientPipe.SendObject(hackInfo); } catch { #if DEBUG System.Windows.Forms.MessageBox.Show("Error - 2 - checkIN #deiuh89rc"); #endif } } } #region sub Class public class HackInfo { public HackInfo() { } string _name; public string Name { get { return _name; } set { _name = value; } } string _userName; public string UserName { get { return _userName; } set { _userName = value; } } string _hackUsed; public string HackUsed { get { return _hackUsed; } set { _hackUsed = value; } } int _pid; public int PID { get { return _pid; } set { _pid = value; } } string _exePath; public string ExePath { get { return _exePath; } set { _exePath = value; } } string _appName; public string AppName { get { return _appName; } set { _appName = value; } } string _assemblyName; public string AssemblyName { get { return _assemblyName; } set { _assemblyName = value; } } string _commands; public string Commands { get { return _commands; } set { _commands = value; } } } #endregion ---sub Class--- #endregion ---com functions--- #region commands protected void AddCommand(string commandText, Delegate commandIN) { try { commandList.Add(commandText, commandIN); _myCommands.Append(commandDelimiter + commandText); } catch { #if DEBUG System.Windows.Forms.MessageBox.Show("Could not add command '" + commandText + "' #if7gf8v7gvf"); #endif } } public void RunCommand(string CommandIN) { try { string[] args = null; string command = string.Empty; if (CommandIN.Contains(delimiter)) { try { command = CommandIN.Substring(0, CommandIN.IndexOf(delimiter)); args = CommandIN.Substring(CommandIN.IndexOf(delimiter) + 1).Split(delimiter.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); } catch { try { command = CommandIN.Substring(0, CommandIN.IndexOf(delimiter)); } catch { #if DEBUG if (CommandIN == null) CommandIN = string.Empty; System.Windows.Forms.MessageBox.Show("Could not do command '" + CommandIN + "' #uifdfsiuvbndsiuf"); #endif return; } } } else command = CommandIN; Delegate targetCommand = commandList[command]; targetCommand.Method.Invoke(targetCommand.Target, args); } catch { #if DEBUG if (CommandIN == null) CommandIN = string.Empty; System.Windows.Forms.MessageBox.Show("Could not do command '" + CommandIN + "' #6g7676df8566"); #endif } } #endregion ---commands--- } }