Skip to content

Commit 2411c92

Browse files
committed
add: Add crdreader
1 parent 3a7cb72 commit 2411c92

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

Makefile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.PHONY: build
2+
3+
CC := x86_64-w64-mingw32-gcc-win32
4+
CFLAGS := -static -Wall -Wextra
5+
TARGET := crdreader.exe
6+
SRCS := src/crdreader.c
7+
8+
build:
9+
$(CC) -o $(TARGET) $(SRCS)

src/crdreader.c

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// SPDX-FileCopyrightText: 2024 Awayume <[email protected]>
2+
// SPDX-License-Identifier: MIT
3+
4+
#include <stdio.h>
5+
6+
#include <windows.h>
7+
#include <wincred.h>
8+
9+
10+
int main() {
11+
DWORD count;
12+
PCREDENTIAL* credentials;
13+
14+
if (!CredEnumerate(NULL, 0, &count, &credentials)) {
15+
char message[] = "[ERROR] Failed to enumerate credentials:";
16+
switch (GetLastError()) {
17+
case 1168:
18+
printf("%s ERROR_NOT_FOUND (0x490)\n", message);
19+
case 1312:
20+
printf("%s ERROR_NO_SUCH_LOGON_SESSION (0x520)\n", message);
21+
case 1004:
22+
printf("%s ERROR_INVALID_FLAGS (0x3EC)\n", message);
23+
defaut:
24+
printf("%sUnknown error\n", message);
25+
}
26+
return 255;
27+
}
28+
29+
if (count == 0) {
30+
printf("No credentials found!\n");
31+
return 0;
32+
}
33+
34+
printf("Credentials (total %d):\n", count);
35+
for (DWORD i = 0; i < count; i++) {
36+
LPSTR key = credentials[i]->TargetName;
37+
LPBYTE value = credentials[i]->CredentialBlob;
38+
printf(" %s: %s\n", key, value);
39+
}
40+
}

0 commit comments

Comments
 (0)