예제 #1
0
 private void startKeyboardLogger(string connectIP, int connectPort)
 {
     Task.Factory.StartNew(() =>
     {
         try
         {
             clientLogger = new TCP.Client(connectIP, connectPort);
             if (access_KeyboardLogger)
             {
                 isLoggerStarted = true;
             }
             else
             {
                 if (clientLogger != null)
                 {
                     clientLogger.Close();
                 }
             }
         }
         catch (Exception ex)
         {
             Console.WriteLine(ex.Message);
         }
     });
 }
예제 #2
0
 private void startTaskMgr(string connectIP, int connectPort)
 {
     Task.Factory.StartNew(() =>
     {
         TCP.Client clientTaskMgr = null;
         try
         {
             clientTaskMgr = new TCP.Client(connectIP, connectPort);
             if (access_TaskMgr)
             {
                 while (true)
                 {
                     clientTaskMgr.Send(getProcessInfo());
                     clientTaskMgr.RecvBytes();
                 }
             }
             else
             {
                 if (clientTaskMgr != null)
                 {
                     clientTaskMgr.Close();
                 }
             }
         }
         catch (Exception ex)
         {
             if (clientTaskMgr != null)
             {
                 clientTaskMgr.Close();
             }
             Console.WriteLine(ex.Message);
         }
     });
 }
예제 #3
0
 private void start_keyboard_capture(string connectIP, int connectPort)
 {
     Task.Factory.StartNew(() =>
     {
         TCP.Client cl_keyboard = new TCP.Client(connectIP, connectPort);
         if (access_CaptureKeyboard)
         {
             status_keyboard.Visible = true;
             try
             {
                 while (is_connected)
                 {
                     string keyData = cl_keyboard.RecvString();
                     if (keyData == "")
                     {
                         cl_keyboard.Close();
                         cl_keyboard = null;
                         break;
                     }
                     SendKeys.SendWait(keyData);
                 }
             }
             catch (Exception ex)
             {
             }
         }
         if (cl_keyboard != null)
         {
             cl_keyboard.Close();
         }
         cl_keyboard             = null;
         status_keyboard.Visible = false;
     });
 }
예제 #4
0
 private void start_capture(string ip_addr, int port)
 {
     Task.Factory.StartNew(() =>
     {
         TCP.Client cl_cap = new TCP.Client(ip_addr, port);
         if (access_Capture)
         {
             status_camera.Visible = true;
             try
             {
                 while (is_connected)
                 {
                     cl_cap.Send(get_screen_bytes(), 5000);
                     string[] sp_data = cl_cap.RecvString(5000).Split(',');
                     Thread.Sleep(int.Parse(sp_data[0]));
                 }
             }
             catch
             {
             }
             status_camera.Visible = false;
         }
         cl_cap.Close();
     });
 }
예제 #5
0
        private void start_pinging(string ip_addr, int port)
        {
            Task.Factory.StartNew(() =>
            {
                clientPing = new TCP.Client(ip_addr, port, 5);
                try
                {
                    Stopwatch sw = new Stopwatch();
                    do
                    {
                        sw.Start();
                        clientPing.Send("+OK", 5000);
                        clientPing.RecvString(5000);
                        sw.Stop();
                        status_text.Text = clientPing.GetServerIP + " - " + sw.Elapsed.TotalMilliseconds.ToString() + "ms";
                        sw.Reset();

                        Console.WriteLine("+PING");
                        Thread.Sleep(1000);
                        if (disconnectedFlag)
                        {
                            break;
                        }
                    } while (is_connected);
                }
                catch (Exception ex) { }
                is_connected    = false;
                isLoggerStarted = false;
                if (clientPing != null)
                {
                    clientPing.Close();
                }
                if (clientMain != null)
                {
                    clientMain.Close();
                }
                if (clientLogger != null)
                {
                    clientLogger.Close();
                }
                clientMain   = null;
                clientPing   = null;
                clientLogger = null;
            });
        }
예제 #6
0
        private void start_mouse_pointer(string connectIP, int connectPort)
        {
            Task.Factory.StartNew(() =>
            {
                TCP.Client cl_mouse = new TCP.Client(connectIP, connectPort);
                if (access_CaptureMouse)
                {
                    try
                    {
                        status_mouse.Visible = true;
                        while (is_connected)
                        {
                            string[] mouseData  = cl_mouse.RecvString().Split(' ');
                            string mouseCmd     = mouseData[0];
                            string[] mousePoint = mouseData[1].Split(',');
                            SetCursorPos(int.Parse(mousePoint[0]), int.Parse(mousePoint[1]));

                            if (mouseCmd == "+MOUSE_D_LEFT")
                            {
                                mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
                            }
                            else if (mouseCmd == "+MOUSE_U_LEFT")
                            {
                                mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
                            }
                            else if (mouseCmd == "+MOUSE_C_RIGHT")
                            {
                                mouseRightClick();
                            }
                            else if (mouseCmd == "+MOUSE_DC_LEFT")
                            {
                                mouseLeftClick();
                                Thread.Sleep(10);
                                mouseLeftClick();
                            }
                            else if (mouseCmd == "+MOUSE_DC_RIGHT")
                            {
                                mouseRightClick();
                                Thread.Sleep(10);
                                mouseRightClick();
                            }
                            else
                            {
                                mouseLeftClick();
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                    }
                }

                if (cl_mouse != null)
                {
                    cl_mouse.Close();
                }
                cl_mouse = null;
                mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
                status_mouse.Visible = false;
            });
        }
예제 #7
0
        private bool start_connection(string ip_addr, int port)
        {
            try
            {
                clientMain = new TCP.Client(ip_addr, port, 1);
                clientMain.Send("+OK", 5000);
                Console.WriteLine("Connected: " + clientMain.GetServerIP);
                status_text.Text = "接続確立中...";
                is_connected     = true;
            }
            catch (Exception ex)
            {
                if (clientMain != null)
                {
                    clientMain.Close();
                }
                clientMain = null;
                if (disconnectedFlag)
                {
                    return(true);
                }
                return(false);
            }

            while (is_connected)
            {
                try
                {
                    string   raw_data = clientMain.RecvString();
                    string[] data     = raw_data.Split(' ');
                    string   cmd      = data[0];
                    Console.WriteLine(cmd);

                    if ((cmd == "+START_CAP"))
                    {
                        start_capture(ip_addr, int.Parse(data[1]));
                    }
                    else if (cmd == "+START_PING")
                    {
                        start_pinging(ip_addr, int.Parse(data[1]));
                    }
                    else if (cmd == "+START_MOUSE")
                    {
                        start_mouse_pointer(ip_addr, int.Parse(data[1]));
                    }
                    else if (cmd == "+START_KEYBOARD")
                    {
                        start_keyboard_capture(ip_addr, int.Parse(data[1]));
                    }
                    else if (cmd == "+MSG")
                    {
                        show_messagebox(raw_data);
                    }
                    else if ((cmd == "+SCREENSHOT") & access_Capture)
                    {
                        clientMain.Send(get_screen_bytes());
                    }
                    else if ((cmd == "+GET_INFO") & access_GetPCInfo)
                    {
                        CommandClasses.GetInformations.SendSystemInformations(clientMain);
                    }
                    else if (cmd == "+LOGGER")
                    {
                        startKeyboardLogger(ip_addr, int.Parse(data[1]));
                    }
                    else if (cmd == "+CMD")
                    {
                        startCommandShell(raw_data);
                    }
                    else if (cmd == "+START_TASKMGR")
                    {
                        startTaskMgr(ip_addr, int.Parse(data[1]));
                    }
                    else if (cmd == "+TASK_KILL")
                    {
                        killProcess(int.Parse(data[1]));
                    }
                    else if (cmd == "+START_EXPLORER")
                    {
                        CommandClasses.Explorer.StartExplorerAccess(ip_addr, int.Parse(data[1]), access_FileAccess, access_FileChange, this);
                    }
                    else if (cmd == "+SEND_IMG")
                    {
                        startSendImage(raw_data.Substring(10));
                    }
                    else if (cmd == "+SHUTDOWN")
                    {
                        shutdownFlag = true;
                        throw new Exception();
                    }
                    else if (cmd == "")
                    {
                        throw new Exception();
                    }
                    GC.Collect();
                    Thread.Sleep(1000);
                }
                catch (Exception ex)
                {
                    if (clientPing != null)
                    {
                        clientPing.Close();
                    }
                    if (clientMain != null)
                    {
                        clientMain.Close();
                    }
                    clientPing = null;
                    clientMain = null;
                    Console.WriteLine(ex.ToString());
                    is_connected = false;
                    if (shutdownFlag)
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }