コード例 #1
0
ファイル: ADHDTech.CiscoSCP.cs プロジェクト: adhdtech/uctools
        public LiveHostClient(string sHostName, string sRemoteSupportUser, string sRemoteSupportPassphrase)
        {
            RemoteSupportPassphrase oReportSupportPassphrase = new RemoteSupportPassphrase();
            String sUserPassword = oReportSupportPassphrase.Decode(sRemoteSupportPassphrase);

            Renci.SshNet.AuthenticationMethod authMethod = new Renci.SshNet.PasswordAuthenticationMethod(sRemoteSupportUser, sUserPassword);
            scpConnInfo = new Renci.SshNet.ConnectionInfo(sHostName, sRemoteSupportUser, new[] { authMethod });
            scpClient   = new Renci.SshNet.ScpClient(scpConnInfo);

            MemoryStream xmlStream = new MemoryStream();

            scpClient.Connect();
            System.Threading.Thread.Sleep(3000);
            try
            {
                scpClient.Download(@"/usr/local/platform/conf/platformConfig.xml", xmlStream);
            } catch (Exception ex) {
                string bob = ex.Message;
            }

            scpClient.Disconnect();

            byte[] xmlDataBytes = new byte[xmlStream.Length];
            xmlStream.Seek(0, SeekOrigin.Begin);
            xmlStream.Read(xmlDataBytes, 0, (int)xmlStream.Length);

            Console.Write("{0}\n", Functions.encoding.GetString(xmlDataBytes));
        }
コード例 #2
0
ファイル: ADHDTech.CiscoSCP.cs プロジェクト: adhdtech/uctools
        public Client(string sHostName, string sRemoteSupportUser, string sRemoteSupportPassphrase)
        {
            RemoteSupportPassphrase oReportSupportPassphrase = new RemoteSupportPassphrase();
            String sUserPassword = oReportSupportPassphrase.Decode(sRemoteSupportPassphrase);

            Renci.SshNet.AuthenticationMethod authMethod = new Renci.SshNet.PasswordAuthenticationMethod(sRemoteSupportUser, sUserPassword);
            scpConnInfo = new Renci.SshNet.ConnectionInfo(sHostName, sRemoteSupportUser, new[] { authMethod });
            scpClient   = new Renci.SshNet.ScpClient(scpConnInfo);
        }
コード例 #3
0
ファイル: frmMain.cs プロジェクト: adhdtech/uctools
        private void FormSelectUCOSHost_Closed(object sender, EventArgs e)
        {
            if (myUCSHostCfg.sUCOSHost.Length > 0 && myUCSHostCfg.sUCOSRemoteUser.Length > 0 && myUCSHostCfg.sUCOSPassphrase.Length > 0)
            {

                // Decode passphrase to password
                RemoteSupportPassphrase oReportSupportPassphrase = new RemoteSupportPassphrase();
                String sUserPassword = oReportSupportPassphrase.Decode(myUCSHostCfg.sUCOSPassphrase);
                if (!oReportSupportPassphrase.Successful)
                {
                    // Could not decode passphrase; abort
                    MessageBox.Show("Could not decode passphrase: [" + myUCSHostCfg.sUCOSPassphrase + "]");
                    return;
                };

                // Let's try to open the security files
                UCOSClientSSH testClient = new UCOSClientSSH(myUCSHostCfg.sUCOSHost, myUCSHostCfg.sUCOSRemoteUser, sUserPassword);

                /*
                try
                {
                    testClient.Validate();
                }
                catch (Exception ex) {
                    MessageBox.Show(ex.Message);
                    return;
                }
                */

                try
                {
                    Dictionary<string, byte[]> filePack = testClient.GetSecurityFilePack();

                    // Set the directory, file and display tags
                    DRSD.sBackupSetDirectory = @"/usr/local/platform/conf";
                    DRSD.sBackupSetXMLFilename = "platformConfig.xml";
                    DRSD.sDisplayFilePath = myUCSHostCfg.sUCOSHost + ":" + DRSD.sBackupSetDirectory + "/" + DRSD.sBackupSetXMLFilename;
                    byte[] bPlatformConfig = filePack[DRSD.sBackupSetDirectory + "/" + DRSD.sBackupSetXMLFilename];
                    byte[] bDKey = new byte[0];
                    if (filePack.ContainsKey(@"/usr/local/platform/.security/CCMEncryption/keys/dkey.txt")) {
                        bDKey = filePack[@"/usr/local/platform/.security/CCMEncryption/keys/dkey.txt"];
                    }
                    ADHDTech.CiscoCrypt.platformConfigXML.PlatformData oPlatformConfig = ADHDTech.CiscoCrypt.Functions.LoadPlatformConfigBytes(bPlatformConfig);
                    DisplayPlatformConfig(oPlatformConfig, Functions.encoding.GetString(bDKey));
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }