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;
}
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:
}
}
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();
}
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();
}
}
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() + ".");
}
Aggregations