Resource

Recon

nmap_scan.log|h-50%_styled

HTTP (80)

Writeup.png

Enumerate meanwhile:

Dashboard

Register, Creds: test02:test02

Writeup-1.png

Ticket creation doesn't have any description, we can create Ticket with title, description and upload zip file.

We can try accessing admin.php:

Writeup-2.png

Remote admin username: zzinter

Admin Panel

Ping tool works:

Writeup-3.png

Command injection unsuccessful.

Writeup-4.png

Everything seemed sanitized and nothing was going well 🤔

The navigation of PHP via page value is always suspicious (http://itrc.ssg.htb/?page=<PAGE>). This means the pages are included, not loaded separately. Meaning we can achieve LFI, php files are loaded without any hassle, but if we try to include files with file:// protocol it fails right away most probably due to filters.

PHP has many wrappers and one of them is ZIP, I tried uploading ZODarrow-up-right or empty ziparrow-up-right, but they returned 404 when going to uploaded file. If uploaded normally then then file is accessible normally.

PayloadsAllTheThings/File Inclusion> wrapper-ziparrow-up-right

LFI

Trying zip payloads yielded no success:

Trying the phar payload worked!

Writeup-5.png

Reverse Shell

Get the reverse shell:

Writeup-6.png

Linpeas didn't show full network, running netstat shows different results

I still wasn't able to connect to the database...

/uploads directory had other zip files, worth checking out:

The file was some kind of automated actions log, PHPSESSID was also used meaning there was an account, grep for pass and we pwned msainristil user.

SSH (22)

We are able to SSH into port 22.

Creds: msainristil:82yards2closeit

FastAPI

There's something going on with Certificate Authorities and in netstat output we saw another host on system signserv.ssg.htb

Writeup-7.png

I didn't know what to do with the service so I left it for now.

SSH CA Certificates

After few hours I returned to the box and found files in decommission_old_ca that should have been there, but wasn't 💀 Probably some MF deleted them..

14.3. Using OpenSSH Certificate Authenticationarrow-up-right14.3.3. Creating SSH CA Certificate Signing Keysarrow-up-right

man page also has solid explanations too!

Create certificate, sign the keys and authenticate.

The attempt was unsuccessful because SSH asks for a password and we don't have it. Looking into ssh-keygen manual in Certificates section examples I saw that we can specify principles which are users or hosts with -n, specify that user should by zzinter:

And we are in.

Note: We are able to login as any user with forged keys from certificate, even root!

SSH (zzinter)

User.txt

SSH (2222)

Privilege Escalation (support)

Unfortunately the Authorization token decodes to garbage, but now we have some idea how to use the application.

Generate API key and try to authenticate on other box:

webadmin seemed like higher privilege so I first tried that, but without password it wouldn't auth, but support user is able to login without any password.

The box seems identical to itrc, but hosts is a bit different.

In the /etc/ssh we can find auth_principals which further has supported principles that can be used to authenticate into the box.

Going directly to root doesn't seem that easy :/

Writeup-8.png

Privilege Escalation (zzinter)

The server code seems to be living in /opt/signserv, but no read permissions. zzinter has permissions to read the sign_key.sh

Get certificate with your public key

Writeup-9.png

Turns out you can't use your own keys (kali machine), keys must come from same device in network (support).

Writeup-10.png

or just modify the previous script:

Anyway, let's inspect the script in /opt

The script uses ca-it file to verify given certificate, the file seems to be Global SSG SSH Certficiate from IT.

Privilege Escalation (root)

zzinter can run this script as root:

Unfortunately we are not able to use /etc/ssh/ca-it.

Reason being that our input CA is checked against it. If you notice the script also has a vulnerability, in the test variables are compared without quotes which is dangerous in bash

shellharden/how_to_do_things_safely_in_bash > The first thing to know about bash codingarrow-up-right

An unquoted variable is to be treated as an armed bomb: It explodes upon contact with whitespace and wildcards.

Before writing exploit let's write small test:

Writeup-11.png

With this we confirmed that using * we can match any character and essentially bruteforce the file.

Run the script and wait some time for bruteforce to finish, check the output file for certificate:

Connect to box via new certificate

Root.txt

Root Scripts

Last updated