Ejemplo n.º 1
0
        public override void SendIgnorableData(string msg)
        {
            SSH1DataWriter w = new SSH1DataWriter();

            w.WriteString(msg);
            SSH1Packet p = SSH1Packet.FromPlainPayload(PacketType.SSH_MSG_IGNORE, w.ToByteArray());

            Transmit(p);
        }
Ejemplo n.º 2
0
        private void SendPlainPassword()
        {
            SSH1DataWriter writer = new SSH1DataWriter();

            writer.WriteString(_param.Password);
            SSH1Packet SSH1Packet = SSH1Packet.FromPlainPayload(PacketType.SSH_CMSG_AUTH_PASSWORD, writer.ToByteArray());

            SSH1Packet.WriteTo(_stream, _tCipher);
            TraceTransmissionEvent(PacketType.SSH_CMSG_AUTH_PASSWORD, "sent password");
        }
Ejemplo n.º 3
0
        private void SendUserName(string username)
        {
            SSH1DataWriter writer = new SSH1DataWriter();

            writer.WriteString(username);
            SSH1Packet SSH1Packet = SSH1Packet.FromPlainPayload(PacketType.SSH_CMSG_USER, writer.ToByteArray());

            SSH1Packet.WriteTo(_stream, _tCipher);
            TraceTransmissionEvent(PacketType.SSH_CMSG_USER, "sent user name");
        }
Ejemplo n.º 4
0
        private void SendExecCommand()
        {
            Debug.WriteLine("EXEC COMMAND");
            string         cmd    = _execCmd;
            SSH1DataWriter writer = new SSH1DataWriter();

            writer.WriteString(cmd);
            SSH1Packet SSH1Packet = SSH1Packet.FromPlainPayload(PacketType.SSH_CMSG_EXEC_CMD, writer.ToByteArray());

            SSH1Packet.WriteTo(_stream, _tCipher);
            TraceTransmissionEvent(PacketType.SSH_CMSG_EXEC_CMD, "exec command: cmd={0}", cmd);
        }
Ejemplo n.º 5
0
        public override void Disconnect(string msg)
        {
            if (!this.IsOpen)
            {
                return;
            }
            SSH1DataWriter w = new SSH1DataWriter();

            w.WriteString(msg);
            SSH1Packet p = SSH1Packet.FromPlainPayload(PacketType.SSH_MSG_DISCONNECT, w.ToByteArray());

            p.WriteTo(_stream, _tCipher);
            base.Close();
        }
Ejemplo n.º 6
0
        private void SendRequestPTY()
        {
            SSH1DataWriter writer = new SSH1DataWriter();

            writer.WriteString(_param.TerminalName);
            writer.WriteInt32(_param.TerminalHeight);
            writer.WriteInt32(_param.TerminalWidth);
            writer.WriteInt32(_param.TerminalPixelWidth);
            writer.WriteInt32(_param.TerminalPixelHeight);
            writer.Write(new byte[1]); //TTY_OP_END
            SSH1Packet SSH1Packet = SSH1Packet.FromPlainPayload(PacketType.SSH_CMSG_REQUEST_PTY, writer.ToByteArray());

            SSH1Packet.WriteTo(_stream, _tCipher);
            TraceTransmissionEvent(PacketType.SSH_CMSG_REQUEST_PTY, "open shell: terminal={0} width={1} height={2}", _param.TerminalName, _param.TerminalWidth, _param.TerminalHeight);
        }
Ejemplo n.º 7
0
        public override void ListenForwardedPort(string allowed_host, int bind_port)
        {
            SSH1DataWriter writer = new SSH1DataWriter();

            writer.WriteInt32(bind_port);
            writer.WriteString(allowed_host);
            writer.WriteInt32(0);
            SSH1Packet p = SSH1Packet.FromPlainPayload(PacketType.SSH_CMSG_PORT_FORWARD_REQUEST, writer.ToByteArray());

            p.WriteTo(_stream, _tCipher);
            TraceTransmissionEvent(PacketType.SSH_CMSG_PORT_FORWARD_REQUEST, "start to listening to remote port: host={0} port={1}", allowed_host, bind_port);

            if (_shellID == -1)
            {
                ExecShell();
                _shellID = _channel_collection.RegisterChannelEventReceiver(null, new SSH1DummyReceiver()).LocalID;
            }
        }
Ejemplo n.º 8
0
        public override SSHChannel ForwardPort(ISSHChannelEventReceiver receiver, string remote_host, int remote_port, string originator_host, int originator_port)
        {
            if (_shellID == -1)
            {
                ExecShell();
                _shellID = _channel_collection.RegisterChannelEventReceiver(null, new SSH1DummyReceiver()).LocalID;
            }

            int local_id = _channel_collection.RegisterChannelEventReceiver(null, receiver).LocalID;

            SSH1DataWriter writer = new SSH1DataWriter();

            writer.WriteInt32(local_id); //channel id is fixed to 0
            writer.WriteString(remote_host);
            writer.WriteInt32(remote_port);
            //originator is specified only if SSH_PROTOFLAG_HOST_IN_FWD_OPEN is specified
            //writer.Write(originator_host);
            SSH1Packet SSH1Packet = SSH1Packet.FromPlainPayload(PacketType.SSH_MSG_PORT_OPEN, writer.ToByteArray());

            SSH1Packet.WriteTo(_stream, _tCipher);
            TraceTransmissionEvent(PacketType.SSH_MSG_PORT_OPEN, "open forwarded port: host={0} port={1}", remote_host, remote_port);

            return(new SSH1Channel(this, ChannelType.ForwardedLocalToRemote, local_id));
        }