• [BJDCTF2020]EasySearch


    [BJDCTF2020]EasySearch
    在这里插入图片描述
    一个登陆页面,尝试了弱口令 爆破 注入无果
    扫描目录发现index.php.swp

    
    	ob_start();
    	function get_hash(){
    		$chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()+-';
    		$random = $chars[mt_rand(0,73)].$chars[mt_rand(0,73)].$chars[mt_rand(0,73)].$chars[mt_rand(0,73)].$chars[mt_rand(0,73)];//Random 5 times
    		$content = uniqid().$random;
    		return sha1($content); 
    	}
        header("Content-Type: text/html;charset=utf-8");
    	***
        if(isset($_POST['username']) and $_POST['username'] != '' )
        {
            $admin = '6d0bc1';
            if ( $admin == substr(md5($_POST['password']),0,6)) {
                echo "";
                $file_shtml = "public/".get_hash().".shtml";
                $shtml = fopen($file_shtml, "w") or die("Unable to open file!");
                $text = '
                ***
                ***
                

    Hello,'.$_POST['username'].'

    *** ***'
    ; fwrite($shtml,$text); fclose($shtml); *** echo "[!] Header error ..."; } else { echo ""; }else { *** } *** ?>
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36

    代码审计:

    if(isset($_POST['username']) and $_POST['username'] != '' )
        {
            $admin = '6d0bc1';
            if ( $admin == substr(md5($_POST['password']),0,6)) {
                echo "";
    
    • 1
    • 2
    • 3
    • 4
    • 5

    只要密码的md5值的前6位为6d0bc1即可登陆成功
    参考爆破密码脚本:

    import hashlib
    
    for i in range(1000000000):
        a = hashlib.md5(str(i).encode('utf-8')).hexdigest()#获取摘要值
        if a[0:6] == '6d0bc1':
            print("find password!"+str(i))
            break
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7

    在这里插入图片描述
    得到密码为 2020666

    接着看到shtml页面
    在这里插入图片描述
    SSI注入参考:SSI注入
    代码中生成了一个shtml页面,登陆后无法查看,抓包观察返回包:
    在这里插入图片描述
    访问该页面:
    在这里插入图片描述
    得到登陆信息

    这里用到shtml,HTML是静态的,而shtml基于SSI技术,当有服务器端可执行脚本时被当作一种动态编程语言,所以可以注入,也可以用来远程命令执行。

    它的注入格式是这样的:
    所以只需要将username设置为payload即可
    首先探测根目录:
    在这里插入图片描述
    在这里插入图片描述
    根目录没有,那查看当前目录:
    也没有
    查看上级目录:
    在这里插入图片描述
    找到flag文件
    查看flag:username=&&password=2020666
    在这里插入图片描述

  • 相关阅读:
    BeanFactory和FactoryBean区别(附BeanFactory和ApplicationContext的区别)
    c盘文件误删怎么恢复?这里介绍四种方法,赶紧看过来
    Vue中作用域插槽的简单使用
    基于反步积分滑模摩擦补偿的光电伺服转台控制
    Layui之用户(CURD)
    C#开源项目:私有化部署LLama推理大模型
    复习笔记bak
    给电脑一键重装系统之后扩展卷不能选怎么解决
    RocketMQ知识点总结
    【python学习】基础篇-常用模块-argparse模块:用于解析命令行参数和选项
  • 原文地址:https://blog.csdn.net/pakho_C/article/details/126049432