PHP 使用 $_SERVER['PHP_SELF'] 时的 XSS 命令
PHP XSS command when using $_SERVER['PHP_SELF']
原例子可见here:
总结
一个表单元素:
<form method="post" action="<?php echo $_SERVER["PHP_SELF"];?>">
有人在浏览器地址栏输入一段恶意代码:http://www.example.com/test_form.php/%22%3E%3Cscript%3Ealert('hacked')%3C/script%3E
示例说明表单元素将转换为以下内容:
<form method="post" action="test_form.php/"><script>alert('hacked')</script>
虽然我明白了,但我不明白为什么
- 这甚至在网址不存在的情况下也有效。不应该
那个人得到某种错误页面说该网站
找不到?就像我们不小心输入错误一样
地址却一无所获?
- 虽然有效,但除了 "hacker"
如果更改未保存在 php 文件中,他自己会受到影响
服务器?我的意思是黑客手动输入了恶意代码
代码,他的浏览器会下载受影响的网站
页。
我一定是把一些概念搞错了,很严重。请纠正我。谢谢
This even works when the web address is nonexistent. Shouldn't that person get an error page of some kind saying that the website cannot be found? Just like when we accidentally type in a wrong address and got nothing?
如果 Web 服务器配置为允许脚本路径后的额外数据,则不会。在 Apache 中,这是由 AcceptPathInfo Directive.
配置的
Even though it works, how is anyone else besides the "hacker" himself affected if the change is not saved on the php file on the server? I mean it is the hacker who manually typed in the malicious code, and it is his browser that would download the affected web page.
XSS 攻击需要攻击者让目标访问这个 URL,这样恶意负载就会 运行 在目标的浏览器中。一种方法是诱使目标点击恶意 link.
原例子可见here:
总结
一个表单元素:
<form method="post" action="<?php echo $_SERVER["PHP_SELF"];?>">
有人在浏览器地址栏输入一段恶意代码:http://www.example.com/test_form.php/%22%3E%3Cscript%3Ealert('hacked')%3C/script%3E
示例说明表单元素将转换为以下内容:
<form method="post" action="test_form.php/"><script>alert('hacked')</script>
虽然我明白了,但我不明白为什么
- 这甚至在网址不存在的情况下也有效。不应该 那个人得到某种错误页面说该网站 找不到?就像我们不小心输入错误一样 地址却一无所获?
- 虽然有效,但除了 "hacker" 如果更改未保存在 php 文件中,他自己会受到影响 服务器?我的意思是黑客手动输入了恶意代码 代码,他的浏览器会下载受影响的网站 页。
我一定是把一些概念搞错了,很严重。请纠正我。谢谢
This even works when the web address is nonexistent. Shouldn't that person get an error page of some kind saying that the website cannot be found? Just like when we accidentally type in a wrong address and got nothing?
如果 Web 服务器配置为允许脚本路径后的额外数据,则不会。在 Apache 中,这是由 AcceptPathInfo Directive.
配置的Even though it works, how is anyone else besides the "hacker" himself affected if the change is not saved on the php file on the server? I mean it is the hacker who manually typed in the malicious code, and it is his browser that would download the affected web page.
XSS 攻击需要攻击者让目标访问这个 URL,这样恶意负载就会 运行 在目标的浏览器中。一种方法是诱使目标点击恶意 link.