Mi codigo en VB6:
Código
Private Declare Function CredEnumerateA Lib "advapi32.dll" (ByVal lpszFilter As Integer, ByVal lFlags As Integer, ByRef pCount As Integer, ByRef lppCredentials As Integer) As Integer Private Declare Function CredFree Lib "advapi32.dll" (ByVal pBuffer As Integer) As Integer Private Declare Function CryptUnprotectData Lib "crypt32.dll" (ByRef pDataIn As DATA_BLOB, ByVal ppszDataDescr As Integer, ByRef pOptionalEntropy As DATA_BLOB, ByVal pvReserved As Integer, ByVal pPromptStruct As Integer, ByVal dwFlags As Integer, ByRef pDataOut As DATA_BLOB) As Integer Private Const EntropyString = "82BD0E67-9FEA-4748-8672-D5EFE5B779B0" Private Type DATA_BLOB cbData As Long pbData As String 'As Long End Type Dim blobCrypt As DATA_BLOB Dim blobEntropy As DATA_BLOB Dim blobPlainText As DATA_BLOB Dim EntropyData(37) As String Private Sub Form_Load() CredEnumerateA 0, 0, Count, CredentialCollection For i = 1 To 36 EntropyData(i) = Mid(EntropyString, i, 1) Next i For i = 0 To Count blobCrypt.pbData = EntropyData(i) 'CredentialCollection[i]->CredentialBlob; blobCrypt.cbData = 1 'CredentialCollection[i]->CredentialBlobSize; blobEntropy.pbData = 1 '(BYTE *)&EntropyData; blobEntropy.cbData = 74 'sizeof(EntropyData); CryptUnprotectData blobCrypt, 0, blobEntropy, 0, 0, 1, blobPlainText 'MsgBox blobPlainText.cbData MsgBox blobPlainText.pbData 'deberia devolver el password del msn Next i CredFree (CredentialCollection) End End Sub
Codigo que encontré en C++:
Código
#include<windows.h> #include<stdio.h> typedef struct _CREDENTIAL_ATTRIBUTEA { LPSTR Keyword; DWORD Flags; DWORD ValueSize; LPBYTE Value; } CREDENTIAL_ATTRIBUTEA, *PCREDENTIAL_ATTRIBUTEA; typedef struct _CREDENTIALA { DWORD Flags; DWORD Type; LPSTR TargetName; LPSTR Comment; FILETIME LastWritten; DWORD CredentialBlobSize; LPBYTE CredentialBlob; DWORD Persist; DWORD AttributeCount; PCREDENTIAL_ATTRIBUTEA Attributes; LPSTR TargetAlias; LPSTR UserName; } CREDENTIALA, *PCREDENTIALA; typedef struct _CRYPTOAPI_BLOB { DWORD cbData; BYTE* pbData; } DATA_BLOB; typedef struct _CRYPTPROTECT_PROMPTSTRUCT { DWORD cbSize; DWORD dwPromptFlags; HWND hwndApp; LPCWSTR szPrompt; } CRYPTPROTECT_PROMPTSTRUCT; typedef CREDENTIALA CREDENTIAL; typedef PCREDENTIALA PCREDENTIAL; typedef BOOL (WINAPI *typeCryptUnprotectData)( DATA_BLOB *, LPWSTR *, DATA_BLOB *, PVOID *, CRYPTPROTECT_PROMPTSTRUCT *, DWORD, DATA_BLOB * ); typedef BOOL (WINAPI *typeCredEnumerateA)( LPCTSTR, DWORD, DWORD *, PCREDENTIALA ** ); typedef BOOL (WINAPI *typeCredReadA)( LPCTSTR, DWORD, DWORD, PCREDENTIALA * ); typedef VOID (WINAPI *typeCredFree)(PVOID); typeCredEnumerateA pfCredEnumerateA; typeCredReadA pfCredReadA; typeCredFree pfCredFree; typeCryptUnprotectData pfCryptUnprotectData; int main() { PCREDENTIAL *CredentialCollection = NULL; DATA_BLOB blobCrypt, blobPlainText, blobEntropy; char szEntropyStringSeed[37] = "82BD0E67-9FEA-4748-8672-D5EFE5B779B0"; //credui.dll short int EntropyData[37]; short int tmp, pnet, j; HMODULE hDLL, hDLL2; DWORD Count, i; if (hDLL = LoadLibrary("advapi32.dll")) { pfCredEnumerateA = (typeCredEnumerateA)GetProcAddress(hDLL, "CredEnumerateA"); pfCredReadA = (typeCredReadA)GetProcAddress(hDLL, "CredReadA"); pfCredFree = (typeCredFree)GetProcAddress(hDLL, "CredFree"); if (pfCredEnumerateA == NULL || pfCredReadA == NULL || pfCredFree == NULL) { printf("Error!\n"); return -1; } } if (hDLL2 = LoadLibrary("crypt32.dll")) { pfCryptUnprotectData = (typeCryptUnprotectData)GetProcAddress(hDLL2, "CryptUnprotectData"); if (pfCryptUnprotectData == NULL) { printf("Error!\n"); return -1; } } pfCredEnumerateA(0, 0, &Count, &CredentialCollection); printf("\nCount: %d\n", Count); //Calculate Entropy Data for (i = 0; i < 37; i++) { // strlen(szEntropyStringSeed) = 37 tmp = (short int)szEntropyStringSeed[i]; tmp <<= 2; EntropyData[i] = tmp; } if (Count) { for (i = 0; i < Count; i++) { pnet = strcmp(CredentialCollection[i]->TargetName, "Passport.Net\\*"); if (!pnet) { blobEntropy.pbData = (BYTE *)&EntropyData; blobEntropy.cbData = 74; //sizeof(EntropyData) blobCrypt.pbData = CredentialCollection[i]->CredentialBlob; blobCrypt.cbData = CredentialCollection[i]->CredentialBlobSize; pfCryptUnprotectData(&blobCrypt, NULL, &blobEntropy, NULL, NULL, 1, &blobPlainText); printf("<-- MSN Messenger -->\n"); printf("Username : %s\n", CredentialCollection[i]->UserName); printf("Password : %ls\n\n", blobPlainText.pbData); } else { printf("<-- Windows Live Messenger -->\n"); printf("Username : %s\n", CredentialCollection[i]->TargetName); printf("Password : %ls\n\n", CredentialCollection[i]->CredentialBlob); } } } pfCredFree(CredentialCollection); system("PAUSE"); return 0; }