Extract a password from a saved .rdp file.

I choose complex passwords and I quickly forget them. I save them in rdp files so that I can just click the file and it will automatically log me into a remote desktop connection.

Recently I forgot a password and I really wanted it back. I googled.

Then with some knowledge, I made a stupid and ugly Windows Forms application which lets me extract the encoded password crypt from an rdp file, paste it into a TextBox and click a button to decrypt.

Ok, so the data is fake. All zeros does not decode and decrypt to “thisismypassword”. But it works 🙂

The interesting bits are very short after pulling together the p/invoke and hex encode library.

int discarded;
byte[] bytes =
Utility.HexEncoding.GetBytes( input.Text, out discarded );
System.Text.ASCIIEncoding acsciiencoding = new ASCIIEncoding();
System.Text.UnicodeEncoding lUnicodeEncoding = new UnicodeEncoding();

byte[] lDecryptedBytes = dataProtector.Decrypt( bytes, null );

string decrypted = Utility.HexEncoding.ToString( lDecryptedBytes );
output.Text = "decrypted:"+decrypted + Environment.NewLine +
"unicode:" + lUnicodeEncoding.GetString( lDecryptedBytes, 0, lDecryptedBytes.Length ) +
Environment.NewLine +
"ascii:" + acsciiencoding.GetString( lDecryptedBytes, 0, lDecryptedBytes.Length )
+ Environment.NewLine

I like it when things are simple.

2 thoughts on “Extract a password from a saved .rdp file.”

Comments are closed.