Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Cant encrypt password into hex for RDP

Options
  • 06-04-2012 9:41pm
    #1
    Registered Users Posts: 7,861 ✭✭✭


    Hi folks,
    Been stuck on this problem for days, and just hoping someone on here has had experience doing this.

    I'm trying to create a program that reads user/pass from a file, and generates a .RDP file for use with Remote Desktop in Windows. In this .RDP file, the password field needs to store the password encrypted, not plain text. I've been trying to encrypt it properly for days but just can't get it correct. Its close, but still wrong.

    Here's an example of a correct / RDP file:
    http://www.remkoweijnen.nl/blog/2007/10/18/how-rdp-passwords-are-encrypted/

    There's code there for C# and delphi I think, but nothing for Java. I've tried porting the C# code, and using crypt32.dll which Windows uses to encrypt the password using a function called CryptProtectData(), but I've had no luck at all.

    also, in that link, the guy made a little program to encrypt/decrypt the passwords. Its at the bottom of the blog post. When I use the tool, my .RDP file can be used to log in correctly, but when I generate the encrypted password, Remote desktop tells me the password is wrong, so I'm sure its just that I'm encrypting it wrong.

    Here is what I am doing at the moment:
    String password = "Passw0rd";
    net.sourceforge.jdpapi.DataProtector protector = new net.sourceforge.jdpapi.DataProtector();
    String hexPass1 = protector.protect(password).toString();
    System.out.println("hexPass1: "+hexPass1);
    org.apache.commons.codec.binary.Base64 base64 = new org.apache.commons.codec.binary.Base64();
    byte[] temp = base64.encode(hexPass1.getBytes());
    System.out.println("hexPassTemp: "+temp);
    String temp2 = Hex.encodeHexString(protector.protect(temp.toString()));
    System.out.println("hexPassTemp2: "+temp2);
    



    This one small little thing has me stuck for practically the whole week, so I'd be very very grateful if anyone could help me out here.

    Cheers.


Advertisement