Dirk Schmitz send me his Python version of encrypting the RDP Password:
python
Download
import win32crypt
import binascii
pwdHash = win32crypt.CryptProtectData(u"MYPASSWORD",u'psw',None,None,None,0)
print binascii.hexlify(pwdHash)
Read the original article here: /2007/10/18/how-rdp-passwords-are-encrypted/
Thank's, this really worked well, after a bit of fiddling (donation will be given asap). For Python 2.7 I had to remove the unicode conversion, otherwise the RDP server would not get the proper password. Interestingly your updated post about 512-byte padding and appending a '0'-character to obtain a 1329 'password 51'-hash did not work for me yet. Did you need the padding as a bugfix or did you suggest it merely as an imrovement to become fully compatible to the MS encoding format? (/2008/03/02/how-rdp-passwords-are-encrypted-2/).
@Arvid: to become fully compliant, it works either way
Ok, just for the records: didn't recall my code correctly: indeed I also apply unicode(password), just the padding did not work yet (spaces or charcter "0"? never mind..).
[...] Encrypt RDP password in Python (includes source) [...]
[…] Encrypt RDP password in Python (includes source) […]