Back to CTF Writeups
HTB // CTF WRITEUP

HackTheBox CTF: Appointment

⬤ VERY EASY 🐧 LINUX WEB SQL INJECTION
SKILLS USED
SQL Injection Login Bypass Nmap Gobuster MySQL Comment Syntax

Appointment is a Very Easy Linux box on HackTheBox focused entirely on SQL injection. The attack path is straightforward — enumerate the target, discover a web login form, and exploit a classic SQL injection vulnerability using MySQL comment syntax to bypass authentication entirely without needing a valid password.

Background Knowledge

What does the acronym SQL stand for?

Answer: Structured Query Language

What is one of the most common types of SQL vulnerabilities?

Answer: SQL Injection

What is the 2021 OWASP Top 10 classification for this vulnerability?

Answer: A03:2021-Injection
SQL Injection has been in the OWASP Top 10 for over a decade. It's one of the most common and most damaging web vulnerabilities in the real world — not just in CTFs.

Recon & Enumeration

I started with enumeration to see what open ports there are and what the system is running:

sudo nmap -sC -sV -Pn -T4 -oN scan.txt 10.129.184.107
Nmap scan results
Nmap scan — port 80 running Apache

What does Nmap report as the service and version running on port 80?

Answer: Apache httpd 2.4.38 ((Debian))

What is the standard port used for the HTTPS protocol?

Answer: 443

What is a folder called in web-application terminology?

Answer: directory

What is the HTTP response code that is returned for Not Found errors?

Answer: 404

Web Enumeration

With port 80 open I navigated to the site and found a login form. I ran Gobuster to check for any hidden directories:

gobuster dir -u http://10.129.184.107 -w /usr/share/wordlists/dirb/common.txt

What switch do we use with Gobuster to specify we're looking to discover directories, and not subdomains?

Answer: dir

Exploitation — SQL Injection

What single character can be used to comment out the rest of a line in MySQL?

Answer: #

The login form takes a username and password and passes them to a backend SQL query that looks something like this:

SELECT COUNT(*) FROM users WHERE username='INPUT' AND password='INPUT'

The key insight here is that if user input isn't sanitized, we can inject SQL syntax directly into the query. By entering admin'# as the username with any password, the ' closes the username string and the # comments out everything after it — including the password check entirely.

WHAT THE SERVER SEES

Normal query:

SELECT COUNT(*) FROM users WHERE username='admin' AND password='correctpassword'

After injection with admin'#:

SELECT COUNT(*) FROM users WHERE username='admin'#' AND password='test'

Everything after # is commented out — the password check never runs.

Login page with SQL injection
Login form — entering admin'# as username bypasses authentication

Using admin'# as the username and anything as the password I was logged straight into the admin panel and captured the flag.

Flag captured
Flag captured — admin panel accessed via SQL injection

If user input is not handled carefully, it could be interpreted as a comment. Use a comment to login as admin without knowing the password. What is the first word on the webpage returned?

Answer: Congratulations

Submit root flag:

Answer: flag captured ✓

Validation

HTB completion validation
HackTheBox completion confirmed

What I Learned

SQL injection is still everywhere. This vulnerability has been known for decades and is still in the OWASP Top 10. Any login form that doesn't properly sanitize user input is potentially vulnerable. Always test login forms with basic SQLi payloads during web enumeration.

The # character is a MySQL comment. Anything after # on the same line is ignored by MySQL. This makes it a powerful tool for manipulating SQL queries — closing strings early and commenting out conditions like password checks entirely.

Understanding what the server sees matters. The key to exploiting SQLi isn't memorizing payloads — it's understanding how the backend query is structured and how your input gets inserted into it. Once you can visualize the query, the injection becomes obvious.

Always enumerate before exploiting. Running Nmap first confirmed this was a web target on port 80. Without that step you're guessing. Enumeration tells you what attack surface exists before you start probing it.

Simple payloads often work. This box required just four characters — admin'# — to fully bypass authentication. Real-world SQLi is often just as simple on poorly secured targets. Always try the basics before reaching for complex tools.