Esempio n. 1
0
 protected SSHChannel(SSHConnection con, ChannelType type, int local_id)
 {
     con.RegisterChannel(local_id, this);
     _connection = con;
     _type = type;
     _localID = local_id;
 }
Esempio n. 2
0
 public SSH2Channel(SSHConnection con, ChannelType type, int local_id, int remote_id, int maxpacketsize)
     : base(con, type, local_id)
 {
     _windowSize = _leftWindowSize = con.Param.WindowSize;
     Debug.Assert(type==ChannelType.ForwardedRemoteToLocal);
     _remoteID = remote_id;
     _serverMaxPacketSize = maxpacketsize;
     _negotiationStatus = 0;
 }
Esempio n. 3
0
        /**
         * opens another SSH connection via port-forwarded connection
         */
        public SSHConnection OpenPortForwardedAnotherConnection(SSHConnectionParameter param, ISSHConnectionEventReceiver receiver, string host, int port)
        {
            ProtocolNegotiationHandler pnh = new ProtocolNegotiationHandler(param);
            ChannelSocket s = new ChannelSocket(pnh);

            SSHChannel ch = ForwardPort(s, host, port, "localhost", 0);

            s.SSHChennal = ch;
            return(SSHConnection.Connect(param, receiver, pnh, s));
        }
Esempio n. 4
0
        //�I���̃n���h�����O �񓯊��ɕʃX���b�h����Ă΂��̂Œ���
        public void ConnectionClosed(SSHConnection connection)
        {
            IDictionaryEnumerator e = _profileToConnection.GetEnumerator();
            while(e.MoveNext()) {
                if(connection==e.Value) {
                    ChannelProfile prof = (ChannelProfile)e.Key;
                    _profileToConnection.Remove(e.Key);
                    bool manual = false;
                    lock(this) {
                        manual = _manualClosingConnections.Contains(connection);
                        if(manual) _manualClosingConnections.Remove(connection);
                    }

                    if(!manual) {
                        Util.InterThreadWarning(Env.Strings.GetString("Message.ConnectionManager.Disconnected"));
                    }
                    Env.MainForm.RefreshProfileStatus(prof); //!!�ق�Ƃ͂�����InterThread

                    break;
                }
            }
        }
Esempio n. 5
0
 public SSH2Channel(SSHConnection con, ChannelType type, int local_id)
     : base(con, type, local_id)
 {
     _windowSize = _leftWindowSize = con.Param.WindowSize;
     _negotiationStatus = type==ChannelType.Shell? 3 : type==ChannelType.ForwardedLocalToRemote? 1 : type==ChannelType.Session? 1 : 0;
 }
Esempio n. 6
0
 public void FixConnection(SSHConnection con)
 {
     _connection = con;
 }
Esempio n. 7
0
 public SynchronizedSSHChannel(SSHChannel ch)
 {
     _channel = ch;
     _connection = _channel.Connection;
     _closed = false;
 }
Esempio n. 8
0
 public void FixConnection(SSHConnection con)
 {
     _connection = con;
     Env.Log.LogConnectionOpened(this.ChannelProfile, _id);
 }
Esempio n. 9
0
        public void ConnectionError(SSHConnection connection, Exception error, string msg)
        {
            if(msg==null && error!=null) msg = error.Message;

            Util.InterThreadWarning(msg);
            ConnectionClosed(connection);
        }
Esempio n. 10
0
        static void Main(string[] args)
        {
            /*
            string cn = System.Threading.Thread.CurrentThread.CurrentUICulture.Name;
            string t1 = Granados.SSHC.Strings.GetString("NotSSHServer");
            System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("ja");
            Granados.SSHC.Strings.Reload();
            string t2 = Granados.SSHC.Strings.GetString("NotSSHServer");
            */

            #if false //RSA keygen
            //RSA KEY GENERATION TEST
            byte[] testdata = Encoding.ASCII.GetBytes("CHRISTIAN VIERI");
            RSAKeyPair kp = RSAKeyPair.GenerateNew(2048, new Random());
            byte[] sig = kp.Sign(testdata);
            kp.Verify(sig, testdata);

            new SSH2UserAuthKey(kp).WritePublicPartInOpenSSHStyle(new FileStream("C:\\IOPort\\newrsakey", FileMode.Create));
            //SSH2UserAuthKey newpk = SSH2PrivateKey.FromSECSHStyleFile("C:\\IOPort\\newrsakey", "nedved");
            #endif

            #if false //DSA keygen
            //DSA KEY GENERATION TEST
            byte[] testdata = Encoding.ASCII.GetBytes("CHRISTIAN VIERI 0000");
            DSAKeyPair kp = DSAKeyPair.GenerateNew(2048, new Random());
            byte[] sig = kp.Sign(testdata);
            kp.Verify(sig, testdata);
            new SSH2UserAuthKey(kp).WritePublicPartInOpenSSHStyle(new FileStream("C:\\IOPort\\newdsakey", FileMode.Create));
            //SSH2PrivateKey newpk = SSH2PrivateKey.FromSECSHStyleFile("C:\\IOPort\\newdsakey", "nedved");
            #endif

            SSHConnectionParameter f = new SSHConnectionParameter();
            f.UserName = "******";
            #if false //SSH1
            //SSH1
            f.Password = "";
            f.Protocol = SSHProtocol.SSH2;
            f.AuthenticationType = AuthenticationType.Password;
            f.PreferableCipherAlgorithms = new CipherAlgorithm[] { CipherAlgorithm.Blowfish, CipherAlgorithm.TripleDES };
            #else //SSH2
            f.Password = "";
            f.Protocol = SSHProtocol.SSH2;
            f.AuthenticationType = AuthenticationType.Password;
            f.WindowSize = 0x1000;
            #endif
            Reader reader = new Reader();
            Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            //s.Blocking = false;
            s.Connect(new IPEndPoint(IPAddress.Parse("192.168.1.1"), 22));
            _conn = SSHConnection.Connect(f, reader, s);
            reader._conn = _conn;
            #if false //Remote->Local
            _conn.ListenForwardedPort("0.0.0.0", 29472);
            #elif false //Local->Remote
            SSHChannel ch = _conn.ForwardPort(reader, "www.yahoo.co.jp", 80, "localhost", 0);
            reader._pf = ch;
            while(!reader._ready) System.Threading.Thread.Sleep(100);
            reader._pf.Transmit(Encoding.ASCII.GetBytes("GET / HTTP/1.0\r\n\r\n"));
            #elif false //SSH over SSH
            f.Password = "******";
            SSHConnection con2 = _conn.OpenPortForwardedAnotherConnection(f, reader, "kuromatsu", 22);
            reader._conn = con2;
            SSHChannel ch = con2.OpenShell(reader);
            reader._pf = ch;
            #else //normal shell
            SSHChannel ch = _conn.OpenShell(reader);
            reader._pf = ch;
            #endif

            //Debug.WriteLine(_conn.ConnectionInfo.DumpHostKeyInKnownHostsStyle());
            SSHConnectionInfo ci = _conn.ConnectionInfo;

            Thread.Sleep(1000);
            //((SSH2Connection)_conn).ReexchangeKeys();

            byte[] b = new byte[1];
            while(true) {
                int input = System.Console.Read();

                b[0] = (byte)input;
                //Debug.WriteLine(input);
                reader._pf.Transmit(b);
            }
        }
Esempio n. 11
0
 public SSH1Channel(SSHConnection con, ChannelType type, int local_id, int remote_id)
     : base(con, type, local_id)
 {
     _remoteID = remote_id;
 }
Esempio n. 12
0
 public SSH1Channel(SSHConnection con, ChannelType type, int local_id)
     : base(con, type, local_id)
 {
 }