Beispiel #1
0
        public string getArgList()
        {
            string sRet = "";

            //-g
            sRet += " -g " + DesktopHeight.ToString() + "x" + DesktopWidth.ToString();

            if (HostName.Length > 0)
            {
                sRet += " -n " + HostName;
            }
            sRet += " -t " + MCSPort.ToString();
            sRet += " -u " + UserName;
            if (Password.Length > 0)
            {
                sRet += " -p " + DPAPI.Decrypt(Password);// _passwordClearText;
            }
            if (Domain.Length > 0)
            {
                sRet += " -d " + Domain;
            }
            if (AlternateShell.Length > 0)
            {
                sRet += " -s " + AlternateShell;
            }
            if (WorkingDir.Length > 0)
            {
                sRet += " -c " + WorkingDir;
            }

            if (usebarcodereader == 1)
            {
                sRet += " -b";
            }

            if (ScreenStyle == eScreenStyles.fullscreen_Fit ||
                ScreenStyle == eScreenStyles.fullscreen_NoFit)
            {
                sRet += " -f ";
            }

            sRet += " -a " + ColorDepthID.ToString();

            sRet += " " + ServerNameOrIP;

            return(sRet);
        }
Beispiel #2
0
        public string getRDPstring()
        {
            StringBuilder sb    = new StringBuilder();
            int           i     = 0;
            string        sLine = rdpLines[0];

            while (sLine != null)
            {
                if (sLine.StartsWith("WorkingDir"))
                {
                    sb.Append(String.Format(sLine, WorkingDir));
                }
                else if (sLine.StartsWith("AlternateShell"))
                {
                    sb.Append(String.Format(sLine, AlternateShell));
                }
                else if (sLine.StartsWith("EnableClipboardRedirection"))
                {
                    sb.Append(String.Format(sLine, EnableClipboardRedirection));
                }
                else if (sLine.StartsWith("Domain"))
                {
                    sb.Append(String.Format(sLine, Domain));
                }
                else if (sLine.StartsWith("MCSPort"))
                {
                    sb.Append(String.Format(sLine, MCSPort));
                }
                else if (sLine.StartsWith("Password"))
                {
                    if (DPAPI.Decrypt(Password).Length > 0)
                    {
                        #region TESTING
                        //string sPassEnc = rdp_password.EncryptRDPPassword(Password);
                        //here:         0200000000000000000000000000000000000000000000000800000072006400700000000E660000100000001000000031C03CFAF193C0C61AA5346F40DB08F800000000048000001000000010000000891E0B7D71DCAB69764E9CA05E25CEB6200000004EEEE6F38BD74AC8E4CC6C0661235AA1221B6BF14C191E27260FD7F99322E5C514000000F539F077730E2DBFDE6B368D9F45B67AAED4E4FF"
                        //rdp:          0200000000000000000000000000000000000000000000000800000072006400700000000E66000010000000100000001E392BB875946E7281F1D962E2CBA05900000000048000001000000010000000BEBDA63E164615F22450CEC59F37D46B200000003BC01FF8CF7EC256730228E21FA4434597E6FF98EBC66B4B1D96EA4E76F7C6AA14000000BCA27291CE4AD6B9B1C3BD3CE397D53647213EC4
                        //rdp_decrypt:  0200000000000000000000000000000000000000000000000800000072006400700000000E66000010000000100000001E392BB875946E7281F1D962E2CBA05900000000048000001000000010000000BEBDA63E164615F22450CEC59F37D46B200000003BC01FF8CF7EC256730228E21FA4434597E6FF98EBC66B4B1D96EA4E76F7C6AA14000000BCA27291CE4AD6B9B1C3BD3CE397D53647213EC4

                        ////using a DLL
                        //string sPassEnc = rdp_crypt.encrypt(Password);
                        //string sPassClear = rdp_crypt.decrypt(sPassEnc);
                        // gives        0200000000000000000000000000000000000000000000000800000072006400700000000e6600001000000010000000c7b7d85faf8e1ead57ad6698aef297ab00000000048000001000000010000000d78d3961ef6071a94af0732d75011c8720000000cff51a599a6e3794062c03e7459d0a97f4e29660e2183a63e1e2e7e9f304ae51140000002ef45194eea70f3133f05f8df7f5d1f5b5da267c
                        //rdp:          0200000000000000000000000000000000000000000000000800000072006400700000000E66000010000000100000001E392BB875946E7281F1D962E2CBA05900000000048000001000000010000000BEBDA63E164615F22450CEC59F37D46B200000003BC01FF8CF7EC256730228E21FA4434597E6FF98EBC66B4B1D96EA4E76F7C6AA14000000BCA27291CE4AD6B9B1C3BD3CE397D53647213EC4

                        //string sPassEnc = RDPcrypt.CryptTest.RDPencrypt(Password);
                        string _passwordClearText = DPAPI.Decrypt(Password);
                        string sEncrypted         = DPAPI.Encrypt(DPAPI.KeyType.UserKey, _passwordClearText, string.Empty, "psw");
                        //MachineKey: 0200000000000000000000000000000000000000040000000800000072006400700000000E6600001000000010000000ABD068CB6407C7B46789983CD8497ADF000000000480000010000000100000009D5510223ADAFF0D214797166ABF00E71000000044D9ABFDD92A841F09DF3461C67FD5231400000004CF33CE7C73F5D847851D8201D6028694F1FC51
                        //User   Key: 0200000000000000000000000000000000000000000000000800000072006400700000000E6600001000000010000000FB1308672F24BB2A3E2C9625977BC1CE00000000048000001000000010000000F60BBBB68E21ACE12D3A54C26BDC7686100000009963D2B109863E4345AD3F6C4BB1DA4314000000FC55E7196D64A5B8C90BA683CBC9775D95A86A97
                        //rdp    Key: 0200000000000000000000000000000000000000000000000800000072006400700000000E66000010000000100000001E392BB875946E7281F1D962E2CBA05900000000048000001000000010000000BEBDA63E164615F22450CEC59F37D46B200000003BC01FF8CF7EC256730228E21FA4434597E6FF98EBC66B4B1D96EA4E76F7C6AA14000000BCA27291CE4AD6B9B1C3BD3CE397D53647213EC4
                        //test
                        sEncrypted = DPAPI.EncryptRDP(_passwordClearText, "rdp");
                        System.Diagnostics.Debug.WriteLine("****rdp****\r\nNo KEY    : " + sEncrypted);
                        //sEncrypted = DPAPI.Encrypt(DPAPI.KeyType.UserKey, Password, null, "rdp");
                        //System.Diagnostics.Debug.WriteLine("User   Key: " + sEncrypted);

                        //sEncrypted = DPAPI.Encrypt(DPAPI.KeyType.MachineKey, Password, null, "psw");
                        //System.Diagnostics.Debug.WriteLine("****psw****\r\nMachineKey: " + sEncrypted);
                        //sEncrypted = DPAPI.Encrypt(DPAPI.KeyType.UserKey, Password, null, "psw");
                        //System.Diagnostics.Debug.WriteLine("User   Key: " + sEncrypted);
                        System.Diagnostics.Debug.WriteLine("rdp    Key: " + "0200000000000000000000000000000000000000000000000800000072006400700000000E66000010000000100000001E392BB875946E7281F1D962E2CBA05900000000048000001000000010000000BEBDA63E164615F22450CEC59F37D46B200000003BC01FF8CF7EC256730228E21FA4434597E6FF98EBC66B4B1D96EA4E76F7C6AA14000000BCA27291CE4AD6B9B1C3BD3CE397D53647213EC4");
                        //user key matches more!!!
                        #endregion
                        string description = "";
                        string sTest       = DPAPI.Decrypt(sEncrypted, string.Empty, out description);
                        if (sTest != _passwordClearText)
                        {
                            sEncrypted = "Error while encrypting password";
                        }
                        sb.Append(String.Format(sLine, Password));
                    }
                    else
                    {
                        sb.Append(String.Format(sLine, ""));
                    }
                }
                else if (sLine.StartsWith("HostName"))
                {
                    sb.Append(string.Format(sLine, HostName));
                }
                else if (sLine.StartsWith("ServerName"))
                {
                    sb.Append(string.Format(sLine, ServerNameOrIP));
                }
                else if (sLine.StartsWith("UserName"))
                {
                    sb.Append(string.Format(sLine, UserName));
                }
                else if (sLine.StartsWith("SavePassword"))
                {
                    sb.Append(string.Format(sLine, SavePassword));
                }
                else if (sLine.StartsWith("DesktopHeight"))
                {
                    sb.Append(string.Format(sLine, DesktopWidth.ToString()));
                }
                else if (sLine.StartsWith("DesktopWidth"))
                {
                    sb.Append(string.Format(sLine, DesktopHeight.ToString()));
                }
                else if (sLine.StartsWith("ScreenStyle"))
                {
                    sb.Append(string.Format(sLine, (int)ScreenStyle));
                    //if(ScreenStyle==1)
                    //    sb.Append(string.Format(sLine, "2"));
                    //else
                    //    sb.Append(string.Format(sLine, "0"));
                }
                else if (sLine.StartsWith("ColorDepthID"))
                {
                    sb.Append(string.Format(sLine, ColorDepthID.ToString()));
                }
                //else if (sLine.StartsWith("rdesktopce")){
                //    sb.Append(string.Format(sLine, rdesktopce));
                //}
                else
                {
                    sb.Append(String.Format(sLine, ""));
                }

                i++;
                sLine = rdpLines[i];
            }
            ;
            return(sb.ToString());
        }