Skip to content

Instantly share code, notes, and snippets.

@thomhastings
Created October 24, 2012 01:13
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save thomhastings/3943115 to your computer and use it in GitHub Desktop.
Save thomhastings/3943115 to your computer and use it in GitHub Desktop.
Batch Script for process permission analysis
:: 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
@ksoona
Copy link

ksoona commented Oct 30, 2014

why do so many people still run windows??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment