Package com.lixia.rdp.Package

Examples of com.lixia.rdp.Package.RdpPackage


//        logger.debug("control");
        this.sendData(data, RDP_DATA_PDU_CONTROL);
    }

    public void sendInput(int time, int message_type, int device_flags, int param1, int param2) {
        RdpPackage data = null;
        try {
            data = this.initData(16);
        } catch (RdesktopException e) {
        }

        data.setLittleEndian16(1); /* number of events */

        data.setLittleEndian16(0); /* pad */

        data.setLittleEndian32(time);
        data.setLittleEndian16(message_type);
        data.setLittleEndian16(device_flags);
        data.setLittleEndian16(param1);
        data.setLittleEndian16(param2);
        data.markEnd();
        // logger.info("input");
        // if(logger.isInfoEnabled()) logger.info(data);
        try {
            this.sendData(data, RDP_DATA_PDU_INPUT);
        } catch (RdesktopException r) {
View Full Code Here


            RDPConnection.conf.exit();
        }
    }

    private void sendFonts(int seq) throws RdesktopException, IOException, CryptoException {
        RdpPackage data = this.initData(8);
        data.setLittleEndian16(0); /* number of fonts */

        data.setLittleEndian16(0x3e); /* unknown */

        data.setLittleEndian16(seq); /* unknown */

        data.setLittleEndian16(0x32); /* entry size */

        data.markEnd();
//        logger.debug("fonts");
        this.sendData(data, RDP_DATA_PDU_FONT2);
    }
View Full Code Here

     * @throws CryptoException
     */
    public void send_authresp(byte[] token, byte[] crypt_hwid, byte[] signature) throws RdesktopException, IOException, CryptoException {
        int sec_flags = Secure.SEC_LICENCE_NEG;
        int length = 58;
        RdpPackage data;

        data = secure.init(sec_flags, length + 2);

        data.set8(LICENCE_TAG_AUTHRESP);
        data.set8(2); // version
        data.setLittleEndian16(length);

        data.setLittleEndian16(1);
        data.setLittleEndian16(LICENCE_TOKEN_SIZE);
        data.copyFromByteArray(token, 0, data.getPosition(), LICENCE_TOKEN_SIZE);
        data.incrementPosition(LICENCE_TOKEN_SIZE);

        data.setLittleEndian16(1);
        data.setLittleEndian16(LICENCE_HWID_SIZE);
        data.copyFromByteArray(crypt_hwid, 0, data.getPosition(), LICENCE_HWID_SIZE);
        data.incrementPosition(LICENCE_HWID_SIZE);

        data.copyFromByteArray(signature, 0, data.getPosition(), LICENCE_SIGNATURE_SIZE);
        data.incrementPosition(LICENCE_SIGNATURE_SIZE);
        data.markEnd();
        secure.send(data, sec_flags);
    }
View Full Code Here

     */
    public void present(byte[] client_random, byte[] rsa_data, byte[] licence_data, int licence_size, byte[] hwid, byte[] signature) throws RdesktopException, IOException, CryptoException {
        int sec_flags = Secure.SEC_LICENCE_NEG;
        int length = /* rdesktop is 16 not 20, but this must be wrong?! */ 20 + Secure.SEC_RANDOM_SIZE + Secure.SEC_MODULUS_SIZE + Secure.SEC_PADDING_SIZE + licence_size + LICENCE_HWID_SIZE + LICENCE_SIGNATURE_SIZE;

        RdpPackage s = secure.init(sec_flags, length + 4);

        s.set8(LICENCE_TAG_PRESENT);
        s.set8(2); // version
        s.setLittleEndian16(length);

        s.setLittleEndian32(1);
        s.setLittleEndian16(0);
        s.setLittleEndian16(0x0201);

        s.copyFromByteArray(client_random, 0, s.getPosition(), Secure.SEC_RANDOM_SIZE);
        s.incrementPosition(Secure.SEC_RANDOM_SIZE);
        s.setLittleEndian16(0);
        s.setLittleEndian16((Secure.SEC_MODULUS_SIZE + Secure.SEC_PADDING_SIZE));
        s.copyFromByteArray(rsa_data, 0, s.getPosition(), Secure.SEC_MODULUS_SIZE);
        s.incrementPosition(Secure.SEC_MODULUS_SIZE);
        s.incrementPosition(Secure.SEC_PADDING_SIZE);

        s.setLittleEndian16(1);
        s.setLittleEndian16(licence_size);
        s.copyFromByteArray(licence_data, 0, s.getPosition(), licence_size);
        s.incrementPosition(licence_size);

        s.setLittleEndian16(1);
        s.setLittleEndian16(LICENCE_HWID_SIZE);
        s.copyFromByteArray(hwid, 0, s.getPosition(), LICENCE_HWID_SIZE);
        s.incrementPosition(LICENCE_HWID_SIZE);
        s.copyFromByteArray(signature, 0, s.getPosition(), LICENCE_SIGNATURE_SIZE);
        s.incrementPosition(LICENCE_SIGNATURE_SIZE);

        s.markEnd();
        secure.send(s, sec_flags);
    }
View Full Code Here

     *
     * @param length Desired length of PDU
     * @return Packet configured as ISO PDU, ready to write at higher level
     */
    public RdpPackage init(int length) {
        RdpPackage data = new RdpPackage(length + 7);//getMemory(length+7);
        data.incrementPosition(7);
        data.setStart(data.getPosition());
        return data;
    }
View Full Code Here

     *
     * @param type one of the following CONNECT_RESPONSE, DISCONNECT_REQUEST
     * @exception IOException when an I/O Error occurs
     */
    private void sendMessage(int type) throws IOException {
        RdpPackage buffer = new RdpPackage(11);//getMemory(11);
        byte[] packet = new byte[11];

        buffer.set8(PROTOCOL_VERSION); // send Version Info
        buffer.set8(0); // reserved byte
        buffer.setBigEndian16(11); // Length
        buffer.set8(6); // Length of Header

        buffer.set8(type); //where code = CR or DR
        buffer.setBigEndian16(0); // Destination reference ( 0 at CC and DR)

        buffer.setBigEndian16(0); // source reference should be a reasonable address we use 0
        buffer.set8(0); //service class
        buffer.copyToByteArray(packet, 0, 0, packet.length);
        out.write(packet);
        out.flush();
    }
View Full Code Here

     * @throws OrderException
     * @throws CryptoException
     */
    public RdpPackage receive() throws IOException, RdesktopException, OrderException, CryptoException {
        int[] type = new int[1];
        RdpPackage buffer = receiveMessage(type);
        if (buffer == null) {
            return null;
        }
        if (type[0] != DATA_TRANSFER) {
            throw new RdesktopException("Expected DT got:" + type[0]);
View Full Code Here

     * @return Packet containing read data, appended to original data if
     * provided
     * @throws IOException
     */
    private RdpPackage tcp_recv(RdpPackage p, int length) throws IOException {
        RdpPackage buffer;
        byte[] packet = new byte[length];
        in.readFully(packet, 0, length);
        // try{ }
        // catch(IOException e){ logger.warn("IOException: " + e.getMessage()); return null;  }
        if (RDPConnection.conf.debug_hexdump) {
            dump.encode(packet, "RECEIVE" /*System.out*/);
        }
        if (p == null) {
            buffer = new RdpPackage(length);
            buffer.copyFromByteArray(packet, 0, 0, packet.length);
            buffer.markEnd(length);
            buffer.setStart(buffer.getPosition());
        } else {
            buffer = new RdpPackage((p.getEnd() - p.getStart())
                    + length);
            buffer.copyFromPacket(p, p.getStart(), 0, p.getEnd());
            buffer.copyFromByteArray(packet, 0, p.getEnd(), packet.length);
            buffer.markEnd(p.size() + packet.length);
            buffer.setPosition(p.getPosition());
            buffer.setStart(0);
        }
        return buffer;
    }
View Full Code Here

     * @throws RdesktopException
     * @throws OrderException
     * @throws CryptoException
     */
    private RdpPackage receiveMessage(int[] type) throws IOException, RdesktopException, OrderException, CryptoException {
        RdpPackage s = null;
        int length, version;

        next_packet:
        while (true) {
            s = tcp_recv(null, 4);
            if (s == null) {
                return null;
            }
            version = s.get8();
            if (version == 3) {
                s.incrementPosition(1); // pad
                length = s.getBigEndian16();
            } else {
                length = s.get8();
                if ((length & 0x80) != 0) {
                    length &= ~0x80;
                    length = (length << 8) + s.get8();
                }
            }
            s = tcp_recv(s, length - 4);
            if (s == null) {
                return null;
            }
            if ((version & 3) == 0) {
                RDPConnection.conf.rdp.rdp5_process(s, (version & 0x80) != 0);
                continue next_packet;
            } else {
                break;
            }
        }
        s.get8();
        type[0] = s.get8();

        if (type[0] == DATA_TRANSFER) {
            s.incrementPosition(1); // eot
            return s;
        }

        s.incrementPosition(5); // dst_ref, src_ref, class
        return s;
    }
View Full Code Here

            uname = uname.substring(0, 9);
        }
        int length = 11 + (RDPConnection.conf.username.length() > 0 ? ("Cookie: mstshash="
                .length()
                + uname.length() + 2) : 0) + 8;
        RdpPackage buffer = new RdpPackage(length);
        byte[] packet = new byte[length];

        buffer.set8(PROTOCOL_VERSION); // send Version Info
        buffer.set8(0); // reserved byte
        buffer.setBigEndian16(length); // Length
        buffer.set8(length - 5); // Length of Header   
        buffer.set8(CONNECTION_REQUEST);
        buffer.setBigEndian16(0); // Destination reference ( 0 at CC and DR)
        buffer.setBigEndian16(0); // source reference should be a reasonable address we use 0
        buffer.set8(0); //service class
        if (RDPConnection.conf.username.length() > 0) {
//            logger.debug("Including username");
            buffer
                    .out_uint8p("Cookie: mstshash=", "Cookie: mstshash="
                            .length());
            buffer.out_uint8p(uname, uname.length());

            buffer.set8(0x0d); // unknown
            buffer.set8(0x0a); // unknown
        }
        /*
         // Authentication request?
         buffer.setLittleEndian16(0x01);
         buffer.setLittleEndian16(0x08);
         // Do we try to use SSL?
         buffer.set8(RDPConnection.conf.use_ssl? 0x01 : 0x00);
         buffer.incrementPosition(3);
         */
        buffer.copyToByteArray(packet, 0, 0, packet.length);
        out.write(packet);
        out.flush();
    }
View Full Code Here

TOP

Related Classes of com.lixia.rdp.Package.RdpPackage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.