Search in sources :

Example 16 with ByteBuffer

use of streamer.ByteBuffer in project cloudstack by apache.

the class NtlmState method testComputeLmV2Response.

public void testComputeLmV2Response() {
    serverChallenge = new byte[] { (byte) 0x34, (byte) 0xe4, (byte) 0x4c, (byte) 0xd5, (byte) 0x75, (byte) 0xe3, (byte) 0x43, (byte) 0x0f };
    clientChallenge = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8 };
    password = "R2Preview!";
    user = "Administrator";
    domain = "workgroup";
    byte[] expected = new byte[] { (byte) 0xa8, (byte) 0xae, (byte) 0xd7, (byte) 0x46, (byte) 0x06, (byte) 0x32, (byte) 0x02, (byte) 0x35, (byte) 0x1d, (byte) 0x95, (byte) 0x99, (byte) 0x36, (byte) 0x20, (byte) 0x36, (byte) 0xac, (byte) 0xc3, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x04, (byte) 0x05, (byte) 0x06, (byte) 0x07, (byte) 0x08 };
    byte[] actual = ntlm_compute_lm_v2_response();
    if (!Arrays.equals(expected, actual))
        throw new RuntimeException("Incorrect result.\nExpected:\n" + new ByteBuffer(expected).toPlainHexString() + "\n  actual:\n" + new ByteBuffer(actual).toPlainHexString() + ".");
}
Also used : ByteBuffer(streamer.ByteBuffer)

Example 17 with ByteBuffer

use of streamer.ByteBuffer in project cloudstack by apache.

the class NtlmState method testComputeNtProofStr.

public void testComputeNtProofStr() {
    byte[] ntlm_v2_hash = new byte[] { (byte) 0x5f, (byte) 0xcc, (byte) 0x4c, (byte) 0x48, (byte) 0x74, (byte) 0x6b, (byte) 0x94, (byte) 0xce, (byte) 0xb7, (byte) 0xae, (byte) 0xf1, (byte) 0x0d, (byte) 0xc9, (byte) 0x11, (byte) 0x22, (byte) 0x8f };
    byte[] data = new byte[] { (byte) 0x4a, (byte) 0x25, (byte) 0x50, (byte) 0xa5, (byte) 0x11, (byte) 0x9b, (byte) 0xd6, (byte) 0x16, (byte) 0x01, (byte) 0x01, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0xa0, (byte) 0xe8, (byte) 0x85, (byte) 0x2c, (byte) 0xe4, (byte) 0xc9, (byte) 0xce, (byte) 0x01, (byte) 0x01, (byte) 0x02, (byte) 0x03, (byte) 0x04, (byte) 0x05, (byte) 0x06, (byte) 0x07, (byte) 0x08, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x02, (byte) 0x00, (byte) 0x1e, (byte) 0x00, (byte) 0x57, (byte) 0x00, (byte) 0x49, (byte) 0x00, (byte) 0x4e, (byte) 0x00, (byte) 0x2d, (byte) 0x00, (byte) 0x4c, (byte) 0x00, (byte) 0x4f, (byte) 0x00, (byte) 0x34, (byte) 0x00, (byte) 0x31, (byte) 0x00, (byte) 0x39, (byte) 0x00, (byte) 0x42, (byte) 0x00, (byte) 0x32, (byte) 0x00, (byte) 0x4c, (byte) 0x00, (byte) 0x53, (byte) 0x00, (byte) 0x52, (byte) 0x00, (byte) 0x30, (byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0x1e, (byte) 0x00, (byte) 0x57, (byte) 0x00, (byte) 0x49, (byte) 0x00, (byte) 0x4e, (byte) 0x00, (byte) 0x2d, (byte) 0x00, (byte) 0x4c, (byte) 0x00, (byte) 0x4f, (byte) 0x00, (byte) 0x34, (byte) 0x00, (byte) 0x31, (byte) 0x00, (byte) 0x39, (byte) 0x00, (byte) 0x42, (byte) 0x00, (byte) 0x32, (byte) 0x00, (byte) 0x4c, (byte) 0x00, (byte) 0x53, (byte) 0x00, (byte) 0x52, (byte) 0x00, (byte) 0x30, (byte) 0x00, (byte) 0x04, (byte) 0x00, (byte) 0x1e, (byte) 0x00, (byte) 0x57, (byte) 0x00, (byte) 0x49, (byte) 0x00, (byte) 0x4e, (byte) 0x00, (byte) 0x2d, (byte) 0x00, (byte) 0x4c, (byte) 0x00, (byte) 0x4f, (byte) 0x00, (byte) 0x34, (byte) 0x00, (byte) 0x31, (byte) 0x00, (byte) 0x39, (byte) 0x00, (byte) 0x42, (byte) 0x00, (byte) 0x32, (byte) 0x00, (byte) 0x4c, (byte) 0x00, (byte) 0x53, (byte) 0x00, (byte) 0x52, (byte) 0x00, (byte) 0x30, (byte) 0x00, (byte) 0x03, (byte) 0x00, (byte) 0x1e, (byte) 0x00, (byte) 0x57, (byte) 0x00, (byte) 0x49, (byte) 0x00, (byte) 0x4e, (byte) 0x00, (byte) 0x2d, (byte) 0x00, (byte) 0x4c, (byte) 0x00, (byte) 0x4f, (byte) 0x00, (byte) 0x34, (byte) 0x00, (byte) 0x31, (byte) 0x00, (byte) 0x39, (byte) 0x00, (byte) 0x42, (byte) 0x00, (byte) 0x32, (byte) 0x00, (byte) 0x4c, (byte) 0x00, (byte) 0x53, (byte) 0x00, (byte) 0x52, (byte) 0x00, (byte) 0x30, (byte) 0x00, (byte) 0x07, (byte) 0x00, (byte) 0x08, (byte) 0x00, (byte) 0xa0, (byte) 0xe8, (byte) 0x85, (byte) 0x2c, (byte) 0xe4, (byte) 0xc9, (byte) 0xce, (byte) 0x01, (byte) 0x06, (byte) 0x00, (byte) 0x04, (byte) 0x00, (byte) 0x02, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x0a, (byte) 0x00, (byte) 0x10, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x09, (byte) 0x00, (byte) 0x26, (byte) 0x00, (byte) 0x54, (byte) 0x00, (byte) 0x45, (byte) 0x00, (byte) 0x52, (byte) 0x00, (byte) 0x4d, (byte) 0x00, (byte) 0x53, (byte) 0x00, (byte) 0x52, (byte) 0x00, (byte) 0x56, (byte) 0x00, (byte) 0x2f, (byte) 0x00, (byte) 0x31, (byte) 0x00, (byte) 0x39, (byte) 0x00, (byte) 0x32, (byte) 0x00, (byte) 0x2e, (byte) 0x00, (byte) 0x31, (byte) 0x00, (byte) 0x36, (byte) 0x00, (byte) 0x38, (byte) 0x00, (byte) 0x2e, (byte) 0x00, (byte) 0x31, (byte) 0x00, (byte) 0x2e, (byte) 0x00, (byte) 0x33, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 };
    byte[] expected = new byte[] { (byte) 0x19, (byte) 0x4b, (byte) 0xeb, (byte) 0xad, (byte) 0xda, (byte) 0x24, (byte) 0xd5, (byte) 0x96, (byte) 0x85, (byte) 0x2e, (byte) 0x24, (byte) 0x94, (byte) 0xd6, (byte) 0x4a, (byte) 0xb8, (byte) 0x5e };
    byte[] actual = computeNtProofStr(ntlm_v2_hash, data);
    if (!Arrays.equals(expected, actual))
        throw new RuntimeException("Incorrect result.\nExpected:\n" + new ByteBuffer(expected).toPlainHexString() + "\n  actual:\n" + new ByteBuffer(actual).toPlainHexString() + ".");
}
Also used : ByteBuffer(streamer.ByteBuffer)

Example 18 with ByteBuffer

use of streamer.ByteBuffer in project cloudstack by apache.

the class NtlmState method ntlm_construct_authenticate_target_info.

public byte[] ntlm_construct_authenticate_target_info() {
    ByteBuffer buf = new ByteBuffer(4096);
    writeAVPair(buf, MSV_AV_NETBIOS_DOMAIN_NAME, serverNetbiosDomainName);
    writeAVPair(buf, MSV_AV_NETBIOS_COMPUTER_NAME, serverNetbiosComputerName);
    writeAVPair(buf, MSV_AV_DNS_DOMAIN_NAME, serverDnsDomainName);
    writeAVPair(buf, MSV_AV_DNS_COMPUTER_NAME, serverDnsComputerName);
    writeAVPair(buf, MSV_AV_DNS_TREE_NAME, serverDnsTreeName);
    writeAVPair(buf, MSV_AV_TIMESTAMP, serverTimestamp);
    byte[] flags = new byte[] { (byte) MSV_AV_FLAGS_MESSAGE_INTEGRITY_CHECK, 0, 0, 0 };
    writeAVPair(buf, MSV_AV_FLAGS, flags);
    writeAVPair(buf, MSV_AV_CHANNEL_BINDINGS, channelBindingsHash);
    writeAVPair(buf, MSV_AV_TARGET_NAME, servicePrincipalName);
    writeAVPair(buf, MSV_AV_EOL, "");
    // DEBUG: put EOL 4 times, for compatibility with FreeRDP output
    // *DEBUG*/writeAVPair(buf, MSV_AV_EOL, "");
    // *DEBUG*/writeAVPair(buf, MSV_AV_EOL, "");
    // *DEBUG*/writeAVPair(buf, MSV_AV_EOL, "");
    buf.trimAtCursor();
    authenticateTargetInfo = buf.toByteArray();
    buf.unref();
    return authenticateTargetInfo;
}
Also used : ByteBuffer(streamer.ByteBuffer)

Example 19 with ByteBuffer

use of streamer.ByteBuffer in project cloudstack by apache.

the class ServerNtlmsspChallenge method parseTargetInfo.

public void parseTargetInfo(ByteBuffer buf) {
    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);
        parseAttribute(data, type, length);
        data.unref();
    }
}
Also used : ByteBuffer(streamer.ByteBuffer)

Example 20 with ByteBuffer

use of streamer.ByteBuffer in project cloudstack by apache.

the class ServerNtlmsspChallenge method parseNtlmChallenge.

public void parseNtlmChallenge(ByteBuffer buf) {
    // Signature: "NTLMSSP\0"
    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.CHALLENGE)
        throw new RuntimeException("Unexpected NTLM message type: " + messageType + ". Expected type: CHALLENGE (" + NtlmConstants.CHALLENGE + "). Data: " + buf + ".");
    // TargetName
    ntlmState.serverTargetName = readStringByDescription(buf);
    // NegotiateFlags
    ntlmState.negotiatedFlags = new NegoFlags(buf.readSignedIntLE());
    if (verbose)
        System.out.println("[" + this + "] INFO: Server negotiate flags: " + ntlmState.negotiatedFlags + ".");
    // ServerChallenge
    ByteBuffer challenge = buf.readBytes(8);
    ntlmState.serverChallenge = challenge.toByteArray();
    if (verbose)
        System.out.println("[" + this + "] INFO: Server challenge: " + challenge + ".");
    challenge.unref();
    // Reserved/context
    buf.skipBytes(8);
    // TargetInfo
    ByteBuffer targetInfo = readBlockByDescription(buf);
    // Store raw target info block for Type3 message
    ntlmState.serverTargetInfo = targetInfo.toByteArray();
    // Parse target info block
    parseTargetInfo(targetInfo);
    targetInfo.unref();
    // OS Version, NTLM revision, 8 bytes, Optional. Ignore it.
    // Ignore rest of buffer with allocated blocks
    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