Search in sources :

Example 31 with ByteBuffer

use of streamer.ByteBuffer in project cloudstack by apache.

the class ClientNtlmsspPubKeyAuth method dumpNegoToken.

private void dumpNegoToken(ByteBuffer buf) {
    String signature = buf.readVariableString(RdpConstants.CHARSET_8);
    if (!ConstantTimeComparator.compareStrings(signature, NTLMSSP))
        throw new RuntimeException("Unexpected NTLM message singature: \"" + signature + "\". Expected signature: \"" + NTLMSSP + "\". Data: " + buf + ".");
    // MessageType (CHALLENGE)
    int messageType = buf.readSignedIntLE();
    if (messageType != NtlmConstants.NTLMSSP_AUTH)
        throw new RuntimeException("Unexpected NTLM message type: " + messageType + ". Expected type: CHALLENGE (" + NtlmConstants.CHALLENGE + "). Data: " + buf + ".");
    System.out.println("lmChallengeResponseFields: " + ServerNtlmsspChallenge.readBlockByDescription(buf).toPlainHexString());
    ByteBuffer ntChallengeResponseBuf = ServerNtlmsspChallenge.readBlockByDescription(buf);
    System.out.println("NtChallengeResponse: " + ntChallengeResponseBuf.toPlainHexString());
    System.out.println("DomainName: " + ServerNtlmsspChallenge.readStringByDescription(buf));
    System.out.println("UserName: " + ServerNtlmsspChallenge.readStringByDescription(buf));
    System.out.println("Workstation: " + ServerNtlmsspChallenge.readStringByDescription(buf));
    System.out.println("EncryptedRandomSessionKey: " + ServerNtlmsspChallenge.readBlockByDescription(buf).toPlainHexString());
    System.out.println("NegotiateFlags: " + new NegoFlags(buf.readSignedIntLE()));
    System.out.println("Version: " + buf.readBytes(8).toPlainHexString());
    dumpNtChallengeResponse(ntChallengeResponseBuf);
}
Also used : ByteBuffer(streamer.ByteBuffer)

Example 32 with ByteBuffer

use of streamer.ByteBuffer in project cloudstack by apache.

the class ClientNtlmsspPubKeyAuth method dumpNtChallengeResponse.

private void dumpNtChallengeResponse(ByteBuffer buf) {
    System.out.println("HMAC: " + buf.readBytes(16).toPlainHexString());
    System.out.format("Header: 0x%08x\n", buf.readUnsignedIntLE());
    System.out.format("Reserved: 0x%08x\n", buf.readUnsignedIntLE());
    System.out.println("Time: " + buf.readBytes(8).toPlainHexString());
    System.out.println("Client challenge: " + buf.readBytes(8).toPlainHexString());
    System.out.format("Reserved: 0x%08x\n", buf.readUnsignedIntLE());
    while (buf.remainderLength() > 0) {
        int type = buf.readUnsignedShortLE();
        int length = buf.readUnsignedShortLE();
        if (type == MSV_AV_EOL)
            // End of list
            break;
        ByteBuffer data = buf.readBytes(length);
        switch(type) {
            case MSV_AV_NETBIOS_DOMAIN_NAME:
                System.out.println("AV Netbios Domain name: " + data.readString(length, RdpConstants.CHARSET_16));
                break;
            case MSV_AV_NETBIOS_COMPUTER_NAME:
                System.out.println("AV Netbios Computer name: " + data.readString(length, RdpConstants.CHARSET_16));
                break;
            case MSV_AV_DNS_DOMAIN_NAME:
                System.out.println("AV DNS Domain name: " + data.readString(length, RdpConstants.CHARSET_16));
                break;
            case MSV_AV_DNS_COMPUTER_NAME:
                System.out.println("AV DNS Computer name: " + data.readString(length, RdpConstants.CHARSET_16));
                break;
            case MSV_AV_CHANNEL_BINDINGS:
                System.out.println("AV Channel Bindings: " + data.readBytes(length).toPlainHexString());
                break;
            case MSV_AV_TIMESTAMP:
                System.out.println("AV Timestamp: " + data.readBytes(length).toPlainHexString());
                break;
            case MSV_AV_FLAGS:
                System.out.println("AV Flags: " + data.readBytes(length).toPlainHexString());
                break;
            case MSV_AV_TARGET_NAME:
                System.out.println("AV Target Name: " + data.readString(length, RdpConstants.CHARSET_16));
                break;
            default:
                System.out.println("Unknown NTLM target info attribute: " + type + ". Data: " + data + ".");
        }
        data.unref();
    }
}
Also used : ByteBuffer(streamer.ByteBuffer)

Example 33 with ByteBuffer

use of streamer.ByteBuffer in project cloudstack by apache.

the class ClientNtlmsspPubKeyAuth method dump.

@Override
public void dump(ByteBuffer buf) {
    buf.rewindCursor();
    TSRequest request = new TSRequest("TSRequest");
    request.readTag(buf);
    System.out.println("TSRequest version: " + request.version.value);
    System.out.println("TSRequest pubKey: " + request.pubKeyAuth.value.toPlainHexString());
    ByteBuffer negoToken = ((NegoItem) request.negoTokens.tags[0]).negoToken.value;
    System.out.println("TSRequest negotoken: " + negoToken.toPlainHexString());
    dumpNegoToken(negoToken);
    negoToken.unref();
}
Also used : TSRequest(rdpclient.ntlmssp.asn1.TSRequest) ByteBuffer(streamer.ByteBuffer)

Example 34 with ByteBuffer

use of streamer.ByteBuffer in project cloudstack by apache.

the class AwtRdpKeyboardAdapter method handleData.

@Override
public void handleData(ByteBuffer buf, Link link) {
    if (verbose)
        System.out.println("[" + this + "] INFO: Data received: " + buf + ".");
    KeyOrder order = (KeyOrder) buf.getOrder();
    buf.unref();
    ByteBuffer outBuf = new ByteBuffer(2, true);
    int scanCode = map_en_us(order.event);
    // eventHeader (1 byte): An 8-bit, unsigned integer. The format of this
    // field is the same as the eventHeader byte field described in section
    // 2.2.8.1.2.2. The eventCode bitfield (3 bits in size) MUST be set to
    // FASTPATH_INPUT_EVENT_SCANCODE (0). The eventFlags bitfield (5 bits in
    // size) contains flags describing the keyboard event.
    outBuf.writeByte((scanCode >> 8) | (FASTPATH_INPUT_EVENT_SCANCODE << 5) | ((order.pressed) ? 0 : FASTPATH_INPUT_KBDFLAGS_RELEASE));
    // keyCode (1 byte): An 8-bit, unsigned integer. The scancode of the key
    // which triggered the event.
    outBuf.writeByte(scanCode);
    // Push buffer to one pad only, so it can be modified without copying of
    // data
    pushDataToPad(STDOUT, outBuf);
}
Also used : KeyOrder(common.KeyOrder) ByteBuffer(streamer.ByteBuffer)

Example 35 with ByteBuffer

use of streamer.ByteBuffer in project cloudstack by apache.

the class ServerClipRdrChannelRouter method handleData.

@Override
public void handleData(ByteBuffer buf, Link link) {
    if (verbose)
        System.out.println("[" + this + "] INFO: Data received: " + buf + ".");
    // Parse PDU header
    // Example: 07 00 -> CLIPRDR_HEADER::msgType = CB_CLIP_CAPS (7)
    int msgType = buf.readUnsignedShortLE();
    // Example: 00 00 -> CLIPRDR_HEADER::msgFlags = 0
    int msgFlags = buf.readUnsignedShortLE();
    // Example: 10 00 00 00 -> CLIPRDR_HEADER::dataLen = 0x10 = 16 bytes
    long dataLenLong = buf.readSignedIntLE();
    if (dataLenLong > 4 * 1024 * 1024)
        throw new RuntimeException("Clipboard packet is too long. Expected length: less than 4MiB. Actual length: " + dataLenLong + ".");
    int dataLen = (int) dataLenLong;
    ByteBuffer payload = buf.readBytes(dataLen);
    // Parse message flags and store them in the payload metadata
    if ((msgFlags & CB_RESPONSE_OK) == CB_RESPONSE_OK)
        payload.putMetadata("success", true);
    if ((msgFlags & CB_RESPONSE_FAIL) == CB_RESPONSE_FAIL)
        payload.putMetadata(SUCCESS, false);
    if ((msgFlags & CB_ASCII_NAMES) == CB_ASCII_NAMES)
        payload.putMetadata(ASCII_NAMES, true);
    // Push PDU to appropriate handler
    switch(msgType) {
        case CB_MONITOR_READY:
            pushDataToPad("monitor_ready", payload);
            break;
        case CB_FORMAT_LIST:
            pushDataToPad("format_list", payload);
            break;
        case CB_FORMAT_LIST_RESPONSE:
            pushDataToPad("format_list_response", payload);
            break;
        case CB_FORMAT_DATA_REQUEST:
            pushDataToPad("format_data_request", payload);
            break;
        case CB_FORMAT_DATA_RESPONSE:
            pushDataToPad("format_data_response", payload);
            break;
        case CB_TEMP_DIRECTORY:
            throw new RuntimeException("[" + this + "] ERROR: Unexpected clipboard temporary directory PDU received from server. Data: " + buf + ".");
        case CB_CLIP_CAPS:
            pushDataToPad("clipboard_capabilities", payload);
            break;
        case CB_FILECONTENTS_REQUEST:
            pushDataToPad("filecontent_request", payload);
            break;
        case CB_FILECONTENTS_RESPONSE:
            pushDataToPad("filecontent_response", payload);
            break;
        case CB_LOCK_CLIPDATA:
            pushDataToPad("lock_clipdata", payload);
            break;
        case CB_UNLOCK_CLIPDATA:
            pushDataToPad("unlock_clipdata", payload);
            break;
        default:
            throw new RuntimeException("[" + this + "] ERROR: Unknown clipboard PDU message type: " + msgType + ".");
    }
    buf.unref();
}
Also used : ByteBuffer(streamer.ByteBuffer)

Aggregations

ByteBuffer (streamer.ByteBuffer)110 Element (streamer.Element)12 BaseElement (streamer.BaseElement)9 Pipeline (streamer.Pipeline)7 PipelineImpl (streamer.PipelineImpl)7 TSRequest (rdpclient.ntlmssp.asn1.TSRequest)6 MockSink (streamer.debug.MockSink)5 MockSource (streamer.debug.MockSource)5 BitmapRectangle (common.BitmapRectangle)3 ScreenDescription (common.ScreenDescription)3 SyncLink (streamer.SyncLink)3 AssertingByteBuffer (streamer.debug.AssertingByteBuffer)3 BitmapOrder (common.BitmapOrder)2 KeyOrder (common.KeyOrder)2 MouseOrder (common.MouseOrder)2 NegoItem (rdpclient.ntlmssp.asn1.NegoItem)2 Link (streamer.Link)2 FakeSink (streamer.debug.FakeSink)2 BufferedImageCanvas (common.BufferedImageCanvas)1 CopyRectOrder (common.CopyRectOrder)1