Thursday, March 22, 2012

Services Report

I was checking for weaknesses in services on a remote machine one time but going through them one at a time was annoying and I really wanted to just have a text file with all the info I could transfer off the machine to peruse at my leisure. So I made this. It enumerates all the services and then does a sc query on them and dumps the output to a text file.

It could be improved by doing a cacls report on the Binary_Path_Name of the service to see if there's write / modify access to the folder. Feel free to improve on it.

-=The Script=-

@echo off
sc query state= all | find /i "Service_Name:" >> test.txt
for /f "tokens=2* delims= " %%a in (test.txt) do echo %%a %%b>> test2.txt
for /f "tokens=* delims=" %%x in (test2.txt) do (
call :sub1 %%x)
goto :next

:sub1
if %1'==' goto :eof
echo %*>> clean.txt
goto :eof



:next
for /f "tokens=* delims=" %%v in (clean.txt) do sc qc "%%v" >> finally.txt
del /f /q test.txt
del /f /q test2.txt
del /f /q clean.txt
exit

No comments:

Post a Comment

All comments moderated.
Comments like "sweet dude" or "this is awesome" or "thanks" will be denied,
if you've got something genuinely interesting to say, say it. Other than that just sit back and bask in the glory.