黑客如何将 javascript 代码注入我的 homepage.php

发布于 2024-10-27 04:56:53 字数 502 浏览 4 评论 0原文

可能的重复:
最佳实践是什么避免 PHP 站点中的 xss 攻击

您好, 我想知道黑客如何将此 javascript 代码注入到我的 homepage.php

<script type="text/javascript">document.write('\u003c\u0069\u006d\u0067\u0020\u0073\u0072\u0063\u003d\u0022\u0068\u0074\u0074\u0070\u003a\u002f\u002f\u0061\.........')</script>

我怎样才能阻止它?

Possible Duplicate:
What are the best practices for avoid xss attacks in a PHP site

Hi,
I wonder how can hackers inject this javascript code to my homepage.php

<script type="text/javascript">document.write('\u003c\u0069\u006d\u0067\u0020\u0073\u0072\u0063\u003d\u0022\u0068\u0074\u0074\u0070\u003a\u002f\u002f\u0061\.........')</script>

How can I block this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

泅渡 2024-11-03 04:56:53

除非您有任何表单实际将内容发布到您的网站,并且最终会出现在您的 php 文件中,否则我会说他们是通过 ftp 上传的,要么是通过 ftp 服务中的漏洞,要么只是通过暴力破解。

检查您的 ftp 传输日志,看看有问题的文件是否是由未知 IP 上传的。

修补你的 ftp 守护进程并希望得到最好的结果,但我建议你要么删除 ftp 访问,要么对其进行 IP 限制。

Unless you have any forms that actually post content to your site, and this ends up in your php-files, I would say that they've uploaded it through ftp, either by a vulnerability in your ftp service or simply by bruteforce.

Check your ftp transfer logs and see if the file in question has been uploaded by an unknown IP.

Patch your ftp daemon and hope for the best, but I suggest you either remove the ftp access, or IP-restrict it.

倒数 2024-11-03 04:56:53

您向我们展示的代码仅仅是黑客攻击的结果;它几乎没有告诉我们其原因。

黑客可以通过多种方式将此类代码插入您的网站。其中一些可能是通过 Javascript 或您网站上的输入表单进行的,但也可能是通过 FTP 或服务器上的其他服务对服务器软件本身进行的黑客攻击。

您需要考虑注入代码的上下文,而不是内容。它是否直接添加到您的 PHP 程序文件中?或者您的页面是否已被修改以从其他地方提取此代码?或者这个 Javascript 是否已放入您数据库中的某个位置?您使用什么 PHP 软件(即您是否运行 Drupal 或 ZenCart 等众所周知的软件包),并且您是否将它们更新到最新版本?回答这些问题将为您提供一些帮助,帮助您确定黑客进入您网站的路线。

但在过去,当我有类似的经历时,我发现找出黑客攻击的最快方法是将被黑客攻击的部分代码输入谷歌。如果黑客攻击之前在其他地方发生过,那么结果将是其他被黑客攻击的网站和人们之前讨论过他们的经历的支持论坛之间的混合。

我发现谷歌提出的支持论坛几乎总是有一个直接的答案,或者至少你能够找到它们之间的共同线索,例如每个被这种方式攻击的人都在运行一个特定的程序基于 PHP 的包或类似的东西。

在不了解您的设置的更多信息的情况下,我无法回答更多问题,但我希望这对您有所帮助。

The code you've shown us is merely the result of a hack; it tells us very little about the cause of it.

There are a large number of ways that a hacker can insert code like this into your site. Some of them may be via Javascript or an input form on your site, but it could equally have been a hack on the server software itself, via FTP or another service on the server.

You need to consider the context of the injected code, rather than the content. Has it been added directly to your PHP program files? Or have your pages been modified to pull in this code from elsewhere? Or has this Javascript been put somewhere in your database? What PHP software are you using (ie are you running a well known package like Drupal or ZenCart, etc), and have you kept them updated to the latest versions? Answering these questions will give you some help in working out the route that the hacker took to get into your site.

But in the past, when I had similar experiences, I've found that the quickest way to find out about the hack is to past parts of the hacked code into Google. If the hack is one that's happened elsewhere before, the results will be a mix between other hacked sites and support forums where people have previously discussed their experiences.

I've found that the support forums thrown up be Google almost always either have a direct answer, or at the very least you'll be able to pick up common threads between them, such as everyone who's been hacked this way was running a particular PHP-based package, or something like that.

Without knowing more about your setup, I can't really answer any more than that, but I hope that's been of some help.

许一世地老天荒 2024-11-03 04:56:53

不要依赖通过 JavaScript 的用户输入,这是客户端。尝试使用PHP。

此处了解有关 JavaScript 注入的更多信息。

Do not rely on user input through JavaScript, this is client side. Try to use PHP.

Read more about JavaScript Injection here.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文