-
Notifications
You must be signed in to change notification settings - Fork 54
Expand file tree
/
Copy pathUtils.cpp
More file actions
42 lines (35 loc) · 1.02 KB
/
Utils.cpp
File metadata and controls
42 lines (35 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "Utils.h"
bool parseArgument(const std::wstring& arg, std::wstring& domain, std::wstring& user, std::wstring& password, std::wstring& address) {
if (arg == LOCAL_ATTACK_KEYWORD)
{
domain = L"";
user = L"";
password = L"";
address = L"";
return true;
}
// Regular expression to match the format [domain]\[user]:[password]@[address]
std::wregex pattern(LR"(([^\\]+)\\([^:]+):([^@]+)@(.+))");
std::wsmatch match;
if (std::regex_match(arg, match, pattern)) {
// Assign parsed values to the respective variables
domain = match[1];
user = match[2];
password = match[3];
address = match[4];
return true;
}
return false;
}
size_t GetEnvironmentSizeW(WCHAR* pchEnvironment)
{
WCHAR* cur = pchEnvironment;
do {
// scan for the end of the string
while (*cur != '\0')
cur++;
// move past null
cur++;
} while (*cur != '\0');
return cur - pchEnvironment + 1;
}