Search in sources :

Example 1 with TSRequest

use of rdpclient.ntlmssp.asn1.TSRequest in project cloudstack by apache.

the class ClientNtlmsspNegotiate method onStart.

@Override
protected void onStart() {
    super.onStart();
    ByteBuffer negoToken = generateNegotiateMessage();
    // Store message for MIC calculation in AUTH message
    ntlmState.negotiateMessage = negoToken.toByteArray();
    // Length of packet
    ByteBuffer buf = new ByteBuffer(1024, true);
    TSRequest tsRequest = new TSRequest("TSRequest");
    tsRequest.version.value = 2L;
    NegoItem negoItem = new NegoItem("NegoItem");
    negoItem.negoToken.value = negoToken;
    tsRequest.negoTokens.tags = new Tag[] { negoItem };
    tsRequest.writeTag(buf);
    // Trim buffer to actual length of data written
    buf.trimAtCursor();
    pushDataToOTOut(buf);
    switchOff();
}
Also used : NegoItem(rdpclient.ntlmssp.asn1.NegoItem) ByteBuffer(streamer.ByteBuffer) TSRequest(rdpclient.ntlmssp.asn1.TSRequest)

Example 2 with TSRequest

use of rdpclient.ntlmssp.asn1.TSRequest in project cloudstack by apache.

the class ClientNtlmsspPubKeyAuth method dump.

@Override
public void dump(ByteBuffer buf) {
    buf.rewindCursor();
    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();
}
Also used : TSRequest(rdpclient.ntlmssp.asn1.TSRequest) ByteBuffer(streamer.ByteBuffer)

Example 3 with TSRequest

use of rdpclient.ntlmssp.asn1.TSRequest 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();
}
Also used : TSRequest(rdpclient.ntlmssp.asn1.TSRequest) ByteBuffer(streamer.ByteBuffer)

Example 4 with TSRequest

use of rdpclient.ntlmssp.asn1.TSRequest in project cloudstack by apache.

the class ClientNtlmsspUserCredentials method onStart.

@Override
protected void onStart() {
    super.onStart();
    ByteBuffer buf = new ByteBuffer(4096, true);
    TSRequest tsRequest = new TSRequest("TSRequest");
    tsRequest.version.value = 2L;
    ByteBuffer tsCredentialsBuf = generateTSCredentials();
    tsRequest.authInfo.value = encryptTSCredentials(tsCredentialsBuf);
    tsCredentialsBuf.unref();
    tsRequest.writeTag(buf);
    // Trim buffer to actual length of data written
    buf.trimAtCursor();
    pushDataToOTOut(buf);
    switchOff();
}
Also used : ByteBuffer(streamer.ByteBuffer) TSRequest(rdpclient.ntlmssp.asn1.TSRequest)

Example 5 with TSRequest

use of rdpclient.ntlmssp.asn1.TSRequest in project cloudstack by apache.

the class ClientNtlmsspPubKeyAuth method onStart.

@Override
protected void onStart() {
    super.onStart();
    /*
         * @see
         * http://blogs.msdn.com/b/openspecification/archive/2010/04/20/ntlm-keys
         * -and-sundry-stuff.aspx
         */
    ntlmState.domain = targetDomain;
    ntlmState.user = user;
    ntlmState.password = password;
    ntlmState.workstation = workstation;
    ntlmState.generateServicePrincipalName(serverHostName);
    ntlmState.ntlm_construct_authenticate_target_info();
    ntlmState.ntlm_generate_timestamp();
    ntlmState.ntlm_generate_client_challenge();
    ntlmState.ntlm_compute_lm_v2_response();
    ntlmState.ntlm_compute_ntlm_v2_response();
    ntlmState.ntlm_generate_key_exchange_key();
    ntlmState.ntlm_generate_random_session_key();
    ntlmState.ntlm_generate_exported_session_key();
    ntlmState.ntlm_encrypt_random_session_key();
    ntlmState.ntlm_init_rc4_seal_states();
    ByteBuffer authenticateMessage = generateAuthenticateMessage(ntlmState);
    ByteBuffer messageSignatureAndEncryptedServerPublicKey = generateMessageSignatureAndEncryptedServerPublicKey(ntlmState);
    // Length of packet
    ByteBuffer buf = new ByteBuffer(4096, true);
    TSRequest tsRequest = new TSRequest("TSRequest");
    tsRequest.version.value = 2L;
    NegoItem negoItem = new NegoItem("NegoItem");
    negoItem.negoToken.value = authenticateMessage;
    tsRequest.negoTokens.tags = new Tag[] { negoItem };
    tsRequest.pubKeyAuth.value = messageSignatureAndEncryptedServerPublicKey;
    tsRequest.writeTag(buf);
    // Trim buffer to actual length of data written
    buf.trimAtCursor();
    pushDataToOTOut(buf);
    switchOff();
}
Also used : NegoItem(rdpclient.ntlmssp.asn1.NegoItem) ByteBuffer(streamer.ByteBuffer) TSRequest(rdpclient.ntlmssp.asn1.TSRequest)

Aggregations

TSRequest (rdpclient.ntlmssp.asn1.TSRequest)6 ByteBuffer (streamer.ByteBuffer)6 NegoItem (rdpclient.ntlmssp.asn1.NegoItem)2