# Hybrid

### Enumeration

IPs

```
10.10.221.54 mail.hybrid.vl
10.10.221.53 dc01.hybrid.vl
```

We have two machines

&#x20;.53 is a Domain controller

&#x20;.54 is a Linux mail server

&#x20;From the nmap scan we can see that NFS is open, to enumerate mount points we can do `showmount -e <ip>`

&#x20;

<figure><img src="https://3164413258-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdsVljAgb891qXyZgmwtE%2Fuploads%2F4C7782aMiKjPwGOmdJj2%2FPasted%20image%2020230815001127.png?alt=media" alt=""><figcaption></figcaption></figure>

After mounting we see a `backup.tar.gz`

<figure><img src="https://3164413258-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdsVljAgb891qXyZgmwtE%2Fuploads%2FHrF1L4CgSo1zQGE9obnK%2FPasted%20image%2020230815001419.png?alt=media" alt=""><figcaption></figcaption></figure>

&#x20;Now we have two directories

<figure><img src="https://3164413258-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdsVljAgb891qXyZgmwtE%2Fuploads%2FtBstszxlDQCuir5sPC01%2FPasted%20image%2020230815001602.png?alt=media" alt=""><figcaption></figcaption></figure>

&#x20;In `etc/dovecot` we find possible email credentials

<figure><img src="https://3164413258-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdsVljAgb891qXyZgmwtE%2Fuploads%2FHHitBIFVDa89fyd2A9Fn%2FPasted%20image%2020230815001706.png?alt=media" alt=""><figcaption></figcaption></figure>

&#x20;In `etc/sssd` we find a interesting file with references to LDAP and Kerberos, this machine is probably joined to the `hybrid.vl`domain&#x20;

<figure><img src="https://3164413258-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdsVljAgb891qXyZgmwtE%2Fuploads%2FdEvBepzP5QKUUDzjpJk8%2FPasted%20image%2020230815001836.png?alt=media" alt=""><figcaption></figcaption></figure>

SSSD is is used to access remote directory service, like Active directory, and provide SSO capabilities to networks based on Unix

We also find a passwd file with the users in this machine

In `/opt/certs/hybrid.vl` we find two files one is a SSL certificate, maybe, and the other one looks like a private key

<figure><img src="https://3164413258-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdsVljAgb891qXyZgmwtE%2Fuploads%2F9lS3Ox78V7baSF6h7Pkg%2FPasted%20image%2020230815002600.png?alt=media" alt=""><figcaption></figcaption></figure>

Now with the credentials discovered from the file we can try to log in the webmail

<figure><img src="https://3164413258-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdsVljAgb891qXyZgmwtE%2Fuploads%2FZYkxRXU1otcIackKd8pb%2FPasted%20image%2020230815003438.png?alt=media" alt=""><figcaption></figcaption></figure>

```
admin@hybrid.vl:Duckling21
peter.turner@hybrid.vl:PeterIstToll!
```

The Admin's inbox is empty but we find something in Peter's inbox

<figure><img src="https://3164413258-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdsVljAgb891qXyZgmwtE%2Fuploads%2FOYIlJYSLikticQPjV2ZN%2FPasted%20image%2020230815003727.png?alt=media" alt=""><figcaption></figcaption></figure>

The junk filter plugin is probably Markasjunk and should be vulnerable to [RCE](https://cyberthint.io/roundcube-markasjunk-command-injection-vulnerability/)

&#x20;We can use this exploit to gain a shell on the machine

<figure><img src="https://3164413258-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdsVljAgb891qXyZgmwtE%2Fuploads%2F0JzwzdqSEJs93Va6QfKQ%2FPasted%20image%2020230815015403.png?alt=media" alt=""><figcaption></figcaption></figure>

Here we download a shell with curl and pipe it to bash

## Privilege escalation Linux

This is the other user on the machine

<figure><img src="https://3164413258-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdsVljAgb891qXyZgmwtE%2Fuploads%2FfOebcEjYNApNJ6zRwuB3%2FPasted%20image%2020230815020640.png?alt=media" alt=""><figcaption></figcaption></figure>

Since we have write access to the share we can create files with Peter's user id

We create a new user in the attacking machine with Peter's user id

<figure><img src="https://3164413258-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdsVljAgb891qXyZgmwtE%2Fuploads%2FJDKmDte3dicfcsgXkZWE%2FPasted%20image%2020230815021558.png?alt=media" alt=""><figcaption></figcaption></figure>

We also need to edit `/etc/logins.defs` and change the maximum `UID` value

From the attacking machine we copy `sh`, or `bash`, to the share and we put the SUID bit on it

<figure><img src="https://3164413258-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdsVljAgb891qXyZgmwtE%2Fuploads%2FC0I3M5opFLJmP7If6GhY%2FPasted%20image%2020230815022245.png?alt=media" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3164413258-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdsVljAgb891qXyZgmwtE%2Fuploads%2FDo0u3dSLaGp7kyCeI6ic%2FPasted%20image%2020230815022301.png?alt=media" alt=""><figcaption></figcaption></figure>

Now we are Peter Turner

In the home folder we find a keepass database but it requires a password

<figure><img src="https://3164413258-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdsVljAgb891qXyZgmwtE%2Fuploads%2FR88bDniuOjPyMjkKMnLu%2FPasted%20image%2020230815022946.png?alt=media" alt=""><figcaption></figcaption></figure>

&#x20;Maybe we can try the Peter's email password

&#x20;And it works!

<figure><img src="https://3164413258-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdsVljAgb891qXyZgmwtE%2Fuploads%2FIENcBmXbBCJnYlOJ2ywT%2FPasted%20image%2020230815023034.png?alt=media" alt=""><figcaption></figcaption></figure>

Now we have Peter's domain password, that we can use on the Linux machine too since it's domain joined

## Privilege escalation domain

Now we enumerate the domain using `bloodhound-python`

<figure><img src="https://3164413258-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdsVljAgb891qXyZgmwtE%2Fuploads%2Fy3LpyxJ64J9q8z0uT5XG%2FPasted%20image%2020230815024451.png?alt=media" alt=""><figcaption></figcaption></figure>

&#x20;Nothing interesting found from this domain dump

&#x20;But we can enumerate AD certificates with Certipy

My installation of Certipy gives problems so i used the [docker version](https://github.com/secure-77/Certipy-Docker) from secure-77

<figure><img src="https://3164413258-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdsVljAgb891qXyZgmwtE%2Fuploads%2FdyY9mBCaebhLE4dA5wuQ%2FPasted%20image%2020230815030804.png?alt=media" alt=""><figcaption></figcaption></figure>

Now to view the output of certipy in bloodhound we need to install a [different version](https://github.com/ly4k/BloodHound)&#x20;

Here we can see a custom certificate template

<figure><img src="https://3164413258-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdsVljAgb891qXyZgmwtE%2Fuploads%2FcNQBJGX1Pn506yMEwyxO%2FPasted%20image%2020230815031407.png?alt=media" alt=""><figcaption></figcaption></figure>

We can mark `MAIL01` as owned and check the shortest path to misconfigured certificate from owned principals

<figure><img src="https://3164413258-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdsVljAgb891qXyZgmwtE%2Fuploads%2F4uqTKbjDRjqlxprJYJyZ%2FPasted%20image%2020230815031630.png?alt=media" alt=""><figcaption></figcaption></figure>

And we can see that `MAIL01` is a part of `DOMAIN COMPUTERS`, and can enroll `HYBRIDCOMPUTERS` To enroll the certificate we need the `MAIL01` machine account hash

Is a keytab file in `/etc/krb5.keytab`, then we can use this [tool](https://github.com/sosdave/KeyTabExtract) to extract the NTLM hash

<figure><img src="https://3164413258-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdsVljAgb891qXyZgmwtE%2Fuploads%2Few8HrAViY1HytUg3Sjsw%2FPasted%20image%2020230815032352.png?alt=media&#x26;token=f6246b5b-fe01-4aa4-9986-7baaab628275" alt=""><figcaption></figcaption></figure>

Now we can request the certificate

If we receive an error regarding the key size we need to specify the correct key size in the command

<figure><img src="https://3164413258-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdsVljAgb891qXyZgmwtE%2Fuploads%2FiR5bASvUqNSmjy42ToFE%2FPasted%20image%2020230815032859.png?alt=media&#x26;token=ab288b6f-5eec-437e-b415-4d956c3e27ea" alt=""><figcaption></figcaption></figure>

We can check the correct key size in bloodhound

<figure><img src="https://3164413258-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdsVljAgb891qXyZgmwtE%2Fuploads%2FM7NPiKensdqovO62sipn%2FPasted%20image%2020230815032923.png?alt=media&#x26;token=6ff1070e-c16e-460a-a790-b0b111a75e7d" alt=""><figcaption></figcaption></figure>

We have succesfully requested a certificate

<figure><img src="https://3164413258-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdsVljAgb891qXyZgmwtE%2Fuploads%2Fqh0oKPfwgj16n860gL7R%2FPasted%20image%2020230815033054.png?alt=media&#x26;token=288900ca-1c63-43a1-8f77-303236c909a7" alt=""><figcaption></figcaption></figure>

Now to pass the certificate we can use this [tool](https://github.com/AlmondOffSec/PassTheCert)

We need to extract the key and the cert from the .pfx file

<figure><img src="https://3164413258-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdsVljAgb891qXyZgmwtE%2Fuploads%2FhBcnALgy8znH4Y0Wxknx%2FPasted%20image%2020230815033618.png?alt=media&#x26;token=7308414f-d842-4216-9078-1706550d3f28" alt=""><figcaption></figcaption></figure>

Then we change the Administrator password

<figure><img src="https://3164413258-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdsVljAgb891qXyZgmwtE%2Fuploads%2FpFBRvEFtiG3yCI2OFQxt%2FPasted%20image%2020230815033826.png?alt=media&#x26;token=1a864aa8-f262-4741-9546-e559e1bda5b5" alt=""><figcaption></figcaption></figure>

Or directly request the Administrator hash

```
sudo docker run -it -v $(pwd):/tmp certipy:latest certipy auth -pfx 'administrator.pfx' -username 'Administrator' -domain 'hybrid.vl' -dc-ip 10.10.221.53
```
