c# - Decrypt Windows Credential Files -


i'm project need manage (write/read) cached credentials. in case, specially (termsrv) or popular known remote desktop.

on windows 7, discovered files stored in "appdata\local\microsoft\credentials". when open mstsc (remote desktop client), , save credential, new file (occult , protected system) created on dir. tried open file on notepad, , it's encrypted data. saw, looks windows use data protection api(dpapi), cryptprotectdata/cryptunprotectdata functions, save/retrieve cached credentials.

my first try, on credread function, discovered domain passwords (cred_type_domain_password - type terminal services), can read authentication packages. after discover, started searching tools, , found people injecting dll lsass process, job. saw nirsoft netpass decrypt saved passwords, , through process explorer, didn't saw new dll injected on lsass. looks works directly on credential file using cryptunprotectdata.

the question is: there anyway retrieve cached passwords, file, without need inject dll , kind of stuff? if yes, way cryptunprotectdata? finally, if yes, data_blob function receives? content of file? can't understand how use function, take blob?

edit::

i posted question on windows/winapi tags only, no views , no answers. believe main question, language independent, i'm doing project in delphi, here goes delphi code credread, gets username, can't list password, because account domain type (cred_type_domain_password)

type  pcredential_attributew = ^_credential_attributew;   _credential_attributew = record     keyword: lpwstr;     flags: dword;     valuesize: dword;     value: lpbyte;   end;     pcredentialw = ^_credentialw;   _credentialw = record     flags: dword;     type_: dword;     targetname: lpwstr;     comment: lpwstr;     lastwritten: filetime;     credentialblobsize: dword;     credentialblob: lpbyte;     persist: dword;     attributecount: dword;     attributes: pcredential_attributew;     targetalias: lpwstr;     username: lpwstr;   end;  pcredentialarray = array of pcredentialw;  const   cred_type_generic                 = 1;   cred_type_domain_password         = 2;   cred_type_domain_certificate      = 3;   cred_type_domain_visible_password = 4;   cred_type_maximum                 = 5;  // maximum supported cred type   cred_type_maximum_ex              = cred_type_maximum + 1000;  // allow new applications run on old oses  var   form1: tform1;  function credreadw(targetname: lpcwstr; type_: dword; flags: dword; var credential: pcredentialw): bool; stdcall; external 'advapi32.dll'; function credenumeratew(filter: lpcwstr; flags: dword; out count: dword; out credential: pcredentialarray): bool; stdcall; external 'advapi32.dll';  implementation  {$r *.dfm}  procedure tform1.formcreate(sender: tobject); var   credentials: pcredentialarray;   credential: pcredentialw;   username: widestring;   i: integer;   dwcount: dword; begin     if credenumeratew(pchar('term*'), 0, dwcount, credentials)     begin       i:= 0 dwcount - 1          begin             if credreadw(credentials[i].targetname, credentials[i].type_, 0, credential)             begin               username:= credential.username;               memo1.lines.add(credentials[i].targetname + ' :: ' + username + ' >> ' + inttostr(credentials[i].type_));               memo1.lines.add(inttostr(credential.credentialblobsize));             end;         end;     end; end; 


Comments

Popular posts from this blog

searchKeyword not working in AngularJS filter -

sequelize.js - Sequelize: sort by enum cases -

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -