Ejemplo n.º 1
0
 void LoadRemoteShell()
 {
     try
     {
         //RemoteShell
         bool isRemoteShellEnabled = false;
         bool.TryParse(GlobalConfiguration.GetValue("isRemoteShellEnabled", TrustedInstallerAuth, false.ToString()), out isRemoteShellEnabled);
         if (isRemoteShellEnabled)
         {
             var PubKey64 = GlobalConfiguration.GetValue("RemoteShellPublicKey", TrustedInstallerAuth, null);
             if (PubKey64 is not null)
             {
                 try
                 {
                     var PubKey = Convert.FromBase64String(PubKey64);
                     RSServer.SetPublicKey(PubKey, TrustedInstallerAuth);
                 }
                 catch (Exception)
                 {
                 }
             }
             var PriKey64 = GlobalConfiguration.GetValue("RemoteShellPrivateKey", TrustedInstallerAuth, null);
             if (PriKey64 is not null)
             {
                 try
                 {
                     var PriKey = Convert.FromBase64String(PubKey64);
                     RSServer.SetPublicKey(PriKey, TrustedInstallerAuth);
                 }
                 catch (Exception)
                 {
                 }
             }
             var ListenIP   = "127.0.0.1";
             var ListenPort = 22;
             ListenIP = GlobalConfiguration.GetValue("RemoteShellIP", TrustedInstallerAuth, ListenIP);
             if (!int.TryParse(GlobalConfiguration.GetValue("RemoteShellPort", TrustedInstallerAuth, "22"), out ListenPort))
             {
                 ListenPort = 22;
             }
             IPEndPoint iPEndPoint = new IPEndPoint(IPAddress.Parse(ListenIP), ListenPort);
             RSServer   rs         = new RSServer(iPEndPoint, 100);
             rs.Start();
         }
     }
     catch (Exception e)
     {
         Trace.WriteLine(e);
     }
 }