-
Notifications
You must be signed in to change notification settings - Fork 67
Expand file tree
/
Copy pathPrivCheck.cna
More file actions
619 lines (512 loc) · 19 KB
/
PrivCheck.cna
File metadata and controls
619 lines (512 loc) · 19 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
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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
# PrivCheck.cna
# Privilege Escalation Check BOFs
# By @merterpreter && @nickvourd
# ============================================
# PrivCheck - Run All Checks
# ============================================
beacon_command_register(
"PrivCheck",
"Run all privilege escalation checks",
"Usage: PrivCheck\n\n" .
"Description:\n" .
" Executes all privilege escalation checks in sequence:\n" .
" - AlwaysInstallElevatedCheck\n" .
" - AutologonCheck\n" .
" - CredentialManagerCheck\n" .
" - HijackablePathCheck\n" .
" - ModifiableAutorunCheck\n" .
" - ModifiableSVCCheck\n" .
" - TokenPrivilegesCheck\n" .
" - UnquotedSVCPathCheck\n" .
" - PowerShellHistoryCheck\n" .
" - UACStatusCheck",
"bof"
);
alias PrivCheck {
local('$barch $handle $data $bofPath');
if (size(@_) > 1) {
berror($1, "This command does not accept arguments.");
berror($1, "Usage: PrivCheck");
return;
}
$barch = barch($1);
btask($1, "");
btask($1, "==================================================");
btask($1, " PrivCheck - Privilege Escalation Checks");
btask($1, " BOF by @merterpreter && @nickvourd");
btask($1, "==================================================");
btask($1, "");
# AlwaysInstallElevatedCheck
$bofPath = script_resource("AlwaysInstallElevatedCheck/AlwaysInstallElevatedCheck. $+ $barch $+ .o");
$handle = openf($bofPath);
$data = readb($handle, -1);
closef($handle);
if (strlen($data) > 0) {
btask($1, "[1/10] Running AlwaysInstallElevatedCheck...");
beacon_inline_execute($1, $data, "go", $null);
} else {
berror($1, "[1/10] Could not load AlwaysInstallElevatedCheck BOF");
}
# AutologonCheck
$bofPath = script_resource("AutologonCheck/AutologonCheck. $+ $barch $+ .o");
$handle = openf($bofPath);
$data = readb($handle, -1);
closef($handle);
if (strlen($data) > 0) {
btask($1, "[2/10] Running AutologonCheck...");
beacon_inline_execute($1, $data, "go", $null);
} else {
berror($1, "[2/10] Could not load AutologonCheck BOF");
}
# CredentialManagerCheck
$bofPath = script_resource("CredentialManagerCheck/CredentialManagerCheck. $+ $barch $+ .o");
$handle = openf($bofPath);
$data = readb($handle, -1);
closef($handle);
if (strlen($data) > 0) {
btask($1, "[3/10] Running CredentialManagerCheck...");
beacon_inline_execute($1, $data, "go", $null);
} else {
berror($1, "[3/10] Could not load CredentialManagerCheck BOF");
}
# HijackablePathCheck
$bofPath = script_resource("HijackablePathCheck/HijackablePathCheck. $+ $barch $+ .o");
$handle = openf($bofPath);
$data = readb($handle, -1);
closef($handle);
if (strlen($data) > 0) {
btask($1, "[4/10] Running HijackablePathCheck...");
beacon_inline_execute($1, $data, "go", $null);
} else {
berror($1, "[4/10] Could not load HijackablePathCheck BOF");
}
# ModifiableAutorunCheck
$bofPath = script_resource("ModifiableAutorunCheck/ModifiableAutorunCheck. $+ $barch $+ .o");
$handle = openf($bofPath);
$data = readb($handle, -1);
closef($handle);
if (strlen($data) > 0) {
btask($1, "[5/10] Running ModifiableAutorunCheck...");
beacon_inline_execute($1, $data, "go", $null);
} else {
berror($1, "[5/10] Could not load ModifiableAutorunCheck BOF");
}
# ModifiableSVCCheck
$bofPath = script_resource("ModifiableSVCCheck/ModifiableSVCCheck. $+ $barch $+ .o");
$handle = openf($bofPath);
$data = readb($handle, -1);
closef($handle);
if (strlen($data) > 0) {
btask($1, "[6/10] Running ModifiableSVCCheck...");
beacon_inline_execute($1, $data, "go", $null);
} else {
berror($1, "[6/10] Could not load ModifiableSVCCheck BOF");
}
# TokenPrivilegesCheck
$bofPath = script_resource("TokenPrivilegesCheck/TokenPrivilegesCheck. $+ $barch $+ .o");
$handle = openf($bofPath);
$data = readb($handle, -1);
closef($handle);
if (strlen($data) > 0) {
btask($1, "[7/10] Running TokenPrivilegesCheck...");
beacon_inline_execute($1, $data, "go", $null);
} else {
berror($1, "[7/10] Could not load TokenPrivilegesCheck BOF");
}
# UnquotedSVCPathCheck
$bofPath = script_resource("UnquotedSVCPathCheck/UnquotedSVCPathCheck. $+ $barch $+ .o");
$handle = openf($bofPath);
$data = readb($handle, -1);
closef($handle);
if (strlen($data) > 0) {
btask($1, "[8/10] Running UnquotedSVCPathCheck...");
beacon_inline_execute($1, $data, "go", $null);
} else {
berror($1, "[8/10] Could not load UnquotedSVCPathCheck BOF");
}
# PowerShellHistoryCheck
$bofPath = script_resource("PowerShellHistoryCheck/PowerShellHistoryCheck. $+ $barch $+ .o");
$handle = openf($bofPath);
$data = readb($handle, -1);
closef($handle);
if (strlen($data) > 0) {
btask($1, "[9/10] Running PowerShellHistoryCheck...");
beacon_inline_execute($1, $data, "go", $null);
} else {
berror($1, "[9/10] Could not load PowerShellHistoryCheck BOF");
}
# UACStatusCheck
$bofPath = script_resource("UACStatusCheck/UACStatusCheck. $+ $barch $+ .o");
$handle = openf($bofPath);
$data = readb($handle, -1);
closef($handle);
if (strlen($data) > 0) {
btask($1, "[10/10] Running UACStatusCheck...");
beacon_inline_execute($1, $data, "go", $null);
} else {
berror($1, "[10/10] Could not load UACStatusCheck BOF");
}
btask($1, "");
btask($1, "==================================================");
btask($1, " PrivCheck Complete");
btask($1, "==================================================");
}
# ============================================
# AlwaysInstallElevatedCheck
# ============================================
beacon_command_register(
"AlwaysInstallElevatedCheck",
"Check for AlwaysInstallElevated privilege escalation vulnerability",
"Usage: AlwaysInstallElevatedCheck\n\n" .
"Description:\n" .
" Checks if AlwaysInstallElevated is enabled in both HKCU and HKLM.\n" .
" This misconfiguration allows any user to install MSI packages with\n" .
" SYSTEM privileges.\n\n" .
"Vulnerability Conditions:\n" .
" HKCU\\Software\\Policies\\Microsoft\\Windows\\Installer\\AlwaysInstallElevated = 1\n" .
" HKLM\\Software\\Policies\\Microsoft\\Windows\\Installer\\AlwaysInstallElevated = 1\n\n" .
" Both keys must be set to 1 for exploitation.",
"bof"
);
alias AlwaysInstallElevatedCheck {
local('$barch $handle $data $bofPath');
if (size(@_) > 1) {
berror($1, "This command does not accept arguments.");
berror($1, "Usage: AlwaysInstallElevatedCheck");
return;
}
$barch = barch($1);
$bofPath = script_resource("AlwaysInstallElevatedCheck/AlwaysInstallElevatedCheck. $+ $barch $+ .o");
$handle = openf($bofPath);
$data = readb($handle, -1);
closef($handle);
if (strlen($data) == 0) {
berror($1, "Could not load BOF file: $bofPath");
return;
}
btask($1, "BOF by @merterpreter && @nickvourd");
btask($1, "Checking AlwaysInstallElevated privilege escalation vulnerability...");
beacon_inline_execute($1, $data, "go", $null);
}
# ============================================
# AutologonCheck
# ============================================
beacon_command_register(
"AutologonCheck",
"Check for stored Autologon credentials in registry",
"Usage: AutologonCheck\n\n" .
"Description:\n" .
" Checks the Winlogon registry key for stored autologon credentials.\n" .
" If AutoAdminLogon=1 and DefaultPassword is set, credentials are exposed.\n\n" .
"Registry Location:\n" .
" HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon",
"bof"
);
alias AutologonCheck {
local('$barch $handle $data $bofPath');
if (size(@_) > 1) {
berror($1, "This command does not accept arguments.");
berror($1, "Usage: AutologonCheck");
return;
}
$barch = barch($1);
$bofPath = script_resource("AutologonCheck/AutologonCheck. $+ $barch $+ .o");
$handle = openf($bofPath);
$data = readb($handle, -1);
closef($handle);
if (strlen($data) == 0) {
berror($1, "Could not load BOF file: $bofPath");
return;
}
btask($1, "BOF by @merterpreter && @nickvourd");
btask($1, "Checking for stored Autologon credentials...");
beacon_inline_execute($1, $data, "go", $null);
}
# ============================================
# CredentialManagerCheck
# ============================================
beacon_command_register(
"CredentialManagerCheck",
"Enumerate credentials from Windows Credential Manager",
"Usage: CredentialManagerCheck\n\n" .
"Description:\n" .
" Enumerates all stored credentials in Windows Credential Manager\n" .
" for the current user context. Shows target, username, and password.\n\n" .
"Note:\n" .
" Only enumerates credentials for the current user/token.\n" .
" Running as SYSTEM will not show user credentials.",
"bof"
);
alias CredentialManagerCheck {
local('$barch $handle $data $bofPath');
if (size(@_) > 1) {
berror($1, "This command does not accept arguments.");
berror($1, "Usage: CredentialManagerCheck");
return;
}
$barch = barch($1);
$bofPath = script_resource("CredentialManagerCheck/CredentialManagerCheck. $+ $barch $+ .o");
$handle = openf($bofPath);
$data = readb($handle, -1);
closef($handle);
if (strlen($data) == 0) {
berror($1, "Could not load BOF file: $bofPath");
return;
}
btask($1, "BOF by @merterpreter && @nickvourd");
btask($1, "Checking Credential Manager...");
beacon_inline_execute($1, $data, "go", $null);
}
# ============================================
# HijackablePathCheck
# ============================================
beacon_command_register(
"HijackablePathCheck",
"Check for writable directories in system PATH",
"Usage: HijackablePathCheck\n\n" .
"Description:\n" .
" Enumerates the system PATH environment variable and checks\n" .
" each directory for write permissions. Writable directories\n" .
" in PATH can be abused for DLL hijacking or binary planting.\n\n" .
"Registry Location:\n" .
" HKLM\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment\\Path",
"bof"
);
alias HijackablePathCheck {
local('$barch $handle $data $bofPath');
if (size(@_) > 1) {
berror($1, "This command does not accept arguments.");
berror($1, "Usage: HijackablePathCheck");
return;
}
$barch = barch($1);
$bofPath = script_resource("HijackablePathCheck/HijackablePathCheck. $+ $barch $+ .o");
$handle = openf($bofPath);
$data = readb($handle, -1);
closef($handle);
if (strlen($data) == 0) {
berror($1, "Could not load BOF file: $bofPath");
return;
}
btask($1, "BOF by @merterpreter && @nickvourd");
btask($1, "Checking for hijackable PATH directories...");
beacon_inline_execute($1, $data, "go", $null);
}
# ============================================
# ModifiableAutorunCheck
# ============================================
beacon_command_register(
"ModifiableAutorunCheck",
"Check for modifiable autorun executables",
"Usage: ModifiableAutorunCheck\n\n" .
"Description:\n" .
" Enumerates autorun registry keys and checks if the\n" .
" referenced executables are writable by current user.\n\n" .
"Checked Locations:\n" .
" HKLM and HKCU:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run\n" .
" HKLM and HKCU:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\RunOnce\n" .
" HKLM and HKCU:\\SOFTWARE\\Wow6432Node\\...\\Run (x64 systems)",
"bof"
);
alias ModifiableAutorunCheck {
local('$barch $handle $data $bofPath');
if (size(@_) > 1) {
berror($1, "This command does not accept arguments.");
berror($1, "Usage: ModifiableAutorunCheck");
return;
}
$barch = barch($1);
$bofPath = script_resource("ModifiableAutorunCheck/ModifiableAutorunCheck. $+ $barch $+ .o");
$handle = openf($bofPath);
$data = readb($handle, -1);
closef($handle);
if (strlen($data) == 0) {
berror($1, "Could not load BOF file: $bofPath");
return;
}
btask($1, "BOF by @merterpreter && @nickvourd");
btask($1, "Checking for modifiable autorun entries...");
beacon_inline_execute($1, $data, "go", $null);
}
# ============================================
# TokenPrivilegesCheck
# ============================================
beacon_command_register(
"TokenPrivilegesCheck",
"Enumerate current token privileges",
"Usage: TokenPrivilegesCheck\n\n" .
"Description:\n" .
" Enumerates all privileges for the current process token\n" .
" and shows their enabled/disabled status.",
"bof"
);
alias TokenPrivilegesCheck {
local('$barch $handle $data $bofPath');
if (size(@_) > 1) {
berror($1, "This command does not accept arguments.");
berror($1, "Usage: TokenPrivilegesCheck");
return;
}
$barch = barch($1);
$bofPath = script_resource("TokenPrivilegesCheck/TokenPrivilegesCheck. $+ $barch $+ .o");
$handle = openf($bofPath);
$data = readb($handle, -1);
closef($handle);
if (strlen($data) == 0) {
berror($1, "Could not load BOF file: $bofPath");
return;
}
btask($1, "BOF by @merterpreter && @nickvourd");
btask($1, "Enumerating token privileges...");
beacon_inline_execute($1, $data, "go", $null);
}
# ============================================
# UnquotedSVCPathCheck
# ============================================
beacon_command_register(
"UnquotedSVCPathCheck",
"Check for Unquoted Service Paths vulnerability",
"Usage: UnquotedSVCPathCheck\n\n" .
"Description:\n" .
" Enumerates Windows services and checks for unquoted paths\n" .
" containing spaces. These can be exploited for privilege escalation.\n\n" .
"Vulnerability Conditions:\n" .
" - Service path contains spaces\n" .
" - Path is not enclosed in quotes\n" .
" - Path is not in System32/SysWOW64",
"bof"
);
alias UnquotedSVCPathCheck {
local('$barch $handle $data $bofPath');
if (size(@_) > 1) {
berror($1, "This command does not accept arguments.");
berror($1, "Usage: UnquotedSVCPathCheck");
return;
}
$barch = barch($1);
$bofPath = script_resource("UnquotedSVCPathCheck/UnquotedSVCPathCheck. $+ $barch $+ .o");
$handle = openf($bofPath);
$data = readb($handle, -1);
closef($handle);
if (strlen($data) == 0) {
berror($1, "Could not load BOF file: $bofPath");
return;
}
btask($1, "BOF by @merterpreter && @nickvourd");
btask($1, "Checking for Unquoted Service Paths vulnerability...");
beacon_inline_execute($1, $data, "go", $null);
}
# ============================================
# PowerShellHistoryCheck
# ============================================
beacon_command_register(
"PowerShellHistoryCheck",
"Check for PowerShell history file",
"Usage: PowerShellHistoryCheck\n\n" .
"Description:\n" .
" Checks if the PowerShell PSReadLine history file exists.\n" .
" This file may contain sensitive commands, credentials, or secrets.\n\n" .
"File Location:\n" .
" %APPDATA%\\Microsoft\\Windows\\PowerShell\\PSReadLine\\ConsoleHost_history.txt",
"bof"
);
alias PowerShellHistoryCheck {
local('$barch $handle $data $bofPath');
if (size(@_) > 1) {
berror($1, "This command does not accept arguments.");
berror($1, "Usage: PowerShellHistoryCheck");
return;
}
$barch = barch($1);
$bofPath = script_resource("PowerShellHistoryCheck/PowerShellHistoryCheck. $+ $barch $+ .o");
$handle = openf($bofPath);
$data = readb($handle, -1);
closef($handle);
if (strlen($data) == 0) {
berror($1, "Could not load BOF file: $bofPath");
return;
}
btask($1, "BOF by @merterpreter && @nickvourd");
btask($1, "Checking for PowerShell history file...");
beacon_inline_execute($1, $data, "go", $null);
}
# ============================================
# UACStatusCheck
# ============================================
beacon_command_register(
"UACStatusCheck",
"Check UAC status, integrity level, and admin membership",
"Usage: UACStatusCheck\n\n" .
"Description:\n" .
" Checks UAC registry settings, current process integrity level,\n" .
" and local administrator group membership.\n\n" .
"Checks Performed:\n" .
" - EnableLUA (UAC enabled/disabled)\n" .
" - ConsentPromptBehaviorAdmin (UAC prompt level)\n" .
" - PromptOnSecureDesktop\n" .
" - Token Integrity Level\n" .
" - Local Administrators group membership",
"bof"
);
alias UACStatusCheck {
local('$barch $handle $data $bofPath');
if (size(@_) > 1) {
berror($1, "This command does not accept arguments.");
berror($1, "Usage: UACStatusCheck");
return;
}
$barch = barch($1);
$bofPath = script_resource("UACStatusCheck/UACStatusCheck. $+ $barch $+ .o");
$handle = openf($bofPath);
$data = readb($handle, -1);
closef($handle);
if (strlen($data) == 0) {
berror($1, "Could not load BOF file: $bofPath");
return;
}
btask($1, "BOF by @merterpreter && @nickvourd");
btask($1, "Checking UAC status, integrity level, and admin membership...");
beacon_inline_execute($1, $data, "go", $null);
}
# ============================================
# ModifiableSVCCheck
# ============================================
beacon_command_register(
"ModifiableSVCCheck",
"Check for services with modifiable permissions",
"Usage: ModifiableSVCCheck\n\n" .
"Description:\n" .
" Enumerates all Windows services and checks their security\n" .
" descriptors to find services that the current user can modify.\n\n" .
"Checked Permissions:\n" .
" - SERVICE_CHANGE_CONFIG\n" .
" - WRITE_DAC\n" .
" - WRITE_OWNER\n" .
" - GENERIC_ALL\n" .
" - GENERIC_WRITE\n" .
" - SERVICE_ALL_ACCESS\n\n" .
"Exploitation:\n" .
" If a service is modifiable, you can change its binary path\n" .
" to point to a malicious executable for privilege escalation.",
"bof"
);
alias ModifiableSVCCheck {
local('$barch $handle $data $bofPath');
if (size(@_) > 1) {
berror($1, "This command does not accept arguments.");
berror($1, "Usage: ModifiableSVCCheck");
return;
}
$barch = barch($1);
$bofPath = script_resource("ModifiableSVCCheck/ModifiableSVCCheck. $+ $barch $+ .o");
$handle = openf($bofPath);
$data = readb($handle, -1);
closef($handle);
if (strlen($data) == 0) {
berror($1, "Could not load BOF file: $bofPath");
return;
}
btask($1, "BOF by @merterpreter && @nickvourd");
btask($1, "Checking for modifiable services...");
beacon_inline_execute($1, $data, "go", $null);
}