Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Cant encrypt password into hex for RDP

  • 06-04-2012 09:41PM
    #1
    Registered Users, Registered Users 2, Paid Member Posts: 8,000 ✭✭✭
    Something about sandwiches


    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