Skip to content

Instantly share code, notes, and snippets.

@ksoona
Forked from thomhastings/process-permissions.bat
Last active August 29, 2015 14:08
Show Gist options
  • Save ksoona/5b5476c3255ae4c62bb1 to your computer and use it in GitHub Desktop.
Save ksoona/5b5476c3255ae4c62bb1 to your computer and use it in GitHub Desktop.
:: process-permissions.bat
:: =======================
:: Batch Script for process permission analysis
:: by Thom Hastings ©2012 New BSD License
::
:: for reference-
:: http://travisaltman.com/windows-privilege-escalation-via-weak-service-permissions/
:: TODO: http://it-ovid.blogspot.com/2012/02/windows-privilege-escalation.html
@echo off
title %username%@%userdomain% on %logonserver%\%computername% via %comspec% ~c0nS0Le
color 0a
title %username%@%userdomain% on %logonserver%\%computername% via %comspec% ~W0rking...
@echo on
for /f "tokens=2 delims='='" %%a in ('wmic service list full^|find /i "pathname"^|find /i /v "system32"') do echo %%a >> process-permissions-unparsed.txt
:: clean up from last time just in case
@del process-permissions-output.txt
for /f eol^=^"^ delims^=^" %%a in (process-permissions-unparsed.txt) do cmd.exe /c icacls "%%a" >> process-permissions-output.txt
@del process-permissions-unparsed.txt
@echo off
title %username%@%userdomain% on %logonserver%\%computername% via %comspec% ~c0nS0Le
echo Opening text file...
pause
start notepad process-permissions-output.txt
:: Dump undocumented system variables (just to see if there's anything interesting)
echo Dumping undocumented system variables...
@echo on
set "
@echo off
pause
choice /m "Clean up"
if errorlevel 2 goto end
if errorlevel 1 goto :clean
:clean
del process-permissions-output.txt
:end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment