예제 #1
0
        /// <summary>
        /// Plugin Thread
        /// </summary>

        public void PluginMain()
        {
            //Get the application port for the server
            if (!isRunning) //Application starting the first time
            {
                clientList = new List <Socket>();
                int appPort = default(int);
                Types.InputBoxValue result = new Types.InputBoxValue {
                    dialogResult = DialogResult.OK, result = ""
                };
                if (Integrate.CheckPermission(Permissions.Display, pluginToken))
                {
                    result = ServerSettings.ShowInputBox("Android Bridge", "Please enter a port for the android listener to run on", pluginToken);
                }
                if (result.dialogResult != DialogResult.OK)
                {
                    Console.WriteLine("Port not set or display permission is denied");
                    return;
                }
                ui = new AndroidUI(this);
                Invoke(() => ui.Show());
                appPort      = int.Parse(result.result);
                serverSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); //Create the socket server
                serverSocket.Bind(new IPEndPoint(IPAddress.Any, appPort));                                  //Bind the server to any interface and the selected port number
                serverSocket.Listen(50000);                                                                 //begin listen max. 50000 pending connections
                serverSocket.BeginAccept(new AsyncCallback(AcceptCallback), null);                          //begin accepting clients
                isRunning = true;                                                                           //Set the application to running state
            }
            else //Application running in the background
            {
                ui = new AndroidUI(this);
                Invoke(() => ui.Show());
            }
        }
        /// <summary>
        /// Plugin Thread
        /// </summary>

        public void PluginMain()
        {
            //Get the application port for the server
            int appPort = default(int);

            Types.InputBoxValue result = ServerSettings.ShowInputBox("Android Bridge", "Please enter a port for the android listener to run on");
            if (result.dialogResult != DialogResult.OK)
            {
                return;
            }
            ui = new AndroidUI(this);
            Invoke(() => ui.Show());
            appPort      = int.Parse(result.result);
            serverSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); //Create the socket server
            serverSocket.Bind(new IPEndPoint(IPAddress.Any, appPort));                                  //Bind the server to any interface and the selected port number
            serverSocket.Listen(5);                                                                     //begin listen max. 5 pending connections
            serverSocket.BeginAccept(new AsyncCallback(AcceptCallback), null);                          //begin accepting clients
        }
        private int GetPort()
        {
            Types.InputBoxValue ret = sCore.RAT.ServerSettings.ShowInputBox("Please eneter the server port", "Enter a port for the Bot listener to run on");
            if (ret.dialogResult != DialogResult.OK)
            {
                return(-1);
            }
            int portNumber = -1;

            int.TryParse(ret.result, out portNumber);
            if (portNumber == -1)
            {
                sCore.RAT.ServerSettings.ShowMessageBox("You entered an invalid value", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(GetPort());
            }
            else
            {
                return(portNumber);
            }
        }