Package streamer

Examples of streamer.ByteBuffer


        byte[] checksum = CryptoAlgos.RC4(recvRc4Seal, Arrays.copyOf(digest, 8));

        byte[] expectedSignature = CryptoAlgos.concatenationOf(versionBytes, checksum, seqNumBytes);

        if (!Arrays.equals(expectedSignature, actualSignature))
            throw new RuntimeException("Unexpected signature of message:\nExpected signature: " + new ByteBuffer(expectedSignature).toPlainHexString()
                    + "\n  Actual signature: " + new ByteBuffer(actualSignature).toPlainHexString());

        recvSeqNum++;

        return decryptedMessage;
    }
View Full Code Here


                (byte)0x27, (byte)0x4e, (byte)0x4b, (byte)0xf8, (byte)0x38, (byte)0x44, (byte)0x3a, (byte)0x12, (byte)0xf4, (byte)0x07, (byte)0xa0,
                (byte)0x8d, (byte)0x02, (byte)0x03, (byte)0x01, (byte)0x00, (byte)0x01,};
        byte[] actual = ntlm_DecryptMessage(encryptedMessage);

        if (!Arrays.equals(expected, actual))
            throw new RuntimeException("Incorrect result.\nExpected:\n" + new ByteBuffer(expected).toPlainHexString() + "\n  actual:\n"
                    + new ByteBuffer(actual).toPlainHexString() + ".");
    }
View Full Code Here

    @Override
    protected void onStart() {
        super.onStart();

        ByteBuffer negoToken = generateNegotiateMessage();
        ntlmState.negotiateMessage = negoToken.toByteArray(); // Store message for MIC calculation in AUTH message

        // Length of packet
        ByteBuffer buf = new ByteBuffer(1024, true);

        TSRequest tsRequest = new TSRequest("TSRequest");
        tsRequest.version.value = 2L;
        NegoItem negoItem = new NegoItem("NegoItem");
        negoItem.negoToken.value = negoToken;
        tsRequest.negoTokens.tags = new Tag[] {negoItem};

        tsRequest.writeTag(buf);

        // Trim buffer to actual length of data written
        buf.trimAtCursor();

        pushDataToOTOut(buf);

        switchOff();
    }
View Full Code Here

        switchOff();
    }

    private ByteBuffer generateNegotiateMessage() {
        ByteBuffer buf = new ByteBuffer(1024);

        // Signature
        buf.writeString("NTLMSSP", RdpConstants.CHARSET_8);
        buf.writeByte(0);

        // Message type
        buf.writeIntLE(NtlmConstants.NEGOTIATE);

        buf.writeIntLE(clientConfigFlags.value); // Flags

        // If the NTLMSSP_NEGOTIATE_VERSION flag is set by the client application,
        // the Version field MUST be set to the current version (section 2.2.2.10),
        // the DomainName field MUST be set to a zero-length string, and the
        // Workstation field MUST be set to a zero-length string.

        // Domain: ""
        buf.writeShortLE(0); // Length
        buf.writeShortLE(0); // Allocated space
        buf.writeIntLE(0); // Offset

        // Workstation: ""
        buf.writeShortLE(0); // Length
        buf.writeShortLE(0); // Allocated space
        buf.writeIntLE(0); // Offset

        // OS Version: 6.1 (Build 7601); NTLM Current Revision 15
        buf.writeBytes(new byte[] {(byte)0x06, (byte)0x01, (byte)0xb1, (byte)0x1d, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x0f});

        // Trim buffer to actual length of data written
        buf.trimAtCursor();

        return buf;
    }
View Full Code Here

    @Override
    protected void onStart() {
        super.onStart();

        ByteBuffer buf = new ByteBuffer(4096, true);

        TSRequest tsRequest = new TSRequest("TSRequest");
        tsRequest.version.value = 2L;

        ByteBuffer tsCredentialsBuf = generateTSCredentials();
        tsRequest.authInfo.value = encryptTSCredentials(tsCredentialsBuf);
        tsCredentialsBuf.unref();

        tsRequest.writeTag(buf);

        // Trim buffer to actual length of data written
        buf.trimAtCursor();
View Full Code Here

        switchOff();
    }

    private ByteBuffer encryptTSCredentials(ByteBuffer buf2) {
        return new ByteBuffer(ntlmState.ntlm_EncryptMessage(buf2.toByteArray()));
    }
View Full Code Here

    private ByteBuffer encryptTSCredentials(ByteBuffer buf2) {
        return new ByteBuffer(ntlmState.ntlm_EncryptMessage(buf2.toByteArray()));
    }

    private ByteBuffer generateTSCredentials() {
        ByteBuffer buf = new ByteBuffer(4096);

        TSCredentials tsCredentials = new TSCredentials("authInfo");
        // 1 means that credentials field contains a TSPasswordCreds structure
        tsCredentials.credType.value = 1L;

        ByteBuffer tsPasswordCredsBuf = new ByteBuffer(4096, true);
        TSPasswordCreds tsPasswordCreds = new TSPasswordCreds("credentials");
        tsPasswordCreds.domainName.value = new ByteBuffer(ntlmState.domain.getBytes(RdpConstants.CHARSET_16));
        tsPasswordCreds.userName.value = new ByteBuffer(ntlmState.user.getBytes(RdpConstants.CHARSET_16));
        tsPasswordCreds.password.value = new ByteBuffer(ntlmState.password.getBytes(RdpConstants.CHARSET_16));
        tsPasswordCreds.writeTag(tsPasswordCredsBuf);
        tsPasswordCredsBuf.trimAtCursor();
        //* DEBUG */System.out.println("TSPasswordCreds:\n" + tsPasswordCredsBuf.dump());

        tsCredentials.credentials.value = tsPasswordCredsBuf;

        tsCredentials.writeTag(buf);
        tsPasswordCredsBuf.unref();

        // Trim buffer to actual length of data written
        buf.trimAtCursor();
        //* DEBUG */System.out.println("TSCredentials:\n" + buf.dump());

View Full Code Here

    @Override
    protected void handleOneTimeData(ByteBuffer buf, Link link) {
        TSRequest tsRequest = new TSRequest("TSRequest");
        tsRequest.readTag(buf);

        ByteBuffer encryptedPubKey = tsRequest.pubKeyAuth.value;
        if (encryptedPubKey == null || encryptedPubKey.length == 0)
            throw new RuntimeException("[" + this
                    + "] ERROR: Unexpected message from RDP server. Expected encrypted server public key but got nothing instead. Data: " + buf);

        byte[] decryptedPubKey = ntlmState.ntlm_DecryptMessage(encryptedPubKey.toByteArray());
        //* DEBUG */System.out.println("Decrypted pub key:\n" + new ByteBuffer(decryptedPubKey).dump());

        // Decrease first byte by 1
        decryptedPubKey[0]--;

        // Compare returned value with expected value
        if (!Arrays.equals(decryptedPubKey, ntlmState.subjectPublicKey))
            throw new RuntimeException("[" + this
                    + "] ERROR: Unexpected message from RDP server. Expected encrypted server public key but an unknown response. Encryted key after decryption: "
                    + new ByteBuffer(decryptedPubKey).toPlainHexString());

        buf.unref();
        switchOff(); // Ignore packet
    }
View Full Code Here

    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);
    }
View Full Code Here

        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");
View Full Code Here

TOP

Related Classes of streamer.ByteBuffer

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.