如何通过外壳保存二进制内容?
我写了不起作用的例子
$f = file_get_contents("my.exe");
exec("echo $f > new.exe");
好吧,
也许将来有人会想要这个待办事项,没有任何人/www-data的PHP可以写入根文件
function my_file_put_contents($f, $content){
$rand_file = "/tmp/my_tmp_".uniqid('', true);
file_put_contents($rand_file, $content);
exec('sudo cp '.escapeshellarg($rand_file).' '.escapeshellarg($f).' && rm '.escapeshellarg($rand_file));
}
然后使用 visudo 编辑/etc/sudoers
www-data ALL = (ALL) NOPASSWD: /bin/rm
www-data ALL = (ALL) NOPASSWD: /bin/cp