Esempio n. 1
0
        private static Packet CreateServiceRequestMessage(SequencePool sequencePool)
        {
            using var packet = sequencePool.RentPacket();
            var writer = packet.GetWriter();

            writer.WriteByte(MessageNumber.SSH_MSG_SERVICE_REQUEST);
            writer.WriteString("ssh-userauth");
            return(packet.Move());
        }
Esempio n. 2
0
        private static Packet CreatePasswordRequestMessage(SequencePool sequencePool, string userName, string password)
        {
            using var packet = sequencePool.RentPacket();
            var writer = packet.GetWriter();

            writer.WriteByte(MessageNumber.SSH_MSG_USERAUTH_REQUEST);
            writer.WriteString(userName);
            writer.WriteString("ssh-connection");
            writer.WriteString("password");
            writer.WriteBoolean(false);
            writer.WriteString(password);
            return(packet.Move());
        }
Esempio n. 3
0
        private static Packet CreatePublicKeyRequestMessage(SequencePool sequencePool, string userName, byte[] sessionId, PrivateKey privateKey)
        {
            /*
             *  byte      SSH_MSG_USERAUTH_REQUEST
             *  string    user name
             *  string    service name
             *  string    "publickey"
             *  boolean   TRUE
             *  string    public key algorithm name
             *  string    public key to be used for authentication
             *  string    signature
             */
            using var packet = sequencePool.RentPacket();
            var writer = packet.GetWriter();

            writer.WriteByte(MessageNumber.SSH_MSG_USERAUTH_REQUEST);
            writer.WriteString(userName);
            writer.WriteString("ssh-connection");
            writer.WriteString("publickey");
            writer.WriteBoolean(true);
            writer.WriteString(privateKey.Format);
            privateKey.AppendPublicKey(ref writer);
            {
                /*
                 *  string    session identifier
                 *  byte      SSH_MSG_USERAUTH_REQUEST
                 *  string    user name
                 *  string    service name
                 *  string    "publickey"
                 *  boolean   TRUE
                 *  string    public key algorithm name
                 *  string    public key to be used for authentication
                 */
                using var signatureData = sequencePool.RentSequence();
                var signatureWriter = new SequenceWriter(signatureData);
                signatureWriter.WriteString(sessionId);
                signatureWriter.WriteByte(MessageNumber.SSH_MSG_USERAUTH_REQUEST);
                signatureWriter.WriteString(userName);
                signatureWriter.WriteString("ssh-connection");
                signatureWriter.WriteString("publickey");
                signatureWriter.WriteBoolean(true);
                signatureWriter.WriteString(privateKey.Format);
                privateKey.AppendPublicKey(ref signatureWriter);
                privateKey.AppendSignature(ref writer, signatureData.AsReadOnlySequence());
            }

            return(packet.Move());
        }
Esempio n. 4
0
 private Packet RentPacket()
 => _sequencePool.RentPacket();