【问题标题】:In WordPress, insert custom field data into file instead of database在 WordPress 中,将自定义字段数据插入文件而不是数据库
【发布时间】:2013-01-12 20:50:11
【问题描述】:

有没有办法将 WordPress 自定义字段中的数据插入自定义文件而不是 MySQL 数据库?

我想这样做的原因是因为我试图为用户设置一个自定义字段作为一种 PHP 沙箱,我想在模板文件中使用 include filename.php 并避免将 PHP 数据插入数据库和随之而来的安全漏洞,或者更糟糕的是在从数据库中检索到数据后必须使用eval

我愿意接受任何其他建议来完成此操作,但我认为最简单的方法是将数据存储在随机 php 文件中并完全绕过数据库。

【问题讨论】:

  • 你认为将用户输入的 PHP 放入服务器上的文件不是安全漏洞...?
  • 这是一个好主意,我想这是一个坏主意。

标签: php wordpress custom-fields


【解决方案1】:

让我先说:

这是个坏主意

您的想法是让最终用户上传您将在服务器上执行的 PHP 脚本。如何阻止攻击者上传这样的脚本:

<?php
// get a list of all of the wp-config.php files available to this user
$configs = shell_exec("cd ~ && find `pwd` -name wp-config.php");
// go through every match and email the contents 
// of the file to my super secret hacker email or whatever
// btw i now have mysql credentials for all of your wp sites.
?>

这甚至都没有想象力。

这里说的是怎么做

在您的 WP 网站上下载并安装 https://github.com/fyaconiello/WP_Bad_Idea 作为插件

然后将其添加到您主题的single-attack_post.php

<h3>THE CODE</h3>
<pre>
<?php include($post->attack_code); ?>
</pre>

【讨论】:

  • 谢谢,我可能最终不会这样做,似乎没有办法绕过邪恶的可能性。
猜你喜欢
  • 1970-01-01
  • 2017-04-14
  • 2016-03-03
  • 2014-12-22
  • 1970-01-01
  • 1970-01-01
  • 2014-11-20
  • 2021-06-21
  • 2018-10-18
相关资源
最近更新 更多