【原创】审计某人事管理系统

经朋友所托得到这个管理系统进行审计。

环境搭建好后一大推错误,后来验证码又不显示,折腾了好久,最后没找到原因,直接把验证码去掉了。(不涉及登陆)

跟进到认证登录处文件查看,代码如下:

直接看关键部分。

$aUser=trim($_POST["aUser"]);
$modeAUser="/^w{6,14}$/";
if(preg_match($modeAUser, $aUser)){
}else{
?>
<script type="text/javascript">
alert("用户名非法");
window.location="../index.php";
</script>
<?php
exit;

获取表单过来的user进行判断出,开始以为存在注入,因为没有进行校验和过滤。

后来才看到正则进行了匹配,密码处进行了MD5所以没办法进行闭合注入了。

$aPwd=$_POST["aPwd"];
$apassword=md5($aPwd);
$sql="select * from admin where aUser='{$aUser}'";
$number=$db->num($sql);
if($number>0){
    $rs=$db->fetchOne($sql);
    if($rs["aPwd"]==$apassword){
        $_SESSION["loginAId"]=$rs["aId"];
        $_SESSION["loginAUser"]=$rs["aUser"];
        $_SESSION["loginAName"]=$rs["aName"];
        $_SESSION["date"]=date("Y-m-d H:i:s");
        ?>
                <script type="text/javascript">
                alert("登录成功");
                window.location="main.php";
                </script>
                <?php
    }else{
        ?>
        <script type="text/javascript">
        alert("密码错误");
        window.location="../index.php";
        </script>
        <?php

        exit;

 登录进去看后发现每个admin后台下的文件都有一个头认证(身份认证)

简单的写法能绕过去,最后还是无果。

include ("configs/config.php");

跟进到config.php文件。

<?php
@session_start();
include './loginuser.php';
include 'DB.class.php';
include './libs/smarty.class.php';
$st=new Smarty();
$st->left_delimiter="<{";
$st->right_delimiter="}>";
$st->setCacheDir("./cache");
$st->setcaching(Smarty::CACHING_LIFETIME_CURRENT);
$st->setcacheLifetime(0.1);
$st->clearallcache(86400);

 就是这样,通过翻阅代码,发现一处没有带入认证文件的脚本。

 居然写成这样我是真的怀疑。

这个先别说了,我们构造一下吧。

我们直接访问就可以了。

这样插入了我们构造好的管理员了。

登录后台。

还有几处变量覆盖。

PS:不知道是程序员故意留下的后门还是粗心导致的。

原文地址:https://www.cnblogs.com/blck/p/5116235.html