Problem with invisible ReCaptcha v2 callback function at Mail.com Sign-up page

Marcus Philips

New member
Hi,

I've been having problems with finding & successfully calling the invisible ReCaptcha v2 callback function at Mail.com Sign-up page (the actual url is "https://signup.mail.com/?edition=int&lang=en#.1258-header-signup2-1").

I'm using 2Captcha service to solve this invisible ReCaptcha v2, while having thoroughly read and following all their API documentation & code examples (for Python 3 in my case).

I have tried both with & without the "invisible=1" parameter passed to the "http://2captcha.com/in.php" API endpoint but the result is the same.

The ReCaptcha gets solved by 2Captcha agents and I finally get the 2CAPTCHA_RESPONSE code.
I have found the hidden ("display: none") textarea with id/name="g-recaptcha-response" in the html, and I enter the received 2CAPTCHA_RESPONSE code into its innerHTML.

The next step (based on the 2Captcha API docs) is to find & call the ReCaptcha callback function.
And here my problem starts..

I have searched for a named callback function in the Mail.com html & js source code but haven't found one.
So, I guessed it must be an anonymous function.
Using Chrome Dev Tools I inspected the various js objects and have found something that maybe is the callback function:
___grecaptcha_cfg.clients[0].Gq.X.callback

But whenever I try to call:
___grecaptcha_cfg.clients[0].Gq.X.callback("2CAPTCHA_RESPONSE")
I get -> undefined


I have spent countless hours trying to find a solution to make Mail.com Sign-up page get the solved ReCaptcha (display the green checkmark) but without luck.

Please, any help would be much appreciated.

Thank you in advance!
 

Marcus Philips

New member
For anyone browsing the forum and having a similar problem to mine...

I managed to solve this with the help of the GREAT support guys over at 2Captcha.com!!!
(HIGHLY RECOMMENDED service & support! I mean it!!!)

To make the long story short...
If you have a situation with:
  • Invisible ReCaptcha v2, where there is no named callback function defined anywhere (not mentioned in the html, nor present in the js source code).
  • No form submit button anywhere (not visible or invisible, nor dynamically generated by js).
  • You want to use 2Captcha service to automatically solve it and proceed to posting the form.

If that's your case, then follow the steps below:
  1. Using Chrome/Firefox Dev Tools -> Console
    1. Manually inspect the existing js object structure by typing:
      ___grecaptcha_cfg.clients
      This is an array of all the recaptcha objects currently created on the page. More often than not, there will be only one. So, that's index [0].
    2. Manually inspect the objects of the above array. In my situation there was only one:
      ___grecaptcha_cfg.clients[0]
      Still using the Console, inspect & try to find the object ___grecaptcha_cfg.clients[0].Gq.X
      NOTE: "Gq.X" may be different in your case. For example, in 2Captcha's API documentation they are referring to it as "aa.l".
      Traverse the object tree and you'll know that you found it when you see the property "sitekey" and the function "callback" listed under it in the tree.
    3. Take a note of the object name of your case (in my case it was "Gq.X").
    4. Take note of the sitekey string.

  2. Contact the 2Captcha API endpoint "http://2captcha.com/in.php" passing:
    1. Your personal 2Captcha API Key.
    2. The parameter "method=userrecaptcha"
    3. The parameter "invisible=1"
    4. The parameter "googlekey=SITE_KEY" (the sitekey that you found in step 1.4)
    5. The parameter "pageurl=FULL_URL_OF_THE_TARGET_PAGE" (the full url where the captcha is located)

  3. Wait for their successful response, and when that happens get the response token text (all characters after the "OK|").

  4. In the HTML source code of the target webpage search and find the hidden <textarea> element which has "display: none" & id/name="g-recaptcha-response".
    1. Type/Inject into its innerHTML the 2Captcha response token text (from step 3).

  5. Manually (through the Chrome/Firefox Dev Tools -> Console) or Programmatically (through browser automation such as Selenium) execute the following javascript code:
    ___grecaptcha_cfg.clients[0].Gq.X.callback("2CAPTCHA_RESPONSE")
    DON'T forget to replace:
    • "Gq.X" with the actual object name of your case (see step 1.3)
    • 2CAPTCHA_RESPONSE is the 2Captcha response token text (from step 3)

  6. Manually submit the main form of the target webpage, or click the main button to proceed to the next page (if there's no submit button).
    At this stage the page will get the solved captcha correctly and continue normally (given that you have provided valid data to any other form field that was required by this form/webpage).

  7. Rock on!!! We're done!..


Note:
Don't be silly as I was, and wait to see the green checkmark animation happening on the visible captcha div.
It won't happen and that's expected. The captcha is already considered solved as far as the webpage is concerned.
Nor expect to see anything returned after you manually (or programmatically) execute the callback function (in step 5).
Specifically, if you manually execute it in the Console you will see "undefined" returned. That's expected too. The callback function doesn't return any value anyways.


I hope this post will help anyone being in the difficult situation that I've been for the past 12 hours tearing my hair apart, while digging hundreds of js lines of obfuscated code trying to find the damn recaptcha callback function!

Have a nice day guys!
 
Last edited:

Tahrim

New member
Thank you Marcus Philips.
Can you please help me by telling how you find ___grecaptcha_cfg.clients[0].Gq.X

How you get Gq.X
what I see when following your instruction:

Capture113.JPG


I am trying to find the callback for the last few days without luck.
 

kristen

New member
Thank you Marcus Philips.
Can you please help me by telling how you find ___grecaptcha_cfg.clients[0].Gq.X

How you get Gq.X

Hi!

As Marcus have mentioned,

"Gq.X" may be different in your case. For example, in 2Captcha's API documentation they are referring to it as "aa.l".
Traverse the object tree and you'll know that you found it when you see the property "sitekey" and the function "callback" listed under it in the tree.

Try to open full tree (with sub-branches) to check every element step-by-step.
My bet is that it may be somewhere in "K" branch, you just need to expand it and check.
 

Attachments

  • Screenshot_203.jpg
    Screenshot_203.jpg
    94.5 KB · Views: 199

MJ3600

New member
Hi!

As Marcus have mentioned,



Try to open full tree (with sub-branches) to check every element step-by-step.
My bet is that it may be somewhere in "K" branch, you just need to expand it and check.


What if there is no callback there like in my case?
 

kristen

New member
What if there is no callback there like in my case?

Then the only way is to manually check all requests after successfull captcha solving in browser. You could use built-in Network Monitor (Chrome and Firefox have this) or a special software like Fiddler.

Anyway you will find that something happens after you solved the captcha — some request submits the solution and then site let you perform desired action. You need to track this request, understand what it consists of, and then — emulate it without browser.
 

rzme

New member
Python:
token = str(token.replace('OK|', ''))
print(token)

driver.execute_script(
    "arguments[0].style.display='inline'",
    driver.find_element_by_xpath(
        '//*[@id="g-recaptcha-response"]'
    ),
)
driver.execute_script(
    'document.getElementById("g-recaptcha-response").innerHTML = "%s"'
    % token
)
time.sleep(3)
driver.execute('___grecaptcha_cfg.clients[0].uK.P.callback({})'.format(token))


time.sleep(3)
submit = driver.find_element_by_class_name('form__create-account-text')
submit.click()

62c3d3c8ace84cb3dcd7511aa36a0be9.png


Figured out most by myself but still stuck at the callback() part. any ideas?
Getting key-error when executing the callback function
 

Mark Miller

2Captcha Engineer
Staff member
Python:
    driver.execute_script(
        "arguments[0].style.display='inline'",
        driver.find_element_by_xpath(
            '//*[@id="g-recaptcha-response"]'
        ),
    )
    driver.execute_script(
        'document.getElementById("g-recaptcha-response").innerHTML = "%s"'
        % token
    )
    time.sleep(3)
    driver.execute('___grecaptcha_cfg.clients[0].uK.P.callback({})'.format(token))


    time.sleep(3)
    submit = driver.find_element_by_class_name('form__create-account-text')
    submit.click()

62c3d3c8ace84cb3dcd7511aa36a0be9.png


Figured out most by myself but still stuck at the callback() part. any ideas?
Getting key-error when executing the callback function


Are you sure the token is passed correctly in this call?
Python:
driver.execute('___grecaptcha_cfg.clients[0].uK.P.callback({})'.format(token))
 

Mark Miller

2Captcha Engineer
Staff member
@Mark Miller {} replaces the token so yeah, unless it should have "" to encapsulate it
In javascript any string should be in quotes or double quotes, otherwise it is taken as a variable name. So when passed to javascript context your call should look like:
___grecaptcha_cfg.clients[0].uK.P.callback('TOKEN_STRING')
 

rzme

New member
@Mark Miller ahh yes ofcourse missed that in the rush lol
anyways it still throws an error.
Code:
KeyError: '___grecaptcha_cfg.clients[0].uK.P.callback("03AERD8Xo7OyxqwJv1b0qtWd_OGITeXz1KCaFNHz2irgqe0oZ5bCJlSk19fD3qxgCpoSuaHM550YwrcJkYndroNMbaHz6sLMq8Ywhu0CUK45wHZVAOnMQghlbDC0RtsmfPbNuEwur_t1Q467L9m5TXOx5QOSN2Qdku1lmZluvEC0g2mzRjtUIbHbClFlDnKGf9lkjKOhMvTtt1HBzUotvX9Zf4HESiQFFtDTFCV4EgXqk3x0hw7KVxcERYx_tZq6ENEBc-9lV4TkbxjDr9NIumCQYqjHXyBgF6wrPQJI4hn-6On3toTrD1WVSy6BzVR6cKn7pF3b7DZ0evCpwWgQSirSXKA5aKfFXAcUOMlnPeN0ln7Nx3037BWPsz2Iwd9vSUl7xiNg2zc67suhO5FLh5cWFTrgxiJRGa2yr4ZGymPmF5Hxtqzoo2i2pywpHStCwFSa9Yh3LScoVh")'
 

Mark Miller

2Captcha Engineer
Staff member
@Mark Miller ahh yes ofcourse missed that in the rush lol
anyways it still throws an error.
Code:
KeyError: '___grecaptcha_cfg.clients[0].uK.P.callback("03AERD8Xo7OyxqwJv1b0qtWd_OGITeXz1KCaFNHz2irgqe0oZ5bCJlSk19fD3qxgCpoSuaHM550YwrcJkYndroNMbaHz6sLMq8Ywhu0CUK45wHZVAOnMQghlbDC0RtsmfPbNuEwur_t1Q467L9m5TXOx5QOSN2Qdku1lmZluvEC0g2mzRjtUIbHbClFlDnKGf9lkjKOhMvTtt1HBzUotvX9Zf4HESiQFFtDTFCV4EgXqk3x0hw7KVxcERYx_tZq6ENEBc-9lV4TkbxjDr9NIumCQYqjHXyBgF6wrPQJI4hn-6On3toTrD1WVSy6BzVR6cKn7pF3b7DZ0evCpwWgQSirSXKA5aKfFXAcUOMlnPeN0ln7Nx3037BWPsz2Iwd9vSUl7xiNg2zc67suhO5FLh5cWFTrgxiJRGa2yr4ZGymPmF5Hxtqzoo2i2pywpHStCwFSa9Yh3LScoVh")'

KeyError comes from Python, not from javascript.
 

rzme

New member
@Mark Miller indeed i probably missed a semicolon, will retry

EDIT: used execute_script() instead of execute() lol smh-> worked
 
Last edited:

reformedot

New member
Hi, I'm getting a KeyError: '___grecaptcha_cfg.clients[0].H.H.callback("03AGdBq24GWE98XSl6X59mjzte35RyCW-86QuJMGWKxUu2wGhGAL7RbgAu0FFrDslOiA_28N6JCijLW3OlAVVqk1QVYJXnP33xN2wSFSG3n0Mf0cPDbk_dbAmT1qbFBKiQejtGQl83_mv57ElyfB0oKsWoKv8cdxta85ZC8beHJqACGtIOk9i9T5E3pB9YfHIahdTXjKGtLutQ30Vvk50sncOClKGBXimVOe7eS_SlAQM1zoSLVW8roGpl0K6BfdmmXmrZuIBwKm106nq8rsrS8ZbiYMiNa85CI0M-yOQc5avC72FBbGJKKFj3roX1eFYyVmpCWr4W266PIrel6xUTi2uKLMr9ITd2OWUr9JecghUWDWOWCLXNRmqzoiA0tZ0vDqyI1knyt0laEUwxr5VCEGm9d1jYwgxQoiWlEE-WWHqqzx1PgUygIejun1pB5XNMW2gaqqUrbKVQq2_Pw-byYDBaEQnfgljA7Q")'

After executing the callback as:
callback = f'___grecaptcha_cfg.clients[0].H.H.callback("{captcha_key}")'
browser.execute(callback)

Any idea? I don't know what I'm doing wrong.
My captcha object is the one attached, and I'm sending the 2captcha request with invisible = 1 parameter and the site key is the screenshot one.

Thanks!
 

Attachments

  • Untitled.png
    Untitled.png
    62.3 KB · Views: 143

Mark Miller

2Captcha Engineer
Staff member
Hi, I'm getting a KeyError: '___grecaptcha_cfg.clients[0].H.H.callback("03AGdBq24GWE98XSl6X59mjzte35RyCW-86QuJMGWKxUu2wGhGAL7RbgAu0FFrDslOiA_28N6JCijLW3OlAVVqk1QVYJXnP33xN2wSFSG3n0Mf0cPDbk_dbAmT1qbFBKiQejtGQl83_mv57ElyfB0oKsWoKv8cdxta85ZC8beHJqACGtIOk9i9T5E3pB9YfHIahdTXjKGtLutQ30Vvk50sncOClKGBXimVOe7eS_SlAQM1zoSLVW8roGpl0K6BfdmmXmrZuIBwKm106nq8rsrS8ZbiYMiNa85CI0M-yOQc5avC72FBbGJKKFj3roX1eFYyVmpCWr4W266PIrel6xUTi2uKLMr9ITd2OWUr9JecghUWDWOWCLXNRmqzoiA0tZ0vDqyI1knyt0laEUwxr5VCEGm9d1jYwgxQoiWlEE-WWHqqzx1PgUygIejun1pB5XNMW2gaqqUrbKVQq2_Pw-byYDBaEQnfgljA7Q")'

After executing the callback as:
callback = f'___grecaptcha_cfg.clients[0].H.H.callback("{captcha_key}")'
browser.execute(callback)

Any idea? I don't know what I'm doing wrong.
My captcha object is the one attached, and I'm sending the 2captcha request with invisible = 1 parameter and the site key is the screenshot one.

Thanks!
Just call the function by name validateReCaptcha
In your case ___grecaptcha_cfg.clients[0].H.H.callback contains a string with function name, not the function itself.
 

reformedot

New member
Just call the function by name validateReCaptcha
In your case ___grecaptcha_cfg.clients[0].H.H.callback contains a string with function name, not the function itself.

Hi Mark, thanks for your fast response!

I'm running validateReCaptcha("03AGdBq25BWD7dBO3OG4eGTj3B54BvFaEctXsV7BQ1fZ2Tf6Xv6ULKAywrXZodN0XGIsHhhb5Fn_NtPzU0nhwzneeA_m3WrVXfeMCCZVCKjxRpYUndTJCEhHPPR9o0kjMW8Io_RQPdvgZkMmdVVQQTRAVu3hO40225W-U8P11fWhncRvir-GddCfSibuE4uMevZVxa8OWBvy158PRWRz5Ed-7mVT9xLV8g8wm5XGH8426qgQ1VDtKPNWRSUACywYlTYCy8Mpp6oMr24ARvPBRdvkQaS5FnpIyaNLxr9BFgGcC4b-Tw0PCaOYcTULvheXjEFJ8tvCSQFAFtTj4-Shda7iAMCVWN6XPwSFj-48sCRWI5VQzlUYHvx7cbrZ81aBwvvsSmU6U8fuAGcm68e7jcQfbjo6g814CbTxoJbVfVQ-fUtxu1Rnpp43tyqO1x3N5q6ZZLYTtGvPCJIABGsp_lpx6IW24psQ9WnA")

But I'm receiving the error attached, what kind of object is the callback expecting? I tried with (), with ("the key") and (the key) and none of them seems working
 

Attachments

  • Untitled 2.png
    Untitled 2.png
    14.5 KB · Views: 86

Mark Miller

2Captcha Engineer
Staff member
Hi Mark, thanks for your fast response!

I'm running validateReCaptcha("03AGdBq25BWD7dBO3OG4eGTj3B54BvFaEctXsV7BQ1fZ2Tf6Xv6ULKAywrXZodN0XGIsHhhb5Fn_NtPzU0nhwzneeA_m3WrVXfeMCCZVCKjxRpYUndTJCEhHPPR9o0kjMW8Io_RQPdvgZkMmdVVQQTRAVu3hO40225W-U8P11fWhncRvir-GddCfSibuE4uMevZVxa8OWBvy158PRWRz5Ed-7mVT9xLV8g8wm5XGH8426qgQ1VDtKPNWRSUACywYlTYCy8Mpp6oMr24ARvPBRdvkQaS5FnpIyaNLxr9BFgGcC4b-Tw0PCaOYcTULvheXjEFJ8tvCSQFAFtTj4-Shda7iAMCVWN6XPwSFj-48sCRWI5VQzlUYHvx7cbrZ81aBwvvsSmU6U8fuAGcm68e7jcQfbjo6g814CbTxoJbVfVQ-fUtxu1Rnpp43tyqO1x3N5q6ZZLYTtGvPCJIABGsp_lpx6IW24psQ9WnA")

But I'm receiving the error attached, what kind of object is the callback expecting? I tried with (), with ("the key") and (the key) and none of them seems working
I think you need to check the function definition.
Type just validateReCaptcha without brackets in the console and you will get the definition. Clicking on the definition you can open the code where it was defined.
 

reformedot

New member
Thanks for your reply Mark,

It seems is all obfuscated, the function is the one attached...

Any idea on how to bypass that captcha having it resolved? When I click on submit button, the captcha pictures appears.

window.validateReCaptcha = function(t) {
t ? it.resolve() : it.reject()
}
 

Attachments

  • Untitled.png
    Untitled.png
    61 KB · Views: 97

Mark Miller

2Captcha Engineer
Staff member
Thanks for your reply Mark,

It seems is all obfuscated, the function is the one attached...

Any idea on how to bypass that captcha having it resolved? When I click on submit button, the captcha pictures appears.

window.validateReCaptcha = function(t) {
t ? it.resolve() : it.reject()
}
No idea unless you provide a link to the website :)