use of streamer.ByteBuffer in project cloudstack by apache.
the class ServerFormatListPDU method sendFormatDataRequest.
/**
* The Format Data Request PDU is sent by the recipient of the Format List
* PDU. It is used to request the data for one of the formats that was listed
* in the Format List PDU.
*/
protected void sendFormatDataRequest(ClipboardDataFormat textFormat) {
if (verbose)
System.out.println("[" + this + "] INFO: Sending request for data in following format: " + textFormat + ".");
// Store data format to parse server response later
state.serverRequestedFormat = textFormat;
ByteBuffer buf = new ByteBuffer(12, true);
// Type
buf.writeShortLE(ServerClipRdrChannelRouter.CB_FORMAT_DATA_REQUEST);
// Message flags
buf.writeShortLE(0);
// Length
buf.writeIntLE(4);
// ID of chosen format
buf.writeIntLE(textFormat.id);
buf.trimAtCursor();
pushDataToPad(STDOUT, buf);
}
use of streamer.ByteBuffer in project cloudstack by apache.
the class ServerNtlmsspChallenge method handleOneTimeData.
@Override
protected void handleOneTimeData(ByteBuffer buf, Link link) {
if (buf == null)
return;
if (verbose)
System.out.println("[" + this + "] INFO: Data received: " + buf + ".");
// Extract server challenge, extract server flags.
// Parse TSRequest in BER format
TSRequest request = new TSRequest("TSRequest");
request.readTag(buf);
ByteBuffer negoToken = ((NegoItem) request.negoTokens.tags[0]).negoToken.value;
// Store message for MIC calculation in AUTH message
ntlmState.challengeMessage = negoToken.toByteArray();
parseNtlmChallenge(negoToken);
negoToken.unref();
buf.unref();
switchOff();
}
use of streamer.ByteBuffer in project cloudstack by apache.
the class ServerNtlmsspChallenge method readBlockByDescription.
public static ByteBuffer readBlockByDescription(ByteBuffer buf) {
// In bytes
int blockLength = buf.readUnsignedShortLE();
int allocatedSpace = buf.readUnsignedShortLE();
int offset = buf.readSignedIntLE();
if (allocatedSpace < blockLength)
blockLength = allocatedSpace;
if (offset > buf.length || offset < 0 || offset + allocatedSpace > buf.length)
throw new RuntimeException("ERROR: NTLM block is too long. Allocated space: " + allocatedSpace + ", block offset: " + offset + ", data: " + buf + ".");
// Move cursor to position of allocated block, starting from beginning of
// this buffer
int storedCursor = buf.cursor;
buf.cursor = offset;
// Read string
ByteBuffer value = buf.readBytes(blockLength);
// Restore cursor
buf.cursor = storedCursor;
return value;
}
use of streamer.ByteBuffer in project cloudstack by apache.
the class ServerNtlmsspPubKeyPlus1 method handleOneTimeData.
@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();
// Ignore packet
switchOff();
}
use of streamer.ByteBuffer in project cloudstack by apache.
the class NtlmState method testConstructAuthenticateTargetInfo.
public void testConstructAuthenticateTargetInfo() {
serverNetbiosDomainName = "WIN-LO419B2LSR0";
serverNetbiosComputerName = "WIN-LO419B2LSR0";
serverDnsDomainName = "WIN-LO419B2LSR0";
serverDnsComputerName = "WIN-LO419B2LSR0";
serverTimestamp = new byte[] { (byte) 0xa0, (byte) 0xe8, (byte) 0x85, (byte) 0x2c, (byte) 0xe4, (byte) 0xc9, (byte) 0xce, (byte) 0x01 };
servicePrincipalName = "TERMSRV/192.168.1.3";
byte[] expected = new byte[] { (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[] actual = ntlm_construct_authenticate_target_info();
if (!Arrays.equals(expected, actual))
throw new RuntimeException("Incorrect result.\nExpected:\n" + new ByteBuffer(expected).toPlainHexString() + "\n actual:\n" + new ByteBuffer(actual).toPlainHexString() + ".");
}
Aggregations