Skip to content

How to Integrate CB with a custom Python script?

edited July 2017 in GSA Captcha Breaker
I'm writing a custom script in python and would like to use CB for captcha solving. The captchas are easy and brute force is giving me 90+ success rate.

But I have no clue how to integrate CB with my script.
@s4nt0s advised me this:

If you go into your GSA CB installation directory and go to folder called source, there might be an example there to help you.
But that didn't really help. Calling out @Sven or anyone who can help in this regard. :)
Thanks

Comments

  • SvenSven www.GSA-Online.de
    You can take any of the simulated captcha servic apis (preferable de-captcher.com one) and exchange their domain with 127.0.0.1 and it will work fine with our tool.

    See here: http://forum.gsa-online.de/discussion/7322/how-to-work-via-php
  • edited July 2017
    Re: How to integrate GSA Captcha Breaker with Python 

    Thanks @Sven
    Okay, made SOME progress. But I'm getting "unknown" for every request. Here's my code:

    import os
    import requests
    class decaptcher:
        def __init__(self, username, password, product_id=""):
            self.__action_url = "http://127.0.0.1"
            self.__username = username
            self.__password = password
            self.__product_id = product_id
        def solve_image(self, image_path):
        from PIL import Image
        img = Image.open('cap.jpg')
        data = {"function": "picture2",
                "username": self.__username,
                "password": self.__password,
                "pict_to": "0",
                "pict_type": "0",
                "captcha_platform":"Guestbook",
                "pict": open(image_path, "rb").read()}
        request = requests.post(self.__action_url, data)
        answer = request.content.split("|")[-1]
        return answer
    d = decaptcher("a", "b")
    print d.solve_image('cap.jpg')

    I'm not sure if CB is even receiving the request as nothing shows up in the log (bottom right of CB window).
    I've tried changing the captcha_platform to different things like "Article Script" etc.
  • SvenSven www.GSA-Online.de
    you can check if CB gets your request if it appears in the log of it. Replying with Unknown is happening if you it was not able to solve it.

    Also use "captcha_platform" with the same name as you call the captcha type in CB. Thats not required but helps to identify the captcha typebetter.
  • The decapthcher API method didn't work for me. 

    import requests
    
    session = requests.session()
    r = session.get("http://127.0.0.1/gsa_test.gsa")
    files = {"file": open("captcha.jpg", 'rb')}
    r2 = session.post("http://127.0.0.1/gsa_test.gsa", files=files)
    answer = r2.content[102:107]
    return answer

    The captcha has 5 letters hence r2.content[102:107].

    It's not a super effective approach but it works.

  • SvenSven www.GSA-Online.de
    OK but this works right?
  • Yes, it does for captchas that are 5 characters long. This line can be modified for captchas with different length:
    answer = r2.content[102:107]


Sign In or Register to comment.