@@ -69,57 +69,62 @@ ECHO.
6969CALL :T_Progress 2
7070
7171:ListHotFixes
72- wmic qfe get Caption,Description,HotFixID,InstalledOn | more
72+ where wmic > nul 2 >& 1
73+ if %errorlevel% equ 0 (
74+ wmic qfe get Caption,Description,HotFixID,InstalledOn | more
75+ ) else (
76+ powershell -command " Get-HotFix | Format-Table -AutoSize"
77+ )
7378set expl = no
7479for /f " tokens=3-9" %%a in ('systeminfo') do (ECHO." %%a %%b %%c %%d %%e %%f %%g " | findstr /i " 2000 XP 2003 2008 vista" && set expl = yes) & (ECHO." %%a %%b %%c %%d %%e %%f %%g " | findstr /i /C:" windows 7" && set expl = yes)
7580IF " %expl% " == " yes" ECHO . [i] Possible exploits (https://github.com/codingo/OSCP-2/blob/master/Windows/WinPrivCheck.bat)
76- IF " %expl% " == " yes" wmic qfe get Caption,Description,HotFixID,InstalledOn | findstr /C:" KB2592799" 1 > NUL
81+ IF " %expl% " == " yes" wmic qfe get Caption,Description,HotFixID,InstalledOn 2 > nul | findstr /C:" KB2592799" 1 > NUL
7782IF " %expl% " == " yes" IF errorlevel 1 ECHO .MS11-080 patch is NOT installed! (Vulns: XP/SP3,2K3/SP3-afd.sys)
78- IF " %expl% " == " yes" wmic qfe get Caption,Description,HotFixID,InstalledOn | findstr /C:" KB3143141" 1 > NUL
83+ IF " %expl% " == " yes" wmic qfe get Caption,Description,HotFixID,InstalledOn 2 > nul | findstr /C:" KB3143141" 1 > NUL
7984IF " %expl% " == " yes" IF errorlevel 1 ECHO .MS16-032 patch is NOT installed! (Vulns: 2K8/SP1/2,Vista/SP2,7/SP1-secondary logon)
80- IF " %expl% " == " yes" wmic qfe get Caption,Description,HotFixID,InstalledOn | findstr /C:" KB2393802" 1 > NUL
85+ IF " %expl% " == " yes" wmic qfe get Caption,Description,HotFixID,InstalledOn 2 > nul | findstr /C:" KB2393802" 1 > NUL
8186IF " %expl% " == " yes" IF errorlevel 1 ECHO .MS11-011 patch is NOT installed! (Vulns: XP/SP2/3,2K3/SP2,2K8/SP2,Vista/SP1/2,7/SP0-WmiTraceMessageVa)
82- IF " %expl% " == " yes" wmic qfe get Caption,Description,HotFixID,InstalledOn | findstr /C:" KB982799" 1 > NUL
87+ IF " %expl% " == " yes" wmic qfe get Caption,Description,HotFixID,InstalledOn 2 > nul | findstr /C:" KB982799" 1 > NUL
8388IF " %expl% " == " yes" IF errorlevel 1 ECHO .MS10-59 patch is NOT installed! (Vulns: 2K8,Vista,7/SP0-Chimichurri)
84- IF " %expl% " == " yes" wmic qfe get Caption,Description,HotFixID,InstalledOn | findstr /C:" KB979683" 1 > NUL
89+ IF " %expl% " == " yes" wmic qfe get Caption,Description,HotFixID,InstalledOn 2 > nul | findstr /C:" KB979683" 1 > NUL
8590IF " %expl% " == " yes" IF errorlevel 1 ECHO .MS10-21 patch is NOT installed! (Vulns: 2K/SP4,XP/SP2/3,2K3/SP2,2K8/SP2,Vista/SP0/1/2,7/SP0-Win Kernel)
86- IF " %expl% " == " yes" wmic qfe get Caption,Description,HotFixID,InstalledOn | findstr /C:" KB2305420" 1 > NUL
91+ IF " %expl% " == " yes" wmic qfe get Caption,Description,HotFixID,InstalledOn 2 > nul | findstr /C:" KB2305420" 1 > NUL
8792IF " %expl% " == " yes" IF errorlevel 1 ECHO .MS10-092 patch is NOT installed! (Vulns: 2K8/SP0/1/2,Vista/SP1/2,7/SP0-Task Sched)
88- IF " %expl% " == " yes" wmic qfe get Caption,Description,HotFixID,InstalledOn | findstr /C:" KB981957" 1 > NUL
93+ IF " %expl% " == " yes" wmic qfe get Caption,Description,HotFixID,InstalledOn 2 > nul | findstr /C:" KB981957" 1 > NUL
8994IF " %expl% " == " yes" IF errorlevel 1 ECHO .MS10-073 patch is NOT installed! (Vulns: XP/SP2/3,2K3/SP2/2K8/SP2,Vista/SP1/2,7/SP0-Keyboard Layout)
90- IF " %expl% " == " yes" wmic qfe get Caption,Description,HotFixID,InstalledOn | findstr /C:" KB4013081" 1 > NUL
95+ IF " %expl% " == " yes" wmic qfe get Caption,Description,HotFixID,InstalledOn 2 > nul | findstr /C:" KB4013081" 1 > NUL
9196IF " %expl% " == " yes" IF errorlevel 1 ECHO .MS17-017 patch is NOT installed! (Vulns: 2K8/SP2,Vista/SP2,7/SP1-Registry Hive Loading)
92- IF " %expl% " == " yes" wmic qfe get Caption,Description,HotFixID,InstalledOn | findstr /C:" KB977165" 1 > NUL
97+ IF " %expl% " == " yes" wmic qfe get Caption,Description,HotFixID,InstalledOn 2 > nul | findstr /C:" KB977165" 1 > NUL
9398IF " %expl% " == " yes" IF errorlevel 1 ECHO .MS10-015 patch is NOT installed! (Vulns: 2K,XP,2K3,2K8,Vista,7-User Mode to Ring)
94- IF " %expl% " == " yes" wmic qfe get Caption,Description,HotFixID,InstalledOn | findstr /C:" KB941693" 1 > NUL
99+ IF " %expl% " == " yes" wmic qfe get Caption,Description,HotFixID,InstalledOn 2 > nul | findstr /C:" KB941693" 1 > NUL
95100IF " %expl% " == " yes" IF errorlevel 1 ECHO .MS08-025 patch is NOT installed! (Vulns: 2K/SP4,XP/SP2,2K3/SP1/2,2K8/SP0,Vista/SP0/1-win32k.sys)
96- IF " %expl% " == " yes" wmic qfe get Caption,Description,HotFixID,InstalledOn | findstr /C:" KB920958" 1 > NUL
101+ IF " %expl% " == " yes" wmic qfe get Caption,Description,HotFixID,InstalledOn 2 > nul | findstr /C:" KB920958" 1 > NUL
97102IF " %expl% " == " yes" IF errorlevel 1 ECHO .MS06-049 patch is NOT installed! (Vulns: 2K/SP4-ZwQuerySysInfo)
98- IF " %expl% " == " yes" wmic qfe get Caption,Description,HotFixID,InstalledOn | findstr /C:" KB914389" 1 > NUL
103+ IF " %expl% " == " yes" wmic qfe get Caption,Description,HotFixID,InstalledOn 2 > nul | findstr /C:" KB914389" 1 > NUL
99104IF " %expl% " == " yes" IF errorlevel 1 ECHO .MS06-030 patch is NOT installed! (Vulns: 2K,XP/SP2-Mrxsmb.sys)
100- IF " %expl% " == " yes" wmic qfe get Caption,Description,HotFixID,InstalledOn | findstr /C:" KB908523" 1 > NUL
105+ IF " %expl% " == " yes" wmic qfe get Caption,Description,HotFixID,InstalledOn 2 > nul | findstr /C:" KB908523" 1 > NUL
101106IF " %expl% " == " yes" IF errorlevel 1 ECHO .MS05-055 patch is NOT installed! (Vulns: 2K/SP4-APC Data-Free)
102- IF " %expl% " == " yes" wmic qfe get Caption,Description,HotFixID,InstalledOn | findstr /C:" KB890859" 1 > NUL
107+ IF " %expl% " == " yes" wmic qfe get Caption,Description,HotFixID,InstalledOn 2 > nul | findstr /C:" KB890859" 1 > NUL
103108IF " %expl% " == " yes" IF errorlevel 1 ECHO .MS05-018 patch is NOT installed! (Vulns: 2K/SP3/4,XP/SP1/2-CSRSS)
104- IF " %expl% " == " yes" wmic qfe get Caption,Description,HotFixID,InstalledOn | findstr /C:" KB842526" 1 > NUL
109+ IF " %expl% " == " yes" wmic qfe get Caption,Description,HotFixID,InstalledOn 2 > nul | findstr /C:" KB842526" 1 > NUL
105110IF " %expl% " == " yes" IF errorlevel 1 ECHO .MS04-019 patch is NOT installed! (Vulns: 2K/SP2/3/4-Utility Manager)
106- IF " %expl% " == " yes" wmic qfe get Caption,Description,HotFixID,InstalledOn | findstr /C:" KB835732" 1 > NUL
111+ IF " %expl% " == " yes" wmic qfe get Caption,Description,HotFixID,InstalledOn 2 > nul | findstr /C:" KB835732" 1 > NUL
107112IF " %expl% " == " yes" IF errorlevel 1 ECHO .MS04-011 patch is NOT installed! (Vulns: 2K/SP2/3/4,XP/SP0/1-LSASS service BoF)
108- IF " %expl% " == " yes" wmic qfe get Caption,Description,HotFixID,InstalledOn | findstr /C:" KB841872" 1 > NUL
113+ IF " %expl% " == " yes" wmic qfe get Caption,Description,HotFixID,InstalledOn 2 > nul | findstr /C:" KB841872" 1 > NUL
109114IF " %expl% " == " yes" IF errorlevel 1 ECHO .MS04-020 patch is NOT installed! (Vulns: 2K/SP4-POSIX)
110- IF " %expl% " == " yes" wmic qfe get Caption,Description,HotFixID,InstalledOn | findstr /C:" KB2975684" 1 > NUL
115+ IF " %expl% " == " yes" wmic qfe get Caption,Description,HotFixID,InstalledOn 2 > nul | findstr /C:" KB2975684" 1 > NUL
111116IF " %expl% " == " yes" IF errorlevel 1 ECHO .MS14-040 patch is NOT installed! (Vulns: 2K3/SP2,2K8/SP2,Vista/SP2,7/SP1-afd.sys Dangling Pointer)
112- IF " %expl% " == " yes" wmic qfe get Caption,Description,HotFixID,InstalledOn | findstr /C:" KB3136041" 1 > NUL
117+ IF " %expl% " == " yes" wmic qfe get Caption,Description,HotFixID,InstalledOn 2 > nul | findstr /C:" KB3136041" 1 > NUL
113118IF " %expl% " == " yes" IF errorlevel 1 ECHO .MS16-016 patch is NOT installed! (Vulns: 2K8/SP1/2,Vista/SP2,7/SP1-WebDAV to Address)
114- IF " %expl% " == " yes" wmic qfe get Caption,Description,HotFixID,InstalledOn | findstr /C:" KB3057191" 1 > NUL
119+ IF " %expl% " == " yes" wmic qfe get Caption,Description,HotFixID,InstalledOn 2 > nul | findstr /C:" KB3057191" 1 > NUL
115120IF " %expl% " == " yes" IF errorlevel 1 ECHO .MS15-051 patch is NOT installed! (Vulns: 2K3/SP2,2K8/SP2,Vista/SP2,7/SP1-win32k.sys)
116- IF " %expl% " == " yes" wmic qfe get Caption,Description,HotFixID,InstalledOn | findstr /C:" KB2989935" 1 > NUL
121+ IF " %expl% " == " yes" wmic qfe get Caption,Description,HotFixID,InstalledOn 2 > nul | findstr /C:" KB2989935" 1 > NUL
117122IF " %expl% " == " yes" IF errorlevel 1 ECHO .MS14-070 patch is NOT installed! (Vulns: 2K3/SP2-TCP/IP)
118- IF " %expl% " == " yes" wmic qfe get Caption,Description,HotFixID,InstalledOn | findstr /C:" KB2778930" 1 > NUL
123+ IF " %expl% " == " yes" wmic qfe get Caption,Description,HotFixID,InstalledOn 2 > nul | findstr /C:" KB2778930" 1 > NUL
119124IF " %expl% " == " yes" IF errorlevel 1 ECHO .MS13-005 patch is NOT installed! (Vulns: Vista,7,8,2008,2008R2,2012,RT-hwnd_broadcast)
120- IF " %expl% " == " yes" wmic qfe get Caption,Description,HotFixID,InstalledOn | findstr /C:" KB2850851" 1 > NUL
125+ IF " %expl% " == " yes" wmic qfe get Caption,Description,HotFixID,InstalledOn 2 > nul | findstr /C:" KB2850851" 1 > NUL
121126IF " %expl% " == " yes" IF errorlevel 1 ECHO .MS13-053 patch is NOT installed! (Vulns: 7SP0/SP1_x86-schlamperei)
122- IF " %expl% " == " yes" wmic qfe get Caption,Description,HotFixID,InstalledOn | findstr /C:" KB2870008" 1 > NUL
127+ IF " %expl% " == " yes" wmic qfe get Caption,Description,HotFixID,InstalledOn 2 > nul | findstr /C:" KB2870008" 1 > NUL
123128IF " %expl% " == " yes" IF errorlevel 1 ECHO .MS13-081 patch is NOT installed! (Vulns: 7SP0/SP1_x86-track_popup_menu)
124129ECHO .
125130CALL :T_Progress 2
@@ -197,7 +202,12 @@ CALL :T_Progress 1
197202
198203:AVSettings
199204CALL :ColorLine " %E% 33m[+]%E% 97m Registered Anti-Virus(AV)"
200- WMIC /Node:localhost /Namespace:\\root\SecurityCenter2 Path AntiVirusProduct Get displayName /Format:List | more
205+ where wmic > nul 2 >& 1
206+ if %errorlevel% equ 0 (
207+ WMIC /Node:localhost /Namespace:\\root\SecurityCenter2 Path AntiVirusProduct Get displayName /Format:List | more
208+ ) else (
209+ powershell -command " Get-CimInstance -Namespace root/SecurityCenter2 -ClassName AntiVirusProduct | Select-Object -ExpandProperty displayName"
210+ )
201211ECHO .Checking for defender whitelisted PATHS
202212reg query " HKLM\SOFTWARE\Microsoft\Windows Defender\Exclusions\Paths" 2 > nul
203213CALL :T_Progress 1
@@ -226,7 +236,12 @@ CALL :T_Progress 3
226236:MountedDisks
227237CALL :ColorLine " %E% 33m[+]%E% 97m MOUNTED DISKS"
228238ECHO . [i] Maybe you find something interesting
229- (wmic logicaldisk get caption 2 > nul | more) || (fsutil fsinfo drives 2 > nul )
239+ where wmic > nul 2 >& 1
240+ if %errorlevel% equ 0 (
241+ wmic logicaldisk get caption | more
242+ ) else (
243+ fsutil fsinfo drives
244+ )
230245ECHO .
231246CALL :T_Progress 1
232247
@@ -273,15 +288,29 @@ tasklist /SVC
273288ECHO .
274289CALL :T_Progress 2
275290ECHO . [i] Checking file permissions of running processes (File backdooring - maybe the same files start automatically when Administrator logs in)
276- for /f " tokens=2 delims='='" %%x in ('wmic process list full^ |find /i " executablepath" ^ |find /i /v " system32" ^ |find " :" ') do (
277- for /f eol^ =^ " ^ delims^=^" %%z in ('ECHO.%%x ') do (
278- icacls " %%z " 2 > nul | findstr /i " (F) (M) (W) :\\" | findstr /i " :\\ everyone authenticated users todos %username% " && ECHO .
291+ where wmic > nul 2 >& 1
292+ if %errorlevel% equ 0 (
293+ for /f " tokens=2 delims='='" %%x in ('wmic process list full ^ |find /i " executablepath" ^ |find /i /v " system32" ^ |find " :" ') do (
294+ for /f eol^ =^ " ^ delims^=^" %%z in ('ECHO.%%x ') do (
295+ icacls " %%z " 2 > nul | findstr /i " (F) (M) (W) :\\" | findstr /i " :\\ everyone authenticated users todos %username% " && ECHO .
296+ )
297+ )
298+ ) else (
299+ for /f " tokens=*" %%x in ('powershell -command " Get-Process | Where-Object {$_.Path -and $_.Path -notlike '*system32*'} | Select-Object -ExpandProperty Path -Unique" ') do (
300+ icacls " %%x " 2 > nul | findstr /i " (F) (M) (W) :\\" | findstr /i " :\\ everyone authenticated users todos %username% " && ECHO .
279301 )
280302)
281303ECHO .
282304ECHO . [i] Checking directory permissions of running processes (DLL injection)
283- for /f " tokens=2 delims='='" %%x in ('wmic process list full^ |find /i " executablepath" ^ |find /i /v " system32" ^ |find " :" ') do for /f eol^ =^ " ^ delims^=^" %%y in ('ECHO.%%x ') do (
284- icacls " %%~dpy \" 2 > nul | findstr /i " (F) (M) (W) :\\" | findstr /i " :\\ everyone authenticated users todos %username% " && ECHO .
305+ where wmic > nul 2 >& 1
306+ if %errorlevel% equ 0 (
307+ for /f " tokens=2 delims='='" %%x in ('wmic process list full ^ |find /i " executablepath" ^ |find /i /v " system32" ^ |find " :" ') do for /f eol^ =^ " ^ delims^=^" %%y in ('ECHO.%%x ') do (
308+ icacls " %%~dpy \" 2 > nul | findstr /i " (F) (M) (W) :\\" | findstr /i " :\\ everyone authenticated users todos %username% " && ECHO .
309+ )
310+ ) else (
311+ for /f " tokens=*" %%x in ('powershell -command " Get-Process | Where-Object {$_.Path -and $_.Path -notlike '*system32*'} | Select-Object -ExpandProperty Path -Unique" ') do (
312+ for /f " delims=" %%d in (" %%~dpx " ) do icacls " %%d " 2 > nul | findstr /i " (F) (M) (W) :\\" | findstr /i " :\\ everyone authenticated users todos %username% " && ECHO .
313+ )
285314)
286315ECHO .
287316CALL :T_Progress 3
@@ -452,8 +481,19 @@ ECHO.
452481:ServiceBinaryPermissions
453482CALL :ColorLine " %E% 33m[+]%E% 97m SERVICE BINARY PERMISSIONS WITH WMIC and ICACLS"
454483ECHO . [?] https://book.hacktricks.wiki/en/windows-hardening/windows-local-privilege-escalation/index.html#services
455- for /f " tokens=2 delims='='" %%a in ('cmd.exe /c wmic service list full ^ | findstr /i " pathname" ^ |findstr /i /v " system32" ') do (
456- for /f eol^ =^ " ^ delims^=^" %%b in (" %%a " ) do icacls " %%b " 2 > nul | findstr /i " (F) (M) (W) :\\" | findstr /i " :\\ everyone authenticated users todos usuarios %username% " && ECHO .
484+ where wmic > nul 2 >& 1
485+ if %errorlevel% equ 0 (
486+ for /f " tokens=2 delims='='" %%a in ('cmd.exe /c wmic service list full ^ | findstr /i " pathname" ^ |findstr /i /v " system32" ') do (
487+ for /f eol^ =^ " ^ delims^=^" %%b in (" %%a " ) do icacls " %%b " 2 > nul | findstr /i " (F) (M) (W) :\\" | findstr /i " :\\ everyone authenticated users todos usuarios %username% " && ECHO .
488+ )
489+ ) else (
490+ for /f " tokens=*" %%a in ('powershell -command " Get-CimInstance -ClassName Win32_Service | Where-Object {$_.PathName -and $_.PathName -notlike '*system32*'} | Select-Object -ExpandProperty PathName" ') do (
491+ for /f " tokens=1 delims= " %%b in (" %%a " ) do (
492+ set " svcpath = %%b "
493+ set " svcpath = !svcpath:~1 ,-1 ! "
494+ if exist " !svcpath! " icacls " !svcpath! " 2 > nul | findstr /i " (F) (M) (W) :\\" | findstr /i " :\\ everyone authenticated users todos usuarios %username% " && ECHO .
495+ )
496+ )
457497)
458498ECHO .
459499CALL :T_Progress 1
@@ -628,16 +668,29 @@ if "%long%" == "true" (
628668 ECHO .
629669 ECHO . [i] Iterating through the drives
630670 ECHO .
631- for /f %%x in ('wmic logicaldisk get name^ | more') do (
632- set tdrive = %%x
633- if " !tdrive:~1 ,2 ! " == " :" (
634- %%x
635- CALL :ColorLine " %E% 33m[+]%E% 97m FILES THAT CONTAINS THE WORD PASSWORD WITH EXTENSION: .xml .ini .txt *.cfg *.config"
636- findstr /s/n/m/i password *.xml *.ini *.txt *.cfg *.config 2 > nul | findstr /v /i " \\AppData\\Local \\WinSxS ApnDatabase.xml \\UEV\\InboxTemplates \\Microsoft.Windows.Cloud \\Notepad\+\+\\ vmware cortana alphabet \\7-zip\\" 2 > nul
637- ECHO .
638- CALL :ColorLine " %E% 33m[+]%E% 97m FILES WHOSE NAME CONTAINS THE WORD PASS CRED or .config not inside \Windows\"
639- dir /s/b *pass* == *cred* == *.config* == *.cfg 2 > nul | findstr /v /i " \\windows\\"
640- ECHO .
671+ where wmic > nul 2 >& 1
672+ if !errorlevel! equ 0 (
673+ for /f %%x in ('wmic logicaldisk get name ^ | more') do (
674+ set tdrive = %%x
675+ if " !tdrive:~1 ,2 ! " == " :" (
676+ %%x
677+ CALL :ColorLine " %E% 33m[+]%E% 97m FILES THAT CONTAINS THE WORD PASSWORD WITH EXTENSION: .xml .ini .txt *.cfg *.config"
678+ findstr /s/n/m/i password *.xml *.ini *.txt *.cfg *.config 2 > nul | findstr /v /i " \\AppData\\Local \\WinSxS ApnDatabase.xml \\UEV\\InboxTemplates \\Microsoft.Windows.Cloud \\Notepad\+\+\\ vmware cortana alphabet \\7-zip\\" 2 > nul
679+ ECHO .
680+ CALL :ColorLine " %E% 33m[+]%E% 97m FILES WHOSE NAME CONTAINS THE WORD PASS CRED or .config not inside \Windows\"
681+ dir /s/b *pass* == *cred* == *.config* == *.cfg 2 > nul | findstr /v /i " \\windows\\"
682+ ECHO .
683+ )
684+ )
685+ ) else (
686+ for /f %%x in ('powershell -command " Get-PSDrive -PSProvider FileSystem | Where-Object {$_.Root -match ':'} | Select-Object -ExpandProperty Name" ') do (
687+ %%x :
688+ CALL :ColorLine " %E% 33m[+]%E% 97m FILES THAT CONTAINS THE WORD PASSWORD WITH EXTENSION: .xml .ini .txt *.cfg *.config"
689+ findstr /s/n/m/i password *.xml *.ini *.txt *.cfg *.config 2 > nul | findstr /v /i " \\AppData\\Local \\WinSxS ApnDatabase.xml \\UEV\\InboxTemplates \\Microsoft.Windows.Cloud \\Notepad\+\+\\ vmware cortana alphabet \\7-zip\\" 2 > nul
690+ ECHO .
691+ CALL :ColorLine " %E% 33m[+]%E% 97m FILES WHOSE NAME CONTAINS THE WORD PASS CRED or .config not inside \Windows\"
692+ dir /s/b *pass* == *cred* == *.config* == *.cfg 2 > nul | findstr /v /i " \\windows\\"
693+ ECHO .
641694 )
642695 )
643696 CALL :T_Progress 2
@@ -666,5 +719,5 @@ EXIT /B
666719
667720:ColorLine
668721SET " CurrentLine = %~1 "
669- FOR /F " delims= " %%A IN ('FORFILES.EXE /P %~dp0 /M %~nx0 /C " CMD /C ECHO.!CurrentLine! " ') DO ECHO . %%A
722+ ECHO .!CurrentLine!
670723EXIT /B
0 commit comments