Examples of RdpPackage


Examples of com.lixia.rdp.Package.RdpPackage

        int[] type = new int[1];
        boolean disc = false; /* True when a disconnect PDU was received */

        boolean cont = true;

        RdpPackage data;

        while (cont) {
            try {
                data = this.receive(type);
                if (data == null) {
View Full Code Here

Examples of com.lixia.rdp.Package.RdpPackage

        packetlen = 8 + (5 * 4) + domainlen + userlen + passlen + commandlen + dirlen;
        if (RDPConnection.conf.use_rdp5 && 1 != RDPConnection.conf.server_rdp_version) {
            //rdp 5
            packetlen += 180 + (2 * 4) + len_ip + len_dll;
        }
        RdpPackage data = SecureLayer.init(sec_flags, packetlen);

        data.setLittleEndian32(0);/* codePage */

        data.setLittleEndian32(flags);/* flags */

        data.setLittleEndian16(domainlen);
        data.setLittleEndian16(userlen);
        data.setLittleEndian16(passlen);
        data.setLittleEndian16(commandlen);
        data.setLittleEndian16(dirlen);
        data.outUnicodeString(domain, domainlen);
        data.outUnicodeString(username, userlen);
        data.outUnicodeString(password, passlen);
        data.outUnicodeString(command, commandlen);
        data.outUnicodeString(directory, dirlen);

        if (RDPConnection.conf.use_rdp5 && 1 != RDPConnection.conf.server_rdp_version) {
//            logger.debug("Sending RDP5-style Logon packet");

            data.setLittleEndian16(CLIENT_INFO_AF_INET);
            data.setLittleEndian16(len_ip + 2);
            // // Length of client ip
            data.outUnicodeString("127.0.0.1", len_ip);
            data.setLittleEndian16(len_dll + 2);
            data.outUnicodeString("C:\\WINNT\\System32\\mstscax.dll", len_dll);

            /* clientTimeZone (172 bytes) */
            rdp_out_client_timezone_info(data);

            data.setLittleEndian32(2); // out_uint32_le(s, 2);
            data.setLittleEndian32(0); // out_uint32(s, 0);
//            data.setLittleEndian32(0xffffffc4); // out_uint32_le(s, 0xffffffc4);
//            data.setLittleEndian32(0xfffffffe); // out_uint32_le(s, 0xfffffffe);
            data.setLittleEndian32(RDPConnection.conf.rdp5_performanceflags); // out_uint32_le(s,
            // 0x0f);
            data.setLittleEndian32(0); // out_uint32(s, 0);
        }

        data.markEnd();
        byte[] buffer = new byte[data.getEnd()];
        data.copyToByteArray(buffer, 0, 0, data.getEnd());
        SecureLayer.send(data, sec_flags);
    }
View Full Code Here

Examples of com.lixia.rdp.Package.RdpPackage

        return size;
    }

    private int rdpdr_send_device_list_announce_request() {
        RdpPackage s;

        s = new RdpPackage(announcedata_size());
        s.setLittleEndian16(RDPDR_COMPONENT_TYPE_CORE);
        s.setLittleEndian16(PAKID_CORE_DEVICELIST_ANNOUNCE);
        s.setLittleEndian32(devices.size()); /* deviceCount */

        for (RdpdrDevice dev : devices) {
            s.setLittleEndian32(dev.type); /* deviceType */

            s.setLittleEndian32(devices.indexOf(dev) + 1); /* deviceID */
            /* preferredDosName, Max 8 characters, may not be null terminated */

            String name = dev.name.replace(" ", "_").substring(0, dev.name.length() > 8 ? 8 : dev.name.length());
            s.copyFromByteArray(name.getBytes(), 0, s.getPosition(), name.length());
            s.incrementPosition(8);

            s.setLittleEndian32(dev.deviceData.size());
            if (dev.deviceData.size() > 0) {
                s.copyFromPacket(dev.deviceData, 0, s.getPosition(), dev.deviceData.size());
                s.incrementPosition(dev.deviceData.size());
            }
        }
        s.markEnd();
        byte[] outputbyte = new byte[s.size()];
        s.copyToByteArray(outputbyte, 0, 0, s.size());
        try {
            this.send_packet(s);
        } catch (RdesktopException e) {
        } catch (CryptoException e) {
        } catch (IOException e) {
View Full Code Here

Examples of com.lixia.rdp.Package.RdpPackage

    }

    public void establishKey() throws RdesktopException, IOException, CryptoException {
        int length = server_public_key_len + SEC_PADDING_SIZE;
        int flags = SEC_CLIENT_RANDOM;
        RdpPackage buffer = this.init(flags, length + 4);

        buffer.setLittleEndian32(length);

        buffer.copyFromByteArray(this.sec_crypted_random, 0, buffer.getPosition(), server_public_key_len);
        buffer.incrementPosition(server_public_key_len);
        buffer.incrementPosition(SEC_PADDING_SIZE);
        buffer.markEnd();
        this.send(buffer, flags);

    }
View Full Code Here

Examples of com.lixia.rdp.Package.RdpPackage

        // Purpose
        // unknown

        int sec_flags = RDPConnection.conf.encryption ? (RDP5_FLAG | Secure.SEC_ENCRYPT) : RDP5_FLAG;

        RdpPackage data = SecureLayer.init(sec_flags, 6 + 14 + caplen + RDP_SOURCE.length);

        // RdpPackage data = this.init(14 + caplen +
        // RDP_SOURCE.length);
        data.setLittleEndian16(2 + 14 + caplen + RDP_SOURCE.length);
        data.setLittleEndian16((RDP_PDU_CONFIRM_ACTIVE | 0x10));
        data.setLittleEndian16(RDPConnection.conf.mcs.getUserID() /* McsUserID() */ + 1001);

        data.setLittleEndian32(this.rdp_shareid);
        data.setLittleEndian16(0x3ea); // user id
        data.setLittleEndian16(RDP_SOURCE.length);
        data.setLittleEndian16(caplen);

        data.copyFromByteArray(RDP_SOURCE, 0, data.getPosition(),
                RDP_SOURCE.length);
        data.incrementPosition(RDP_SOURCE.length);
        data.setLittleEndian16(0xd); // num_caps
        data.incrementPosition(2); // pad

        this.sendGeneralCaps(data);
        // ta.incrementPosition(this.RDP_CAPLEN_GENERAL);
        this.sendBitmapCaps(data);
        this.sendOrderCaps(data);

//        if (RDPConnection.conf.use_rdp5 && RDPConnection.conf.persistent_bitmap_caching) {
        if (RDPConnection.conf.use_rdp5) {
//            logger.info("Persistent caching enabled");
            this.sendBitmapcache2Caps(data);
        } else {
            this.sendBitmapcacheCaps(data);
        }

        this.sendColorcacheCaps(data);
        this.sendActivateCaps(data);
        this.sendControlCaps(data);
        this.sendPointerCaps(data);
        this.sendShareCaps(data);
        // this.sendUnknownCaps(data);

        this.sendUnknownCaps(data, 0x0d, 0x58, caps_0x0d); // rdp_out_unknown_caps(s,
        // 0x0d, 0x58,
        // caps_0x0d); /*
        // international? */
        this.sendUnknownCaps(data, 0x0c, 0x08, caps_0x0c); // rdp_out_unknown_caps(s,
        // 0x0c, 0x08,
        // caps_0x0c);
        this.sendUnknownCaps(data, 0x0e, 0x08, caps_0x0e); // rdp_out_unknown_caps(s,
        // 0x0e, 0x08,
        // caps_0x0e);
        this.sendUnknownCaps(data, 0x10, 0x34, caps_0x10); // rdp_out_unknown_caps(s,
        // 0x10, 0x34,
        // caps_0x10); /*
        // glyph cache? */

        data.markEnd();
//        logger.debug("confirm active");
        // this.send(data, RDP_PDU_CONFIRM_ACTIVE);
        RDPConnection.conf.secure.send(data, sec_flags);
    }
View Full Code Here

Examples of com.lixia.rdp.Package.RdpPackage

        int result = 0;
        rdpdr_send_completion(deviceid, id, status, result, buffer, buffer_len);
    }

    void rdpdr_send_completion(int device, int id, int status, int result, byte[] buffer, int length) {
        RdpPackage s;

        s = new RdpPackage(20 + length);
        s.setLittleEndian16(RDPDR_COMPONENT_TYPE_CORE);//PAKID_CORE_DEVICE_REPLY?
        s.setLittleEndian16(PAKID_CORE_DEVICE_IOCOMPLETION);
        s.setLittleEndian32(device);
        s.setLittleEndian32(id);
        s.setLittleEndian32(status);
        s.setLittleEndian32(result);
        if (length > 0) {
            s.copyFromByteArray(buffer, 0, s.getPosition(), length);
        }
        s.markEnd();
        try {
            this.send_packet(s);
        } catch (RdesktopException e) {
        } catch (CryptoException e) {
        } catch (IOException e) {
View Full Code Here

Examples of com.lixia.rdp.Package.RdpPackage

     * @return Intialised packet
     * @throws RdesktopException
     */
    public RdpPackage init(int flags, int length) throws RdesktopException {
        int headerlength;
        RdpPackage buffer;

        if (!this.licenceIssued) {
            headerlength = ((flags & SEC_ENCRYPT) != 0) ? 12 : 4;
        } else {
            headerlength = ((flags & SEC_ENCRYPT) != 0) ? 12 : 0;
        }

        buffer = McsLayer.init(length + headerlength);
        buffer.pushLayer(RdpPackage.SECURE_HEADER, headerlength);
        //buffer.setHeader(RdpPackage.SECURE_HEADER);
        //buffer.incrementPosition(headerlength);
        //buffer.setStart(buffer.getPosition());
        return buffer;
    }
View Full Code Here

Examples of com.lixia.rdp.Package.RdpPackage

     * @throws CryptoException
     * @throws OrderException
     */
    public RdpPackage receive() throws RdesktopException, IOException, CryptoException, OrderException {
        int sec_flags;
        RdpPackage buffer;
        while (true) {
            int[] channel = new int[1];
            buffer = McsLayer.receive(channel);
            if (buffer == null) {
                return null;
            }
            buffer.setHeader(RdpPackage.SECURE_HEADER);
            if (RDPConnection.conf.encryption || (!this.licenceIssued)) {

                sec_flags = buffer.getLittleEndian32();

                if ((sec_flags & SEC_LICENCE_NEG) != 0) {
                    licence.process(buffer);
                    continue;
                }
                if ((sec_flags & SEC_ENCRYPT) != 0) {
                    buffer.incrementPosition(8); //signature
                    byte[] data = new byte[buffer.size() - buffer.getPosition()];
                    buffer.copyToByteArray(data, 0, buffer.getPosition(), data.length);
                    byte[] packet = this.decrypt(data);

                    buffer.copyFromByteArray(packet, 0, buffer.getPosition(), packet.length);

                    //buffer.setStart(buffer.getPosition());
                    //return buffer;
                }
            }

            if (channel[0] != MCS.MCS_GLOBAL_CHANNEL) {
                channels.channel_process(buffer, channel[0]);
                continue;
            }

            buffer.setStart(buffer.getPosition());
            return buffer;
        }
    }
View Full Code Here

Examples of com.lixia.rdp.Package.RdpPackage

        data.copyFromByteArray(caps, 0, data.getPosition(), /* RDP_CAPLEN_UNKNOWN */ length - 4);
        data.incrementPosition(/* RDP_CAPLEN_UNKNOWN */length - 4);
    }

    private void sendSynchronize() throws RdesktopException, IOException, CryptoException {
        RdpPackage data = this.initData(4);
        data.setLittleEndian16(1); // type
        data.setLittleEndian16(1002);
        data.markEnd();
//        logger.debug("sync");
        this.sendData(data, RDP_DATA_PDU_SYNCHRONISE);
    }
View Full Code Here

Examples of com.lixia.rdp.Package.RdpPackage

//        logger.debug("sync");
        this.sendData(data, RDP_DATA_PDU_SYNCHRONISE);
    }

    private void sendControl(int action) throws RdesktopException, IOException, CryptoException {
        RdpPackage data = this.initData(8);
        data.setLittleEndian16(action);
        data.setLittleEndian16(0); // userid
        data.setLittleEndian32(0); // control id
        data.markEnd();
//        logger.debug("control");
        this.sendData(data, RDP_DATA_PDU_CONTROL);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.