Package streamer

Examples of streamer.ByteBuffer


        switchOff();
    }

    private byte[] getServerPublicKey() {
        // SSL certificate public key with algorithm
        ByteBuffer subjectPublicKeyInfo = new ByteBuffer(sslState.serverCertificateSubjectPublicKeyInfo);

        // Parse subjectPublicKeyInfo
        SubjectPublicKeyInfo parser = new SubjectPublicKeyInfo("SubjectPublicKeyInfo");
        parser.readTag(subjectPublicKeyInfo);

        // Copy subjectPublicKey subfield to separate byte buffer
        ByteBuffer subjectPublicKey = new ByteBuffer(subjectPublicKeyInfo.length);
        parser.subjectPublicKey.writeTag(subjectPublicKey);

        subjectPublicKeyInfo.unref();
        subjectPublicKey.trimAtCursor();

        // Skip tag:
        // 03 82 01 0f (tag) 00 (padding byte)
        subjectPublicKey.trimHeader(5);// FIXME: parse it properly
        // * DEBUG */System.out.println("DEBUG: subjectPublicKey:\n" +
        // subjectPublicKey.dump());

        ntlmState.subjectPublicKey = subjectPublicKey.toByteArray();

        return ntlmState.subjectPublicKey;
    }
View Full Code Here


    }

    @Override
    public void writeBytes(ByteBuffer actual) {
        //*DEBUG*/System.out.println("WriteString: "+actual+", cursor:"+cursor+".");
        ByteBuffer expected = readBytes(actual.length);
        if (!actual.equals(expected))
            throw new RuntimeException("Expected value does not match actual value. Expected value: " + expected + ", actual value: " + actual + ".");
    }
View Full Code Here

            throw new RuntimeException("Expected value does not match actual value. Expected value: " + expected + ", actual value: " + actual + ".");
    }

    @Override
    public void writeBytes(byte[] actualData) {
        ByteBuffer actual = new ByteBuffer(actualData);
        //*DEBUG*/System.out.println("WriteString: "+actual+", cursor:"+cursor+".");
        ByteBuffer expected = readBytes(actual.length);
        if (!actual.equals(expected))
            throw new RuntimeException("Expected value does not match actual value. Expected value: " + expected + ", actual value: " + actual + ".");
    }
View Full Code Here

     * in [RFC3280] section 4.1. The encrypted key is encapsulated in the
     * pubKeyAuth field of the TSRequest structure and is sent over the TLS
     * channel to the server.
     */
    private ByteBuffer generateMessageSignatureAndEncryptedServerPublicKey(NtlmState ntlmState) {
        return new ByteBuffer(ntlmState.ntlm_EncryptMessage(getServerPublicKey()));
    }
View Full Code Here

            throw new RuntimeException("Expected value does not match actual value. Expected value: " + expected + ", actual value: " + actual + ".");
    }

    @Override
    public void writeBytes(byte[] actualData, int offset, int length) {
        ByteBuffer actual = new ByteBuffer(actualData, offset, length);
        //*DEBUG*/System.out.println("WriteString: "+actual+", cursor:"+cursor+".");
        ByteBuffer expected = readBytes(actual.length);
        if (!actual.equals(expected))
            throw new RuntimeException("Expected value does not match actual value. Expected value: " + expected + ", actual value: " + actual + ".");
    }
View Full Code Here

    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.
        buf.writeIntLE(/*ntlmState.negotiatedFlags.value*/0xe288b235); // FIXME: remove hardcoded value

        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)

        int savedCursorForMIC = buf.cursor; // Save cursor position to write MIC
        // later
        buf.writeBytes(new byte[16]); // Write 16 zeroes

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

            sendEventToAllPads(Event.STREAM_CLOSE, Direction.OUT);
            return;
        }

        // Prepare new packet
        ByteBuffer buf = initializeData();

        // Push it to output(s)
        if (buf != null)
            pushDataToAllOuts(buf);
View Full Code Here

    /**
     * Initialize data.
     */
    public ByteBuffer initializeData() {
        ByteBuffer buf = new ByteBuffer(incommingBufLength);

        // Set first byte of package to it sequance number
        buf.data[buf.offset] = (byte)(packetNumber % 128);

        // Initialize rest of bytes with sequential values, which are
        // corresponding with their position in byte buffer
        for (int i = buf.offset + 1; i < buf.length; i++)
            buf.data[i] = (byte)(i % 128);

        buf.putMetadata(ByteBuffer.SEQUENCE_NUMBER, packetNumber);
        buf.putMetadata("src", id);

        return buf;
    }
View Full Code Here

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

        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()));
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.