> For the complete documentation index, see [llms.txt](https://pythonic01.gitbook.io/pythonic01/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://pythonic01.gitbook.io/pythonic01/try-hack-me/service-thm.md).

# Service (THM)

At your service.

## Into

* Hello Every one today i want to do a windows machine as a part of my way to master AD (Active Directory) SHALL WE ??

## Enumeration

### Port scanning

```

53/tcp    open  domain        syn-ack ttl 127 Simple DNS Plus
80/tcp    open  http          syn-ack ttl 127 Microsoft IIS httpd 10.0
|_http-server-header: Microsoft-IIS/10.0
|_http-title: Above Services
| http-methods:
|   Supported Methods: OPTIONS TRACE GET HEAD POST
|_  Potentially risky methods: TRACE
88/tcp    open  kerberos-sec  syn-ack ttl 127 Microsoft Windows Kerberos (server time: 2025-01-04 10:29:23Z)
135/tcp   open  msrpc         syn-ack ttl 127 Microsoft Windows RPC
139/tcp   open  netbios-ssn   syn-ack ttl 127 Microsoft Windows netbios-ssn
389/tcp   open  ldap          syn-ack ttl 127 Microsoft Windows Active Directory LDAP (Domain: services.local0., Site: Default-First-Site-Name)
445/tcp   open  microsoft-ds? syn-ack ttl 127
464/tcp   open  kpasswd5?     syn-ack ttl 127
593/tcp   open  ncacn_http    syn-ack ttl 127 Microsoft Windows RPC over HTTP 1.0
636/tcp   open  tcpwrapped    syn-ack ttl 127
3389/tcp  open  ms-wbt-server syn-ack ttl 127 Microsoft Terminal Services
|_ssl-date: 2025-01-04T10:30:40+00:00; 0s from scanner time.
| ssl-cert: Subject: commonName=WIN-SERVICES.services.local
| Issuer: commonName=WIN-SERVICES.services.local
| Public Key type: rsa
| Public Key bits: 2048
| Signature Algorithm: sha256WithRSAEncryption
| Not valid before: 2025-01-03T10:26:28
| Not valid after:  2025-07-05T10:26:28
| MD5:   ae6e:0e10:f6bf:87f9:9173:a46a:5e07:8fca
| SHA-1: 5554:fe7c:13e9:df45:0692:3b94:99e5:16ab:a721:013b
| -----BEGIN CERTIFICATE-----
| MIIC+jCCAeKgAwIBAgIQQ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|   NetBIOS_Domain_Name: SERVICES
|   NetBIOS_Computer_Name: WIN-SERVICES
|   DNS_Domain_Name: services.local
|   DNS_Computer_Name: WIN-SERVICES.services.local
|   Product_Version: 10.0.17763
|_  System_Time: 2025-01-04T10:30:31+00:00
5985/tcp  open  http          syn-ack ttl 127 Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP)
|_http-title: Not Found
|_http-server-header: Microsoft-HTTPAPI/2.0
7680/tcp  open  pando-pub?    syn-ack ttl 127
9389/tcp  open  mc-nmf        syn-ack ttl 127 .NET Message Framing
47001/tcp open  http          syn-ack ttl 127 Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP)
|_http-server-header: Microsoft-HTTPAPI/2.0
|_http-title: Not Found
49664/tcp open  msrpc         syn-ack ttl 127 Microsoft Windows RPC
49665/tcp open  msrpc         syn-ack ttl 127 Microsoft Windows RPC
49666/tcp open  msrpc         syn-ack ttl 127 Microsoft Windows RPC
49667/tcp open  msrpc         syn-ack ttl 127 Microsoft Windows RPC
49668/tcp open  msrpc         syn-ack ttl 127 Microsoft Windows RPC
49674/tcp open  msrpc         syn-ack ttl 127 Microsoft Windows RPC
49675/tcp open  ncacn_http    syn-ack ttl 127 Microsoft Windows RPC over HTTP 1.0
49676/tcp open  msrpc         syn-ack ttl 127 Microsoft Windows RPC
49679/tcp open  msrpc         syn-ack ttl 127 Microsoft Windows RPC
49682/tcp open  msrpc         syn-ack ttl 127 Microsoft Windows RPC
49696/tcp open  msrpc         syn-ack ttl 127 Microsoft Windows RPC
49708/tcp open  msrpc         syn-ack ttl 127 Microsoft Windows RPC
```

There are a lot of things Running there but there are few important ones.

1. HTTP : 80
2. DNS : 53
3. SSH : 22
4. kerberos-sec : 88
5. RDP : 3389
6. LDAP : 389
7. SMB : 139 , 445

Let's start with the simplest which is the HTTP server.

#### HTTP

* After Enumerate for a bit i notice this.<br>

  <figure><img src="https://616326001-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fi149KGmTZ4nvE4TuOMXm%2Fuploads%2FE5jlctYf37aUWYgvxoj4%2Fimage.png?alt=media&amp;token=fb316061-d7f6-48cc-82b5-6825d41b82ac" alt=""><figcaption></figcaption></figure>
* There are few things we can notice.
  * There are few users which appear to be
  * We can see how they would set the names for Joanne Doe should be <j.doe@services.local>
  * So we can deduce the rest right.

<figure><img src="https://616326001-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fi149KGmTZ4nvE4TuOMXm%2Fuploads%2FgUIqhA5yVZjUGPaIBLxv%2Fimage.png?alt=media&amp;token=977b4426-e37b-4e6a-a51e-1d297e7cdba1" alt=""><figcaption></figcaption></figure>

* My user file will look like this initially

### Validate the users

* We can use multiple tools to validate the users via kerberos we can use <https://github.com/ropnop/kerbrute> a good tool to attack Active directory.<br>

<figure><img src="https://616326001-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fi149KGmTZ4nvE4TuOMXm%2Fuploads%2FaNo0c9zyl5P6C5gPWxxH%2Fimage.png?alt=media&amp;token=9f9e413b-5cbc-40ee-a8a1-49bd0683c1a5" alt=""><figcaption></figcaption></figure>

* Using Kerbrute we were able to find a hash of one of the users which is Jack. Now let's try to crack it via hash cat.
* After try with hashcat i was not able to crack it because the algorith used here was kinda strong to crack as we can see `$18`.<br>

<figure><img src="https://616326001-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fi149KGmTZ4nvE4TuOMXm%2Fuploads%2FIafrXY3oO4vpFM3LYMOE%2Fimage.png?alt=media&amp;token=ab1ec427-a28a-4e4b-9cb0-20ce96c76c69" alt=""><figcaption></figcaption></figure>

* And there i used impacket tool called GetNPUsers which suppose to give us the same thing but with weaker hash.<br>

<figure><img src="https://616326001-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fi149KGmTZ4nvE4TuOMXm%2Fuploads%2FM3qYC33eCy4Nxioda7s3%2Fimage.png?alt=media&amp;token=d99d7e5b-9a00-4c64-b991-cced570f3b65" alt=""><figcaption></figcaption></figure>

* And as we can see here this hash should be weaker let's give that a shot and crack it.\
  `hashcat -m 18200 -a 0 ./hash ../../Downloads/rockyou.txt`\
  \
  And indeed we was able to crack it.\
  `j.rock : Serviceworks1`

  <figure><img src="https://616326001-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fi149KGmTZ4nvE4TuOMXm%2Fuploads%2FEbbD4iVl2cRB8NMmVOFW%2Fimage.png?alt=media&amp;token=11902140-2ac8-4090-9711-8f758064cbd4" alt=""><figcaption></figcaption></figure>
* As we get valid creds now we can see what does SMB have for us.

### SMB

* We can use tools like smbmap or smbclient to see what shares do we have.
* In my case i will use smbclient.<br>

<figure><img src="https://616326001-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fi149KGmTZ4nvE4TuOMXm%2Fuploads%2FFJ8npjx1dSMXZ9Yn3k85%2Fimage.png?alt=media&amp;token=e3743774-df7a-44ff-ad5c-07f94610ec01" alt=""><figcaption></figcaption></figure>

* First i will check the C$ share.
* We can find our flag there :)<br>

<figure><img src="https://616326001-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fi149KGmTZ4nvE4TuOMXm%2Fuploads%2FNybQPguf5eylzhRvjE5f%2Fimage.png?alt=media&amp;token=a5554df8-5883-48f1-beaa-e1260f6129a5" alt=""><figcaption></figcaption></figure>

## Getting Shell as j.rock

* I though that we maybe able to access the machine via evil-Winrm and indeed we can.<br>

<figure><img src="https://616326001-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fi149KGmTZ4nvE4TuOMXm%2Fuploads%2F06VkmQ6itWeMdyNPbCCk%2Fimage.png?alt=media&amp;token=4c1a70e4-410a-416b-869d-1daa9fc98fde" alt=""><figcaption></figcaption></figure>

## Getting Administrator access

* The first thing i review when i access the machine was the permission.<br>

<figure><img src="https://616326001-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fi149KGmTZ4nvE4TuOMXm%2Fuploads%2FDlSG5EIgjaDHcyHyh8xJ%2Fimage.png?alt=media&amp;token=3e9c9ac2-9278-4c1b-88ac-d228f67dd6d4" alt=""><figcaption></figcaption></figure>

* The server Operators Group is interesting group since it allow use to configure some aspect of the AD.\
  <https://www.hackingarticles.in/windows-privilege-escalation-server-operator-group/>
* Using the above resource i was able to get administrator access The process went as follow.<br>

<figure><img src="https://616326001-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fi149KGmTZ4nvE4TuOMXm%2Fuploads%2FWl2HD65vaEouKFCfBF5x%2Fimage.png?alt=media&amp;token=4cc7a44f-a2c5-4025-87f0-5bd9144ce6c3" alt=""><figcaption></figcaption></figure>

* I create this payload using msfvenom.
* Then i setup the listener from metasploit.<br>

<figure><img src="https://616326001-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fi149KGmTZ4nvE4TuOMXm%2Fuploads%2FfOb96TrsC38hZ6GFaHhw%2Fimage.png?alt=media&amp;token=73463b6f-39e6-4ba4-a885-c84ed7839c31" alt=""><figcaption></figcaption></figure>

* And now from the hacked machine we need to set the service and allow our shell to be executed as NT\Authority.
* Using the `services` command we see the running commands. You can choose one to execute the same steps but the only one that works with me was `cfn-hub`.<br>

  <figure><img src="https://616326001-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fi149KGmTZ4nvE4TuOMXm%2Fuploads%2Ftur00LtOukXycz25L6WH%2Fimage.png?alt=media&amp;token=53f4230a-2335-47c8-9363-f8f2ded6df0a" alt=""><figcaption></figcaption></figure>
* Now we can start the service again.<br>

<figure><img src="https://616326001-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fi149KGmTZ4nvE4TuOMXm%2Fuploads%2FQKRkaGQHHuOnCHXjYhgC%2Fimage.png?alt=media&amp;token=cc73ab2d-1838-45c0-9b68-fa3b4abec52e" alt=""><figcaption></figcaption></figure>

* And now we are the super user.<br>

<figure><img src="https://616326001-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fi149KGmTZ4nvE4TuOMXm%2Fuploads%2FqNmP1iUvu7Q1tARSRz2I%2Fimage.png?alt=media&amp;token=08830375-10aa-4091-ac56-2a55131c91ac" alt=""><figcaption></figcaption></figure>

* And here we have our flag.<br>

<figure><img src="https://616326001-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fi149KGmTZ4nvE4TuOMXm%2Fuploads%2FV07PRlxA1nBi0CayVp5x%2Fimage.png?alt=media&amp;token=2b74b594-7d60-4374-99be-9bb68ff52e4c" alt=""><figcaption></figcaption></figure>

## Conclusion.

* This machine was quite fun and easy as am not that good with Windows not AD. :)
