什么是 reCAPTCHA Enterprise?
现在,reCAPTCHA Enterprise 是谷歌著名安全系统的一个版本,专为安全性要求较高的网站和应用程序而设计。与普通的 reCAPTCHA v2 和 v3 版本相比,它提供了更多的功能和改进的安全机制,因此更适合大型公司、金融机构和其他处理敏感数据的组织使用。
特性和优点
应用了比标准版本更复杂的安全机制。尽管验证方法相同(v2 要求用户执行特定任务,而 v3 则执行行为分析),但企业版具有以下几个显著优势:
- 灵活的定制和详细的分析.在 reCAPTCHA Enterprise 中,网站管理员可以进行更深入的自定义和高级分析。这是主要的重要优势,它允许微调风险评估的阈值,并将用户行为、操作率和位置等其他因素考虑在内。
- 尽量减少误报 。由于使用了复杂的算法和风险分析,reCAPTCHA Enterprise 可以减少误报的数量。这对于拥有大量用户的大型公司和服务来说尤为重要,因为错误会导致真正的客户被阻止。与 reCAPTCHA v2 不同的是,在 reCAPTCHA v2 中,错误可能是显而易见的(例如选择错误的图片),而在企业版中,分析更为全面,还包括用户行为和声誉等其他因素。
- 详细报告.提供有关交互的详细信息,包括根据风险状况阻止或标记的原因。
Enterprise v2 和 v3 有哪些区别?
与标准版本(非企业版)类似,这些版本在验证用户的方式上有所不同:
reCAPTCHA v2:
用户必须解决一个基于视觉或文本的挑战(例如,用户必须解决一个基于视觉或文本的挑战(例如,用户必须解决一个基于视觉或文本的挑战))。g.,选择带有交通灯的图像)或勾选 "我不是机器人 "框。复选可以是明确的(基于挑战),并要求用户参与。适用于表单、输入和其他单个验证点。
reCAPTCHA v3:
后台运行的隐形检查。它会评估用户在页面上的行为,并给出 0.0 到 1.0 的风险分数(其中 1.0 代表真实用户,0.0 代表可能的僵尸)。开发人员可根据分数决定采取何种措施(例如阻止访问、要求额外验证)。它是监控网站活动、保护支付页面和分析流量的理想工具。
如何确定 Enterprise 版本?
要确定网页是否使用了 reCAPTCHA Enterprise,请打开 Browser Developer Tools 并检查页面的源代码:
- 查找特定查询,查看 URL 和查询参数。如果查询包含类似这样的域:/enterprise,这表明使用了 reCAPTCHA Enterprise.
- 在标准版本中会有一个 URL:...recaptcha/api2/
交互的自动化
这种验证码类型可以有效保护网站免受黑客攻击和其他恶意活动。不过,为了达到高尚的目的,可能需要与 reCAPTCHA Enterprise 进行自动化交互。自动解决此类验证码是一项复杂的任务,需要深厚的技术知识,因此求助于特殊服务会更容易,例如, CapMonster Cloud 。这项服务利用人工智能的能力,快速高效地解决验证码问题,大大减少了时间和经济成本。如果您的活动与以下方向相关联,它将成为您不可或缺的助手:
- 测试自动化: 开发人员可以为使用 reCAPTCHA 的 Web 应用程序创建自动化测试。要使测试正确运行,您需要模拟其解决方案。
- 质量保证 (QA): 质量工程师可以检查系统性能,包括验证码通过或失败时网站的行为。
- 价格和竞争对手监控: 价格监控公司可以使用自动化功能从安装了验证码的网站收集产品和服务数据。
- 研究数据分析: 科学家和分析师可以为经济、社会或科学研究收集数据。
- Pentestas: 信息安全专家测试网络应用程序的漏洞,包括对机器人和攻击的抵抗能力。
- 漏洞分析:自动验证码解题还可以帮助那些因行动不便或视觉障碍而难以通过 reCAPTCHA 的用户。
在这种情况下,专门的技术可以提供一种更方便、更易于访问的方式来与网站进行交互。
使用CapMonster Cloud的解决方案
该服务通过浏览器扩展解决 reCAPTCHA Enterprise 问题(适用于 Chrome and Firefox)和 API。如果您需要使用 API 将验证码解决集成到您的代码中,请按照以下步骤操作:
- Create an account at CapMonster Cloud 充值您的余额,从您的个人账户获取 API 密钥 - 您需要它来进行集成。
- 从 documentation 通过该服务成功解决验证码所需的条件:
查询参数
CapMonster 云 支持 reCAPTCHA Enterprise 第 2 版解决方案。使用两种任务类型 - RecaptchaV2EnterpriseTaskProxyless(无代理)和 RecaptchaV2EnterpriseTask(使用代理)。它们之间的区别是:
RecaptchaV2EnterpriseTaskProxyless:
此类任务不需要指定代理。 CapMonster Cloud 使用自己的代理服务器来解决验证码问题。适用于不需要使用特定地区的 IP 地址或确保用户 IP 与验证码解决服务器匹配的简单任务。
RecaptchaV2EnterpriseTask:
要求指定一个代理服务器来解决验证码问题。这样就可以模拟来自特定 IP 地址的请求。如果网站在解决验证码问题时检查 IP 地址是否匹配,或要求从特定国家访问,则有必要这样做。在有地理或 IP 限制的网站上,可提高成功解决的概率。38;margin-bottom:0pt;margin-top:0pt;" dir="ltr">选择最适合您要求的任务类型,并根据您的选择探索其他选项:
type<string>mandatory
RecaptchaV2EnterpriseTaskProxyless
websiteURL<string>required
解决验证码问题的页面地址。
websiteKey<string>required
登陆页面上的 reCAPTCHA 识别码密钥。
<div class="g-recaptcha" data-sitekey="THIS_ONE"></div>;
或 <iframe title="reCAPTCHA" src="...;k=6LdIFr0ZAAAAAAAO3vz0O0OQrtAefzdJcWQM2TMYQH&...其中 6LdIFr0ZAAAAAO3vz0O0O0OQrtAefzdJcWQM2TMYQH 是网站关键字
enterprisePayload<string>optional
reCAPTCHA Enterprise 部件的某些实现可能会在结构上包含一个额外的 s 字段,该字段将与 sitekey 一起传递给 grecaptcha.enterprise.render 方法。例如:2JvvUXHNTnZl1Jb6WEvbDyB...ugQA of <pre lang="js" ><code>grecaptcha.enterprise.render("some-div-id", { sitekey:"6Lc_aCMTAAAAABx7u2N2N0D1XnVbI_v6ZdbM6rYf16" theme:"dark" s:"2JvUXHNTnZl1Jb6WEvbDyB...ugQA" });</code></pre>;
apiDomain<string>optional
加载 reCAPTCHA 企业的域名地址。例如
- www.google.com
- www.recaptcha.net
除非知道参数的用途,否则请勿使用。
userAgent<string>optional
模拟中使用的浏览器用户代理。必须使用现代浏览器签名,否则 Google 将返回错误信息,要求您更新浏览器。
cookies<字符串>可选
与登陆页面交互时必须使用的附加 cookie。
格式:cookiename1=cookievalue1; cookiename2=cookievalue2
type<string>optional
RecaptchaV2EnterpriseTask
websiteURL<string>required
解决验证码的页面地址。
websiteKey<string>mandatory
登陆页面上的 reCAPTCHA 识别码密钥。
<div class="g-recaptcha" data-sitekey="THIS_ONE"></div>;
或 <iframe title="reCAPTCHA" src="...;k=6LdIFr0ZAAAAAAAO3vz0O0OQrtAefzdJcWQM2TMYQH&...其中 6LdIFr0ZAAAAAO3vz0O0O0OQrtAefzdJcWQM2TMYQH 是网站关键字
enterprisePayload<string>optional
reCAPTCHA Enterprise 部件的某些实现可能会在结构上包含一个额外的 s 字段,该字段将与 sitekey 一起传递给 grecaptcha.enterprise.render 方法。
例如:2JvvUXHNTnZl1Jb6WEvbDyB...ugQA of <pre lang="js" ><code>grecaptcha.enterprise.render("some-div-id", { sitekey:"6Lc_aCMTAAAAABx7u2N2N0D1XnVbI_v6ZdbM6rYf16" theme:"dark" s:"2JvUXHNTnZl1Jb6WEvbDyB...ugQA" });</code></pre>;
apiDomain<string>optional
加载 reCAPTCHA 企业的域名地址。例如
- www.google.com
- www.recaptcha.net
除非知道参数的用途,否则请勿使用。
userAgent<string>optional
模拟中使用的浏览器用户代理。必须使用现代浏览器签名,否则 Google 将返回错误信息,要求您更新浏览器。
cookies<字符串>可选
与登陆页面交互时必须使用的附加 cookie。
格式:cookiename1=cookievalue1; cookiename2=cookievalue2
proxyType<string>mandatory
http - 普通 http/https 代理;
https - 仅当 "http "不起作用时才使用该选项(某些自定义代理需要);
socks4 - socks4 代理;
socks5 - socks5 代理。
proxyAddress<string>mandatory
IPv4/IPv6 代理的 IP 地址。不允许:
使用主机名;
使用透明代理(可以看到客户端 IP);
在本地机器上使用代理。
proxyPort<整数>必填
代理端口。
proxyLogin<字符串>可选
代理服务器登录名。
proxyPassword<string>optional
代理服务器的密码。
任务创建方法
Use POST method:
https://api.capmonster.cloud/createTask
What the query should look like:
{{
"clientKey":"API_KEY"、
"task":{
{ "type":"RecaptchaV2EnterpriseTaskProxyless"、
"websiteURL":"https://mydomain.com/page-with-recaptcha-enterprise"、
"websiteKey":"6Lcg7CMUAAAAAANphynKgn9YAgA4tQ2KI_iqRyTwd"、
"enterprisePayload":{
"s":"some_additional_token".
}
}
}
成功回复:
{{
"errorId":0、
"taskId":407533072
}
获取任务结果的方法
Use method getTaskResult获取解决方案。根据系统负载情况,您将在 10 秒至 80 秒后得到响应。使用 POST 方法:
https://api.capmonster.cloud/getTaskResult
请求:
{
"clientKey":"API_KEY"、
"taskId":407533072
}
成功回复:
{{
"errorId":0、
"status":"ready"、
"solution":{
"gRecaptchaResponse":"3AHJ_VuvYIBNBW5yyv0zRYJ75VkOKvhKj9_xGBJKnQimF72rfoq3Iy-DyGHMwLAo6a3".
}
}
gRecaptchaResponse - 将哈希值替换到表单中的 reCAPTCHA Enterprise 中 <textarea id="g-recaptcha-response" ..></textarea>.长度介于 500 和 2190 字节之间。
使用官方CapMonster Cloud库的代码示例
For your convenience, the service has its own libraries 用于自动解决多种类型的验证码。让我们以 C#、Python 和 JavaScript 为例:
C#。
https://github.com/CapMonsterCloud/capmonstercloud-client-dotnet
RecaptchaV2EnterpriseProxyless
使用 Zennolab.CapMonsterCloud.Requests;
Zennolab.CapMonsterCloud.Requests
类 程序
{
static async Task Main(string[] args)
{
var clientOptions = new ClientOptions
{
ClientKey = "your_api_key" // 替换为您从 CapMonster Cloud 获取的 API 密钥
};
var cmCloudClient = CapMonsterCloudClientFactory.Create(clientOptions);
var recaptchaV2EnterpriseRequest = new RecaptchaV2EnterpriseProxylessRequest
{
WebsiteUrl = "https://example.com", // 带验证码的网站地址
WebsiteKey = "6Lf56sWnAAAAAIKLuWNYgRsFUfmI-5Lex3xT5N-s", // 替换为网站密钥。
EnterprisePayload = "{\"s\":\"SOME_ADDITIONAL_TOKEN\"}"// 附加令牌(如果需要)
};
var recaptchaV2EnterpriseResult = await cmCloudClient.SolveAsync(recaptchaV2EnterpriseRequest);
Console.WriteLine("Captcha Solution: " + recaptchaV2EnterpriseResult.Solution.Value); // 输出验证码解决方案结果
}
}
ReCaptchaV2Enterprise
使用 Zennolab.CapMonsterCloud.Requests;
使用 Zennolab.CapMonsterCloud.Requests;使用 Zennolab.CapMonsterCloud.Requests
类 程序
{
static async Task Main(string[] args)
{
var clientOptions = new ClientOptions
{
ClientKey = "your_api_key" // 替换为您的 CapMonster 云 API 密钥
};
var cmCloudClient = CapMonsterCloudClientFactory.Create(clientOptions);
var recaptchaV2EnterpriseRequest = new RecaptchaV2EnterpriseRequest
{
WebsiteUrl = "https://example.com", // 带验证码的网站地址
WebsiteKey = "6Lf56sWnAAAAAIKLuWNYgRsFUfmI-5Lex3xT5N-s", // 替换为网站密钥。
EnterprisePayload = "{\"s\":\"SOME_ADDITIONAL_TOKEN\"}", // 附加令牌(如果需要)。
ProxyType = ProxyType.Http, // 代理类型
ProxyAddress = "8.8.8.8.8", // ProxyAddress
代理服务器端口 = 8080, //代理服务器端口
代理登录 = "proxyLoginHere", // 代理登录(如需要)
代理密码 = "proxyPasswordHere" // 代理密码(如需要)
};
var recaptchaV2EnterpriseResult = await cmCloudClient.SolveAsync(recaptchaV2EnterpriseRequest);
Console.WriteLine("Captcha Solution: " + recaptchaV2EnterpriseResult.Solution.Value); // 输出验证码解决方案结果
}
}
Python。
https://github.com/CapMonsterCloud/capmonstercloud-client-python
RecaptchaV2EnterpriseProxyless
导入 asyncio
from capmonstercloudclient import CapMonsterClient, ClientOptions
from capmonstercloudclient.requests import RecaptchaV2EnterpriseProxylessRequest
client_options = ClientOptions(api_key="your_api_key") # 替换为您的 CapMonster 云 API 密钥
cap_monster_client = CapMonsterClient(options=client_options)
recaptcha2request = RecaptchaV2EnterpriseProxylessRequest(
websiteUrl="https://example.com", # 带有验证码的网站地址。
websiteKey="6Lf56sWnAAAAAIKLuWNYgRsFUfmI-5Lex3xT5N-s", # 替换为您的 websiteKey。
enterprisePayload={ # 附加令牌(如需要)
{ "s":"some_additional_token".
}
)
async def solve_captcha():
返回 await cap_monster_client.solve_captcha(recaptcha2request)
responses = asyncio.run(solve_captcha())
print(responses) # 打印验证码解决方案
ReCaptchaV2Enterprise
导入 asyncio
from capmonstercloudclient import CapMonsterClient, ClientOptions
从 capmonstercloudclient.requests 导入 RecaptchaV2EnterpriseRequest
client_options = ClientOptions(api_key="your_api_key") # 替换为您的 CapMonster 云 API 密钥
cap_monster_client = CapMonsterClient(options=client_options)
recaptcha2request = RecaptchaV2EnterpriseRequest(
websiteUrl="https://example.com", # 验证码网站的地址
websiteKey="6Lf56sWnAAAAAIKLuWNYgRsFUfmI-5Lex3xT5N-s", # 替换为您的 websiteKey。
enterprisePayload={ # 附加令牌(如需要)
{ "s":"some_additional_token".
}、
proxy_type="http", # 代理类型(http、https、socks5)
proxy_address="8.8.8.8.8", # 代理服务器地址
proxy_port=8080, # 代理服务器端口
proxy_login="proxyLoginHere", # 代理登录(如需要)
proxy_password="proxyPasswordHere", # 代理密码(如需要)
)
async def solve_captcha():
return await cap_monster_client.solve_captcha(recaptcha2request)
responses = asyncio.run(solve_captcha())
print(responses) # 输出验证码解决方案
JavaScript(基于浏览器)
https://github.com/CapMonsterCloud/capmonstercloud-client-js
RecaptchaV2EnterpriseProxyless
import { CapMonsterCloudClientFactory, ClientOptions, RecaptchaV2EnterpriseProxylessRequest } from '@zennolab_com/capmonstercloud-client';
document.addEventListener('DOMContentLoaded', async () => {
const cmcClient = CapMonsterCloudClientFactory.Create(new ClientOptions({ clientKey: '<your capmonster.cloud API key>' })); // 替换为您的 CapMonsterCloud API 密钥
const recaptchaV2EnterpriseRequest = new RecaptchaV2EnterpriseProxylessRequest({
websiteURL:'https://mydomain.com/page-with-recaptcha-enterprise', // Captcha website URL
websiteKey: '6Lf56sWnAAAAAIKLuWNYgRsFUfmI-5Lex3xT5N-s', // 替换为您的 websiteKey。
enterprisePayload:{
s:'SOME_ADDITIONAL_TOKEN',// 附加令牌(如需要)
}、
});
console.log(await cmcClient.Solve(recaptchaV2EnterpriseRequest));
});
RecaptchaV2Enterprise
import { CapMonsterCloudClientFactory, ClientOptions, RecaptchaV2EnterpriseRequest } from '@zennolab_com/capmonstercloud-client';
document.addEventListener('DOMContentLoaded', async () => {
const cmcClient = CapMonsterCloudClientFactory.Create(new ClientOptions({ clientKey: '<your capmonster.cloud API key>' })); // 替换为您的 CapMonsterCloud API 密钥
const recaptchaV2EnterpriseRequest = new RecaptchaV2EnterpriseRequest({
websiteURL:'https://mydomain.com/page-with-recaptcha-enterprise', //带有验证码的网站地址
websiteKey: '6Lf56sWnAAAAAIKLuWNYgRsFUfmI-5Lex3xT5N-s', // 替换为您的 websiteKey。
enterprisePayload:{
s:'SOME_ADDITIONAL_TOKEN',// 附加令牌(如需要)
}、
proxyType:http', //代理类型(http、https、socks5)
proxyAddress:8.8.8.8.8',// 代理服务器端口
proxyPort: 8080, // ProxyServerPort
proxyLogin:proxyLoginHere',// 代理登录(如果需要)
proxyPassword:'proxyPasswordHere', // 代理密码(如需要)
userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36'、
});
console.log(await cmcClient.Solve(recaptchaV2EnterpriseRequest));
});
JavaScript(使用 Node.js)
// https://github.com/CapMonsterCloud/capmonstercloud-client-js
RecaptchaV2EnterpriseProxyless
const { CapMonsterCloudClientFactory, ClientOptions, RecaptchaV2EnterpriseProxylessRequest }.= require('@zennolab_com/capmonstercloud-client');
async function run() {
const cmcClient = CapMonsterCloudClientFactory.Create(new ClientOptions({ clientKey: 'your_api_key' })); // 替换为来自 CapMonsterCloud 的 API 密钥
const recaptchaRequest = new RecaptchaV2EnterpriseProxylessRequest({
websiteURL:'https://example.com/', // 包含验证码的网站地址
websiteKey: '6Lf56sWnAAAAAIKLuWNYgRsFUfmI-5Lex3xT5N-s', // 替换为您的 websiteKey。
enterprisePayload:{
s:'SOME_ADDITIONAL_TOKEN', //附加令牌(如需要)
}、
});
const response = await cmcClient.Solve(recaptchaRequest);
if (!response?.solution) throw new Error('Captcha not solved.');
console.log('Captcha not solved:', response.solution);
}
run()
.then() => {
console.log('DONE');
process.exit(0);
})
.catch((err) => {
console.error(err);
process.exit(1);
});
;
RecaptchaV2Enterprise
const { CapMonsterCloudClientFactory, ClientOptions, RecaptchaV2EnterpriseRequest, ProxyType }= require('@zennolab_com/capmonstercloud-client');
async function run() {
const cmcClient = CapMonsterCloudClientFactory.Create(
new ClientOptions({ clientKey: 'your_api_key' }) // 替换为您的 CapMonsterCloud API 密钥
);
const recaptchaRequest = new RecaptchaV2EnterpriseRequest({
websiteURL:'https://example.com/', //带有验证码的网站地址
websiteKey: '6Lf56sWnAAAAAIKLuWNYgRsFUfmI-5Lex3xT5N-s', // 替换为您的 websiteKey。
enterprisePayload:{
s:'SOME_ADDITIONAL_TOKEN', //附加令牌(如需要)
}、
proxyType:ProxyType.Http, // 代理类型(http、https、socks5)
proxyAddress:8.8.8.8.8', // 代理服务器地址
proxyPort:8080, //代理服务器端口
proxyLogin:proxyLoginHere', //代理登录(如需要)
proxyPassword: 'proxyPasswordHere', // 代理密码(如需要)
userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36' // 使用最新的 UserAgent。
});
const response = await cmcClient.Solve(recaptchaRequest);
if (!response?.solution) throw new Error('Captcha not solved.');
console.log('Captcha not solved:', response.solution);
}
运行()
.then() => {
console.log('DONE');
process.exit(0);
})
.catch((err) => {
console.error(err);
process.exit(1);
});
获取和使用标记:如何将解决方案替换为页面
在大多数情况下,reCAPTCHA Enterprise 解决方案是通过浏览器插入的。这是因为这种验证在客户端工作,使用 JavaScript 执行复杂的检查。您可以使用浏览器自动化工具(如 Puppeteer或 Selenium)。要插入解决方案,您还需要检查页面代码并找到相应的表单,然后在代码中使用该元素并进行验证。
- 让我们以 Python 和 Selenium 工具为例。首先,我们需要研究带有验证码的登陆页面,并找出所有需要服务解决的验证码 CapMonster Cloud 参数和需要替换令牌的元素。通常它包含在 textarea并且看起来像这样: