Opera 中的欺骗 UserAgent

发布于 2024-09-02 03:04:35 字数 1116 浏览 2 评论 0原文

我试图将 Opera(在 Linux 下)伪装成另一个浏览器,在本例中是 iPad,用于某些测试目的。 现在我知道网站可以检查哪个浏览器正在访问它,例如在 PHP $useragent = $_SERVER['HTTP_USER_AGENT']; 和 JavaScript navigator.userAgent 中(或navigator.platform)。

在 Firefox 中,您可以使用插件轻松切换用户代理和其他相关信息,但在 Opera 中似乎有点难做到。

首先在 opera.ini 中您可以执行以下操作:

[User Agent]
Spoof UserAgent ID=1

但这仅限于预定义的 UserAgent 列表。没有空间容纳定制的。

同样在 opera.ini

[ISP]
Id=iPad

这会将 iPad 添加到 Opera 的用户代理中。这是一个开始,大部分时间都可以在网站上运行。

opera.ini 中,您可以设置“用户 JavaScript 文件”以在加载网站之前加载自定义 JavaScript 文件:

[User Prefs]
User JavaScript File=/opera_dir/userjs/load.js

load.js 中,您可以执行以下操作:

navigator.userAgent = "Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B334b Safari/531.21.10"

因为此文件获取在加载网站之前执行我可以修改 UserAgent,但是当站点通过 PHP 检查 UserAgent 时这将不起作用,但它适用于使用 JavaScript 检查的站点。

是否有另一种方法来欺骗完整的自定义 UserAgent?

I'm trying to spoof Opera (under Linux) to be another browser, in this case iPad for some testing purposes.
Now I know sites can check which browser is accessing it using, for example, in PHP $useragent = $_SERVER['HTTP_USER_AGENT']; and in JavaScript navigator.userAgent (or navigator.platform).

In Firefox you can use an addon to easily switch your user agent and other relevant information, but in Opera it seems it bit hard to do.

First in opera.ini you can do:

[User Agent]
Spoof UserAgent ID=1

But this is limited to a predefined list of UserAgents. No room for custom ones.

Also in opera.ini

[ISP]
Id=iPad

This will add iPad to the User Agent of Opera. It's a start and works most of the time on the sites.

In opera.ini you can set a 'User JavaScript file' to load a custom JavaScript file before loading a website:

[User Prefs]
User JavaScript File=/opera_dir/userjs/load.js

In load.js you can do:

navigator.userAgent = "Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B334b Safari/531.21.10"

Because this file gets executed before loading the website I can modify the UserAgent, but this won't work when a site is checking the UserAgent via PHP, but it works for sites checking with JavaScript.

Is there another way of spoofing a complete custom UserAgent?

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

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

发布评论

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

评论(2

千秋岁 2024-09-09 03:04:35

你不能。在桌面 Opera 中,就是这样。

http://labs.opera.com 上找到的一些自定义(“GOGI”类型)开发人员版本可能会提供opera:config#UserPrefs|CustomUser-Agent 选项,您可以在其中指定整个 UA 字符串(不久前发布的版本现在已经相当旧了)。也许您更适合使用设备 SDK 工具?看看 http://dev.opera.com/sdk/

You can't. In desktop Opera, that is.

Some custom ("GOGI"-type) developer builds found on http://labs.opera.com might offer the opera:config#UserPrefs|CustomUser-Agent option where you can specify the entire UA string (the builds that were released a while back are rather old by now). Perhaps you'd be better of with the device SDK tools? Have a look at http://dev.opera.com/sdk/

紫竹語嫣☆ 2024-09-09 03:04:35

您可以使用网络代理完成同样的任务。我会推荐尝试一下
Charles Web 调试代理。来自charles proxy的介绍:

Charles 是一个 HTTP 代理 / HTTP
监视器/反向代理,启用
开发人员可以查看所有 HTTP 和
它们之间的 SSL/HTTPS 流量
机和互联网。这
包括请求、响应和
HTTP 标头(其中包含
cookie 和缓存信息)。

You can accomplish the same feat using a web-proxy. I'll recommend to try out
Charles Web Debugging Proxy. From the charles proxy introduction:

Charles is an HTTP proxy / HTTP
monitor / Reverse Proxy that enables a
developer to view all of the HTTP and
SSL / HTTPS traffic between their
machine and the Internet. This
includes requests, responses and the
HTTP headers (which contain the
cookies and caching information).

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