执行脚本的 PHP 页面
我可以创建一个带有简单文本区域表单的页面,该页面将输入 PHP 代码,然后当我单击提交时,它会执行它?就像脚本页面一样?
最重要的是放置它是否安全?即使在管理员保护的页面中?
谢谢你!
can i create a page with a simple text area form, which will be entered PHP CODE and then, when i click to submit, it executes it? just like a Script page?
and most of all it is secure to put it? even in a admin protected page?
thankyou!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你想使用 PHP:eval ,不,即使在 a 后面也不安全登录墙。最好放置一些可以记录的预定义函数。
当然,根据定义,任何你设置为可访问的东西都是相当不安全的。
you want to use PHP:eval, and no it is not safe even behind a login wall. Better put some predefined function that can be logged.
And of course, by definition anything you put as accessible is quite unsafe anyway.
你当然可以:
但是,允许这样做是极其危险的。在许多其他可以执行的恶意操作中,有人可以通过 array_map("unlink", glob('*.*')); 擦除当前工作目录。
You sure can:
However, it is extremely dangerous to permit this. Someone could wipe the current working directory via
array_map("unlink", glob('*.*'));
among the many, many other malicious things that could be done.如果您允许某人在表单上编写 PHP 代码,然后在提交时获取该 PHP 代码并执行它,那么您将面临巨大的安全风险。可以做吗?当然可以,但我强烈建议不要这样做。
如果您绝对确定需要执行此操作,请阅读
eval
函数。 PHP:评估If you are allowing someone to author PHP code on a form and then, on submission, taking that PHP code and executing it, you're opening yourself up to HUGE, HUGE security risks. Is it possible to do? Sure, but I would highly recommend against doing it.
If you're absolutely sure you need to do this, read about the
eval
function. PHP: eval