
HTB: Help
An exposed GraphQL endpoint hands over a user hash, which unlocks an authenticated HelpDeskZ SQL injection that leaks the admin hash. A password spray turns that into SSH, and a kernel exploit (CVE-2017-16995) finishes it off with root.
Help is a Linux box from HackTheBox. The foothold chains an exposed GraphQL endpoint into a HelpDeskZ SQL injection, and the privesc is a kernel exploit. The initial foothold took a while, so let's walk through it.
Recon
Looking at the nmap scan we see SSH on 22, Apache on 80 redirecting to help.htb, and a Node.js Express app on 3000. Let's add help.htb to our hosts file and visit the site.

It's an Apache default page, so let's run a dir buster and see if we can find anything else.

gobuster dir -u http://help.htb/ -w /usr/share/wordlists/seclists/Discovery/Web-Content/directory-list-2.3-medium.txt

There's a /support page, let's head over to that.
HelpDeskZ and the GraphQL endpoint
It's some sort of help desk running HelpDeskZ.

Looking at the URL on the Knowledgebase tab we can see there's a ?v= parameter. Maybe we can abuse this somehow.

Checking out that other port (3000), we see that it's a GraphQL endpoint.

It's exposed, so let's see what we can do with it. GraphQL introspection lets us ask the endpoint to describe its own schema:
curl -s -X POST http://help.htb:3000/graphql -H "Content-Type: application/json" -d '{"query":"{__schema{types{name fields{name}}}}"}'

We get the schema. There's a user query, and the User type has username and password fields. Let's pull those.
curl -s -X POST http://help.htb:3000/graphql -H "Content-Type: application/json" -d '{"query":"{user{username password}}"}'

Nice, we have a username and a password hash! Let's save those to our notes and crack that password. It's 32 hex characters, so MD5:
hashcat -m 0 '5d3c93182bb20f07b994a7f617e99cff' /usr/share/wordlists/rockyou.txt

We got it: godhelpmeplz. Let's log back into the help desk app and enumerate the software.
HelpDeskZ SQL injection
After a little research I found that this HelpDeskZ version has an authenticated SQL injection: Exploit-DB 41200.

Let's pull that over to our box and check it out. It's a blind injection through the ticket attachment download, so it needs a ticket with an attachment to work against (ticket 4 in the output below). We run it with the creds we just cracked:
python3 41200.py http://help.htb/support/ helpme@helpme.com godhelpmeplz

We were able to pull the admin hash, so now let's crack it with hashcat. The script labeled it as SHA-256, but it's only 40 hex characters, so this is actually SHA-1. Let's adjust the hash mode:
hashcat -m 100 admin.hash /usr/share/wordlists/rockyou.txt

Success, Welcome1. We're in business!
Password spray to SSH
Let's save this to our notes and look for a user to spray that password at. Looking back at my research, there's also an arbitrary file upload exploit for HelpDeskZ that could get us a shell. But spraying a couple of usernames over SSH first, we get a hit on the username help.

Great, let's log in via SSH:
ssh help@help.htb
Logging in and checking the home directory, we find user.txt.

Privesc: kernel exploit
Looking at the login banner we're on Ubuntu 16.04.5 with kernel 4.4.0-116-generic, which is vulnerable to a local privesc: Exploit-DB 44298, CVE-2017-16995. It abuses a bug in the kernel's eBPF verifier to get root from a normal user.
Let's pull it over, build it in /tmp and run it.

It worked and we grabbed the root.txt flag.
Closing thoughts
We were stuck on this one for a bit, and the initial foothold was the hardest part. This box was a good way to learn more about endpoints and how they can be vulnerable, especially an exposed GraphQL endpoint that hands over its whole schema. Another lesson: don't trust an exploit's label on a hash, check the length yourself. The privesc was the easiest part of it all.
