Skip to content

Commit 1b6ab48

Browse files
authored
Update FIDO2.1 Manager.cpp
allow chars like @&*! (add escape function for PIN)
1 parent f37dc16 commit 1b6ab48

File tree

1 file changed

+41
-1
lines changed

1 file changed

+41
-1
lines changed

FIDO2.1 Manager.cpp

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#define ID_REFRESH_BUTTON 103
1414

1515
// Global string variable
16-
std::wstring globalPin = L"111";
16+
std::wstring globalPin = L"0000";
1717
std::wstring deviceNumber = L"";
1818

1919
HINSTANCE hInst;
@@ -25,6 +25,45 @@ struct PasskeyInfo {
2525
std::wstring domain;
2626
};
2727

28+
std::wstring EscapeCommandLineArgument(const std::wstring& input) {
29+
std::wstring escaped = L"\""; // Start with a quote to properly handle spaces
30+
31+
for (wchar_t ch : input) {
32+
switch (ch) {
33+
case L'"': escaped += L"\\\""; break; // Escape double quotes
34+
case L'^':
35+
case L'&':
36+
case L'|':
37+
case L'<':
38+
case L'>':
39+
case L'%':
40+
case L'!':
41+
case L'(':
42+
case L')':
43+
case L'=':
44+
case L';':
45+
case L'`':
46+
case L',':
47+
case L'[':
48+
case L']':
49+
case L'{':
50+
case L'}':
51+
case L'*':
52+
case L'?':
53+
case L'\\': // Escape special characters for CMD
54+
escaped += L'^';
55+
escaped += ch;
56+
break;
57+
default:
58+
escaped += ch;
59+
}
60+
}
61+
62+
escaped += L"\""; // End with a quote
63+
return escaped;
64+
}
65+
66+
2867

2968
// Function to execute a command and capture its output
3069
std::vector<std::wstring> RunCommandAndGetOutput(const std::wstring& command) {
@@ -659,6 +698,7 @@ void PopulateListView(HWND hwnd, const std::wstring& deviceNumber) {
659698
DisableAllButtons(hwnd);
660699
// Show the input box and store the result in globalPIN
661700
globalPin = ShowInputBox(NULL, L"Enter PIN", L"Please enter your PIN:");
701+
globalPin = EscapeCommandLineArgument(globalPin);
662702

663703
const size_t MIN_PIN_LENGTH = 4;
664704

0 commit comments

Comments
 (0)