Search in sources :

Example 91 with ByteBuffer

use of streamer.ByteBuffer in project cloudstack by apache.

the class AwtCanvasAdapter method main.

/**
     * Example.
     */
public static void main(String[] args) {
    // System.setProperty("streamer.Link.debug", "true");
    // System.setProperty("streamer.Element.debug", "true");
    // System.setProperty("streamer.Pipeline.debug", "true");
    ByteBuffer packet = new ByteBuffer(new byte[] { 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x10, 0x00, 0x01, 0x00, 0x10, 0x00, 0x01, 0x04, 0x0a, 0x00, 0x0c, (byte) 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 });
    Pipeline pipeline = new PipelineImpl("test");
    Element bitmap = new ServerBitmapUpdate("bitmap");
    BufferedImageCanvas canvas = new BufferedImageCanvas(1024, 768);
    Element adapter = new AwtCanvasAdapter("test", canvas, null) {

        {
            verbose = true;
        }
    };
    pipeline.addAndLink(bitmap, adapter);
    bitmap.handleData(packet, null);
}
Also used : PipelineImpl(streamer.PipelineImpl) Element(streamer.Element) BaseElement(streamer.BaseElement) ServerBitmapUpdate(rdpclient.rdp.ServerBitmapUpdate) ByteBuffer(streamer.ByteBuffer) BufferedImageCanvas(common.BufferedImageCanvas) Pipeline(streamer.Pipeline)

Example 92 with ByteBuffer

use of streamer.ByteBuffer in project cloudstack by apache.

the class ClientNtlmsspPubKeyAuth method onStart.

@Override
protected void onStart() {
    super.onStart();
    /*
         * @see
         * http://blogs.msdn.com/b/openspecification/archive/2010/04/20/ntlm-keys
         * -and-sundry-stuff.aspx
         */
    ntlmState.domain = targetDomain;
    ntlmState.user = user;
    ntlmState.password = password;
    ntlmState.workstation = workstation;
    ntlmState.generateServicePrincipalName(serverHostName);
    ntlmState.ntlm_construct_authenticate_target_info();
    ntlmState.ntlm_generate_timestamp();
    ntlmState.ntlm_generate_client_challenge();
    ntlmState.ntlm_compute_lm_v2_response();
    ntlmState.ntlm_compute_ntlm_v2_response();
    ntlmState.ntlm_generate_key_exchange_key();
    ntlmState.ntlm_generate_random_session_key();
    ntlmState.ntlm_generate_exported_session_key();
    ntlmState.ntlm_encrypt_random_session_key();
    ntlmState.ntlm_init_rc4_seal_states();
    ByteBuffer authenticateMessage = generateAuthenticateMessage(ntlmState);
    ByteBuffer messageSignatureAndEncryptedServerPublicKey = generateMessageSignatureAndEncryptedServerPublicKey(ntlmState);
    // Length of packet
    ByteBuffer buf = new ByteBuffer(4096, true);
    TSRequest tsRequest = new TSRequest("TSRequest");
    tsRequest.version.value = 2L;
    NegoItem negoItem = new NegoItem("NegoItem");
    negoItem.negoToken.value = authenticateMessage;
    tsRequest.negoTokens.tags = new Tag[] { negoItem };
    tsRequest.pubKeyAuth.value = messageSignatureAndEncryptedServerPublicKey;
    tsRequest.writeTag(buf);
    // Trim buffer to actual length of data written
    buf.trimAtCursor();
    pushDataToOTOut(buf);
    switchOff();
}
Also used : NegoItem(rdpclient.ntlmssp.asn1.NegoItem) ByteBuffer(streamer.ByteBuffer) TSRequest(rdpclient.ntlmssp.asn1.TSRequest)

Example 93 with ByteBuffer

use of streamer.ByteBuffer in project cloudstack by apache.

the class ClientNtlmsspPubKeyAuth method generateAuthenticateMessage.

public static ByteBuffer generateAuthenticateMessage(NtlmState ntlmState) {
    // Allocate memory for blocks from given fixed offset
    int blocksCursor = BLOCKS_OFFSET;
    ByteBuffer buf = new ByteBuffer(4096);
    // Signature: "NTLMSSP\0"
    buf.writeString(NTLMSSP, RdpConstants.CHARSET_8);
    buf.writeByte(0);
    // NTLM Message Type: NTLMSSP_AUTH (0x00000003)
    buf.writeIntLE(NtlmConstants.NTLMSSP_AUTH);
    // Although the protocol allows authentication to succeed if the client
    // provides either LmChallengeResponse or NtChallengeResponse, Windows
    // implementations provide both.
    // LM V2 response
    blocksCursor = writeBlock(buf, ntlmState.lmChallengeResponse, blocksCursor);
    // NT v2 response
    blocksCursor = writeBlock(buf, ntlmState.ntChallengeResponse, blocksCursor);
    // DomainName
    blocksCursor = writeStringBlock(buf, ntlmState.domain, blocksCursor, RdpConstants.CHARSET_16);
    // UserName
    blocksCursor = writeStringBlock(buf, ntlmState.user, blocksCursor, RdpConstants.CHARSET_16);
    // Workstation
    blocksCursor = writeStringBlock(buf, ntlmState.workstation, blocksCursor, RdpConstants.CHARSET_16);
    // EncryptedRandomSessionKey, 16 bytes
    blocksCursor = writeBlock(buf, ntlmState.encryptedRandomSessionKey, blocksCursor);
    // NegotiateFlags (4 bytes): In connection-oriented mode, a NEGOTIATE
    // structure that contains the set of bit flags (section 2.2.2.5) negotiated
    // in the previous messages.
    // FIXME: remove hardcoded value
    buf.writeIntLE(/*ntlmState.negotiatedFlags.value*/
    0xe288b235);
    buf.writeBytes(generateVersion());
    // If the CHALLENGE_MESSAGE TargetInfo field (section 2.2.1.2) has an
    // MsvAvTimestamp present, the client SHOULD provide a MIC(Message Integrity
    // Check)
    // Save cursor position to write MIC
    int savedCursorForMIC = buf.cursor;
    // later
    // Write 16 zeroes
    buf.writeBytes(new byte[16]);
    if (BLOCKS_OFFSET != buf.cursor)
        throw new RuntimeException("BUG: Actual offset of first byte of allocated blocks is not equal hardcoded offset. Hardcoded offset: " + BLOCKS_OFFSET + ", actual offset: " + buf.cursor + ". Update hardcoded offset to match actual offset.");
    buf.cursor = blocksCursor;
    buf.trimAtCursor();
    ntlmState.authenticateMessage = buf.toByteArray();
    // Calculate and write MIC to reserved position
    ntlmState.ntlm_compute_message_integrity_check();
    buf.cursor = savedCursorForMIC;
    buf.writeBytes(ntlmState.messageIntegrityCheck);
    buf.rewindCursor();
    return buf;
}
Also used : ByteBuffer(streamer.ByteBuffer)

Example 94 with ByteBuffer

use of streamer.ByteBuffer in project cloudstack by apache.

the class ServerFormatDataResponsePDU method main.

/**
     * Example.
     */
public static void main(String[] args) {
    // System.setProperty("streamer.Link.debug", "true");
    System.setProperty("streamer.Element.debug", "true");
    // System.setProperty("streamer.Pipeline.debug", "true");
    /* @formatter:off */
    byte[] packet = new byte[] { //  CLIPRDR_HEADER::msgType = CB_FORMAT_DATA_RESPONSE (5)
    0x05, //  CLIPRDR_HEADER::msgType = CB_FORMAT_DATA_RESPONSE (5)
    0x00, //  CLIPRDR_HEADER::msgFlags = 0x0001 = CB_RESPONSE_OK
    0x01, //  CLIPRDR_HEADER::msgFlags = 0x0001 = CB_RESPONSE_OK
    0x00, //  CLIPRDR_HEADER::dataLen = 0x18 = 24 bytes
    0x18, //  CLIPRDR_HEADER::dataLen = 0x18 = 24 bytes
    0x00, //  CLIPRDR_HEADER::dataLen = 0x18 = 24 bytes
    0x00, //  CLIPRDR_HEADER::dataLen = 0x18 = 24 bytes
    0x00, 0x68, 0x00, 0x65, 0x00, 0x6c, 0x00, 0x6c, 0x00, 0x6f, 0x00, 0x20, 0x00, 0x77, 0x00, 0x6f, 0x00, //  CLIPRDR_FORMAT_DATA_RESPONSE::requestedFormatData: "hello world"
    0x72, //  CLIPRDR_FORMAT_DATA_RESPONSE::requestedFormatData: "hello world"
    0x00, //  CLIPRDR_FORMAT_DATA_RESPONSE::requestedFormatData: "hello world"
    0x6c, //  CLIPRDR_FORMAT_DATA_RESPONSE::requestedFormatData: "hello world"
    0x00, //  CLIPRDR_FORMAT_DATA_RESPONSE::requestedFormatData: "hello world"
    0x64, //  CLIPRDR_FORMAT_DATA_RESPONSE::requestedFormatData: "hello world"
    0x00, //  CLIPRDR_FORMAT_DATA_RESPONSE::requestedFormatData: "hello world"
    0x00, //  CLIPRDR_FORMAT_DATA_RESPONSE::requestedFormatData: "hello world"
    0x00 };
    /* @formatter:on */
    MockSource source = new MockSource("source", ByteBuffer.convertByteArraysToByteBuffers(packet));
    Element router = new ServerClipRdrChannelRouter("router");
    ClipboardState state = new ClipboardState();
    state.serverRequestedFormat = new ClipboardDataFormat(ClipboardDataFormat.CB_FORMAT_UNICODETEXT, "");
    Element format_data_response = new ServerFormatDataResponsePDU("format_data_response", state);
    ByteBuffer clipboardAdapterPacket = new ByteBuffer(0);
    clipboardAdapterPacket.putMetadata(AwtClipboardAdapter.CLIPBOARD_CONTENT, "hello world");
    Element sink = new MockSink("sink", new ByteBuffer[] { clipboardAdapterPacket });
    Pipeline pipeline = new PipelineImpl("test");
    pipeline.add(source, router, format_data_response, sink);
    pipeline.link("source", "router >format_data_response", "format_data_response >clipboard", "sink");
    pipeline.runMainLoop("source", STDOUT, false, false);
}
Also used : MockSource(streamer.debug.MockSource) MockSink(streamer.debug.MockSink) PipelineImpl(streamer.PipelineImpl) Element(streamer.Element) BaseElement(streamer.BaseElement) ByteBuffer(streamer.ByteBuffer) Pipeline(streamer.Pipeline)

Example 95 with ByteBuffer

use of streamer.ByteBuffer in project cloudstack by apache.

the class ServerFormatDataResponsePDU method parseData.

protected void parseData(ByteBuffer buf) {
    String content = state.serverRequestedFormat.parseServerResponseAsString(buf);
    // Send response to clipboard adapter
    ByteBuffer outBuf = new ByteBuffer(0);
    outBuf.putMetadata(AwtClipboardAdapter.CLIPBOARD_CONTENT, content);
    pushDataToPad(SERVER_CLIPBOARD_ADAPTER_PAD, outBuf);
}
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