Skip to content

Commit

Permalink
add: Add crdreader
Browse files Browse the repository at this point in the history
  • Loading branch information
Awayume committed Mar 29, 2024
1 parent 3a7cb72 commit 2411c92
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.PHONY: build

CC := x86_64-w64-mingw32-gcc-win32
CFLAGS := -static -Wall -Wextra
TARGET := crdreader.exe
SRCS := src/crdreader.c

build:
$(CC) -o $(TARGET) $(SRCS)
40 changes: 40 additions & 0 deletions src/crdreader.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// SPDX-FileCopyrightText: 2024 Awayume <[email protected]>
// SPDX-License-Identifier: MIT

#include <stdio.h>

#include <windows.h>
#include <wincred.h>


int main() {
DWORD count;
PCREDENTIAL* credentials;

if (!CredEnumerate(NULL, 0, &count, &credentials)) {
char message[] = "[ERROR] Failed to enumerate credentials:";
switch (GetLastError()) {
case 1168:
printf("%s ERROR_NOT_FOUND (0x490)\n", message);
case 1312:
printf("%s ERROR_NO_SUCH_LOGON_SESSION (0x520)\n", message);
case 1004:
printf("%s ERROR_INVALID_FLAGS (0x3EC)\n", message);
defaut:
printf("%sUnknown error\n", message);
}
return 255;
}

if (count == 0) {
printf("No credentials found!\n");
return 0;
}

printf("Credentials (total %d):\n", count);
for (DWORD i = 0; i < count; i++) {
LPSTR key = credentials[i]->TargetName;
LPBYTE value = credentials[i]->CredentialBlob;
printf(" %s: %s\n", key, value);
}
}

0 comments on commit 2411c92

Please sign in to comment.