Skip to content

Instantly share code, notes, and snippets.

@bordplate
Created November 18, 2017 19:52
Show Gist options
  • Save bordplate/ce64d2c1474801cc6a987a021d497bc9 to your computer and use it in GitHub Desktop.
Save bordplate/ce64d2c1474801cc6a987a021d497bc9 to your computer and use it in GitHub Desktop.
Script to enumerate services on a Windows system and list their permissions. Writes to a file in folder called services.txt. Run with `cscript service-permissions-enumeration.vbs`
strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colListOfServices = objWMIService.ExecQuery ("Select * from Win32_Service ")
Set objShell = CreateObject("Wscript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
For Each objService in colListOfServices
Dim path, x
path = objService.PathName
x = Instr(path,"-")
If x Then path = Left(path,x-1)
x = Instr(path,"/")
If x Then path = Left(path,x-1)
path = Trim(path)
wscript.echo path
objShell.Run "cmd /c icacls """ & objService.PathName & """ >> services.txt", 0, True
Next
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment