Search in sources :

Example 46 with ByteBuffer

use of streamer.ByteBuffer in project cloudstack by apache.

the class ServerNtlmsspChallenge method readStringByDescription.

/**
     * Read NTLM wide string, by it description. Buffer offset must point to
     * beginning of NTLM message signature.
     *
     * @param buf
     *          buffer with cursor pointing to description
     * @return
     */
public static String readStringByDescription(ByteBuffer buf) {
    ByteBuffer block = readBlockByDescription(buf);
    String value = block.readString(block.length, RdpConstants.CHARSET_16);
    block.unref();
    return value;
}
Also used : ByteBuffer(streamer.ByteBuffer)

Example 47 with ByteBuffer

use of streamer.ByteBuffer in project cloudstack by apache.

the class ServerNtlmsspChallenge method parseAttribute.

public void parseAttribute(ByteBuffer buf, int type, int length) {
    switch(type) {
        case MSV_AV_NETBIOS_DOMAIN_NAME:
            ntlmState.serverNetbiosDomainName = buf.readString(length, RdpConstants.CHARSET_16);
            break;
        case MSV_AV_NETBIOS_COMPUTER_NAME:
            ntlmState.serverNetbiosComputerName = buf.readString(length, RdpConstants.CHARSET_16);
            break;
        case MSV_AV_DNS_DOMAIN_NAME:
            ntlmState.serverDnsDomainName = buf.readString(length, RdpConstants.CHARSET_16);
            break;
        case MSV_AV_DNS_COMPUTER_NAME:
            ntlmState.serverDnsComputerName = buf.readString(length, RdpConstants.CHARSET_16);
            break;
        case MSV_AV_DNS_TREE_NAME:
            ntlmState.serverDnsTreeName = buf.readString(length, RdpConstants.CHARSET_16);
            break;
        case MSV_AV_TIMESTAMP:
            ByteBuffer tmp = buf.readBytes(length);
            ntlmState.serverTimestamp = tmp.toByteArray();
            //*DEBUG*/System.out.println("Server timestamp: "+tmp.toPlainHexString());
            tmp.unref();
            break;
        default:
    }
}
Also used : ByteBuffer(streamer.ByteBuffer)

Example 48 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)

Example 49 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 50 with ByteBuffer

use of streamer.ByteBuffer in project cloudstack by apache.

the class NtlmState method testNTOWFv2W.

public void testNTOWFv2W() {
    byte[] expected = 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[] actual = NTOWFv2W("R2Preview!", "Administrator", "workgroup");
    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)

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