Gavel (HTB)

Enumeration.

# Nmap 7.97 scan initiated Sat Dec  6 12:02:21 2025 as: nmap -sS -A -v -o scan.nmap 10.10.11.97
Nmap scan report for 10.10.11.97
Host is up (0.010s latency).
Not shown: 998 closed tcp ports (reset)
PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 8.9p1 Ubuntu 3ubuntu0.13 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey: 
|   256 1f:de:9d:84:bf:a1:64:be:1f:36:4f:ac:3c:52:15:92 (ECDSA)
|_  256 70:a5:1a:53:df:d1:d0:73:3e:9d:90:ad:c1:aa:b4:19 (ED25519)
80/tcp open  http    Apache httpd 2.4.52
|_http-server-header: Apache/2.4.52 (Ubuntu)
| http-methods: 
|_  Supported Methods: GET HEAD POST OPTIONS
|_http-title: Did not follow redirect to http://gavel.htb/
Device type: general purpose|router
Running: Linux 4.X|5.X, MikroTik RouterOS 7.X
OS CPE: cpe:/o:linux:linux_kernel:4 cpe:/o:linux:linux_kernel:5 cpe:/o:mikrotik:routeros:7 cpe:/o:linux:linux_kernel:5.6.3
OS details: Linux 4.15 - 5.19, MikroTik RouterOS 7.2 - 7.5 (Linux 5.6.3)
Uptime guess: 20.698 days (since Sat Nov 15 19:18:04 2025)
Network Distance: 2 hops
TCP Sequence Prediction: Difficulty=261 (Good luck!)
IP ID Sequence Generation: All zeros
Service Info: Host: gavel.htb; OS: Linux; CPE: cpe:/o:linux:linux_kernel

TRACEROUTE (using port 256/tcp)
HOP RTT      ADDRESS
1   10.51 ms 10.10.14.1
2   10.54 ms 10.10.11.97

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 at Sat Dec  6 12:02:35 2025 -- 1 IP address (1 host up) scanned in 13.38 seconds

Classic machine let's check the website

Enumerating the web server.

Basically the website is like a game where you can bid for items. This is not where we going to focus on using dirsearch we can find the .git exposed.

Using git-dumper.

We can get the whole .git folder from the web site.

This command will give us the .git folder in the gavel-git .

Code analysis.

There is two thing we going to consider and focus on here.

  • SQL injection in inventory.php

Here is a thing we can notice that the $col is a variable that can fetch a column from the database. The thing is that when the perpare statment is calidating the user input it does not validate this one. So we can use it to exploit the SQLI. I have talk a lot about how is work in this artical.

  • Second in the file bid_handler.php:55

Here we have the function runkit_function_add used to allow function definition in run time (while the code is executing) So if we can control the $rule then we can define a function to execute.

Exploiting SQL injection.

Beside what is mentioned in the artical

Let's see the exploit.

  1. In the path http://gavel.htb/inventory.php we can find a sort function that sort our items.

  2. Let's intercept the request.

Using these two fields we can achieve SQL injection.

  1. Collect the passwords and save them into a file to crack them.

Now that we have these creds we can login into that user which is the admin.

Getting RCE.

Very cool let's see what's in there.

Basically this what we have discuss if we are able to change the rule which is true in this case we can execute php code.

so am going to use this payload.

Just notice that the function must return true. At least in my case.

Now let's change this with any message and let's place a bid in the Bidding tab in order to our function to be executed.

and then in the Bidding we just need to place a bid .

And if you do not forgot to start a listener.

From auctioneer to root.

Then using this command we can switch into the auctioneer user which I found in the /etc/passwd . And the password shall be the same that we crack.

then using the id command we can see this.

Our user is a member of another group. Let's see what that group has.

This command will show us all the files that belongs to the gavel-seller group.

Cool we have these two files. After investigation and clearly seen here gaveld .

Anyway knowing that we can check this services status.

We can see the config file too here. Let's see what it contains.

So the daemon executable exist there in /opt/gavel/gaveld . Surly we can reverse engineer it to find what it has but let's see what we got there first.

There we going to find a file called sample.yaml

So basically using the gavel-util tool when can communicate with that service the help menu for it shows us more.

So we can submit a YAML file but if we send this sample we going to find this.

so we need to construct these again in a YAML file. But notice the rule field takes a function so if it not filtered or protected then we can execute PHP code as root. But let's see what protection this php engine has.

We can find these protections in /opt/gavel/.config/php/php.ini

And as we can see no protection is there so we can execute PHP code.

Am going to use this payload.

This just simple add suid bit into the bash executable so that when executed it will give us the privilege of the owner of the file which is root .

After putting the payload into p.yaml run it and we shall find what we want.

Cool one thing to not before we move on and we going to discuss later. Is that we shall return false when running out PHP code for reason I will be covering later on.

We just need to add the -p flag to prevent it from dropping our privilege.

Problem discussion.

Last updated