前言
ThinkPHP 5 免费企业网站管理系统hsycms 带前后台是由好生意工作室开发的一款全新的企业站后台管理系统,网址URL全伪静态处理,网址简短,易于优化。
Hsycms 企业管理系统后台是作者亲者编写的一套精美蓝色响应式后台,界面简单,美观,易于操作。
sql注入审计
首先是确定路由关系,通过查看index.php文件
define('APP_PATH', __DIR__ . '/app/');
函数功能等都在/app路径下面
public function index()
{
$id = input('id');
$one = db('article')->where('id',$id)->find();
虽然$id = input('id');也是官方的写法,但是并没有进行过滤,还是可以进行注入,
修复方式$id = input('id/d');将其强制转换一下就OK
payload,这里使用时间盲注
/news/151) and if(1<2,sleep(2),sleep(0)) and ( 1=1
xss审计
前端在留言板直接进行注入即可,并没有任何过滤,进入后台即可弹窗
app\hsycms\view\site\book.html、
<h2>留言列表</h2>
<a href="javascript:history.go(0);" class="btn fr"><i class="icon-refresh"></i> 刷新</a> </div>
<table class="table">
<tr>
<th width="100">ID</th>
<th>姓名</th>
<th>手机</th>
<th>邮箱</th>
<th>地址</th>
<th width="30%">留言内容</th>
<th>留言时间</th>
<th width="200">操作</th>
</tr>
{volist name="list" id="v"}
<tr>
<td><input type="checkbox" name="id[]" value="{$v.id}" />{$v.id}</td>
<td>{$v.name}</td>
<td>{$v.phone}</td>
<td>{$v.email}</td>
<td>{$v.address}</td>
<td>{$v.content}</td>
<td>{$v.datetime|date='Y-m-d H:i:s',###}</td>
后台模板直接拼接传入的信息
写配置文件getshell
审计过程
app/install/controller/Index.php中,首先是config方法,对传进去的db数组写进了session。之后是进入了sql方法。
在sql方法中,session中的’db_config赋值dbconfig变量,然后传进了write_config函数,跟进app/install/common.php,可以看到只是对配置模板做简单的替换,于是造成写配置文件Getshell
public function config($db = null, $admin = null) {
if (request()->IsPost()) {
//检测管理员信息
if (!is_array($admin) || empty($admin[0]) || empty($admin[1]) ) {
return $this->error('请填写完整管理员信息');
} else if ($admin[1] != $admin[2]) {
return $this->error('确认密码和密码不一致');
} else {
$info = array();
list($info['username'], $info['password'], $info['repassword'])
= $admin;
//缓存管理员信息
session('admin_info', $info);
}
//检测数据库配置
if (!is_array($db) || empty($db[0]) || empty($db[1]) || empty($db[2]) || empty($db[3]) || empty($db[4]) || empty($db[5]) || empty($db[6])) {
return $this->error('请填写完整的数据库配置');
} else {
$DB = array();
list($DB['type'], $DB['hostname'], $DB['database'], $DB['username'], $DB['password'],
$DB['hostport'], $DB['prefix']) = $db;
//缓存数据库配置
session('db_config', $DB);
//创建数据库
$dbname = $DB['database'];
unset($DB['database']);
$db = \think\Db::connect($DB);
$sql = "CREATE DATABASE IF NOT EXISTS `{$dbname}` DEFAULT CHARACTER SET utf8";
if (!$db->execute($sql)) {
return $this->error($db->getError());
} else {
return $this->redirect('install/index/sql');
}
}
} else {
$this->status['index'] = 'success';
$this->status['check'] = 'success';
$this->status['config'] = 'primary';
$this->assign('status', $this->status);
return $this->fetch();
}
}
public function sql() {
session('error', false);
$this->status['index'] = 'success';
$this->status['check'] = 'success';
$this->status['config'] = 'success';
$this->status['sql'] = 'primary';
$this->assign('status', $this->status);
echo $this->fetch();
if (session('update')) {
$db = \think\Db::connect();
//更新数据表
update_tables($db, config('prefix'));
} else {
//连接数据库
$dbconfig = session('db_config');
$db = \think\Db::connect($dbconfig);
//创建数据表
create_tables($db, $dbconfig['prefix']);
//注册创始人帐号
$admin = session('admin_info');
register_administrator($db, $dbconfig['prefix'], $admin);
//创建配置文件
$conf = write_config($dbconfig);
session('config_file', $conf);
}
if (session('error')) {
show_msg('失败');
} else {
echo '<script type="text/javascript">location.href = "'.url('install/index/complete').'";</script>';
}
}
public function complete() {
$this->status['index'] = 'success';
$this->status['check'] = 'success';
$this->status['config'] = 'success';
$this->status['sql'] = 'success';
$this->status['complete'] = 'primary';
$this->assign('status', $this->status);
$this->assign('status', $this->status);
return $this->fetch();
}
}
并没有什么过滤,直接就写入数据库和文件app\database.php中
在数据库名称这里构造一句话进行写shell。
![图片[1]-Hsycms2.0代码审计-渗透云记 - 专注于网络安全与技术分享](https://b.encenc.com/wp-content/uploads/2023/06/d2b5ca33bd202847.png)
![图片[2]-Hsycms2.0代码审计-渗透云记 - 专注于网络安全与技术分享](https://b.encenc.com/wp-content/uploads/2023/06/d2b5ca33bd202939.png)
© 版权声明
渗透云记的技术文章仅供参考,此文所提供的信息只为网络安全人员对自己所负责的网站、服务器等(包括但不限于)进行检测或维护参考,未经授权请勿利用文章中的技术资料对任何计算机系统进行入侵操作。利用此文所提供的信息而造成的直接或间接后果和损失,均由使用者本人负责。
渗透云记拥有对此文章的修改、删除和解释权限,如转载或传播此文章,需保证文章的完整性,未经允许,禁止转载!
本文所提供的工具仅用于学习,禁止用于其他,请在24小时内删除工具文件!!!访问本博客请务必遵守有关互联网的相关法律、规定与规则。一旦您访问本博客,即表示您已经知晓并接受了此声明通告。详情见本站的“免责声明”如果有侵权之处请第一时间联系我们删除。敬请谅解!E-mail:admin@encenc.com
THE END















请登录后查看评论内容