Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to implement Captchas #15

Open
MaxMatti opened this issue Feb 19, 2017 · 2 comments
Open

How to implement Captchas #15

MaxMatti opened this issue Feb 19, 2017 · 2 comments

Comments

@MaxMatti
Copy link

The example doesn't include how to deal with having to solve captchas. The source code which I scanned through only mentions that a signed captcha query and its result are needed. How do I obtain those?

aszlig added a commit to openlab-aux/vuizvui that referenced this issue Jun 9, 2017
This is not only a major annoyance for us but seems to bother a few
other people using the humblebundle-python API:

  * saik0/humblebundle-python#11
  * saik0/humblebundle-python#14
  * saik0/humblebundle-python#15

While digging through the reCaptcha2 API and also the implementation of
the Humble Bundle site, I stumbled over this code from
https://www.humblebundle.com/user/captcha:

  var captcha = new Recaptcha2('captcha-holder');
  $('input[type=submit]').click(function(e){
    e.preventDefault();
    // recaptcha v2 only cares about response, but we can let the Android app interface stay the same
    var challenge = '';
    var response = captcha.get_response();
    var android_defined = false;
    if (typeof Android != 'undefined') {
      Android.setCaptchaResponse(challenge, response);
    }
  })

So we only need the response, which we do now using a very ugly written
Qt 5 QWebEngine GUI which we use to ask the user to solve the captcha.

Combined with our downloader, it works like this:

Whenever the login fails with a HumbleCaptchaException, we print a
message with the store path to the GUI helper. We're inside a
fixed-output derivation builder, so we do have networking.

The GUI helper also runs a small TCP server listening on port 18123 and
the downloader inside the Nix builder constantly tries to connect to
that port and waits until it gets just one string (the connection is
directly closed afterwards and the GUI helper exits), which is the
response. This is then passed as recaptcha_response keyword argument to
the login() method of the HumbleApi object.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
@aszlig
Copy link

aszlig commented Jun 9, 2017

This commit should shed some light about this.

@strycore
Copy link

strycore commented Jun 9, 2017

Right now, I'm working on GOG integration with the Lutris client. I've found that the only reliable way to authenticate and to get through the captchas + 2FA is to actually show them.

I have a Gtk dialog showing a webkit view and a GOG service here:
https://github.com/lutris/lutris/blob/gog/lutris/gui/dialogs.py#L366
and here:
https://github.com/lutris/lutris/blob/gog/lutris/services/gog.py

This has proven to be a working solution as opposed to every command line driven library I've encountered for GOG and Humble Bundle. Once we ship support for GOG, our plan to do exactly the same thing for Humble Bundle, using the same methods. Any other hack to work around account protection is bound to break at some point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants