Beispiel #1
0
def twocaptcha_solver():
    """Handles and returns recaptcha answer for osrs account creation page"""
    SITE_URL = get_site_settings()[1]
    SITE_KEY = get_site_settings()[0]  # osrs site key
    API_KEY = get_user_settings()[3]  # api key read from settings.ini
    if not API_KEY:
        raise ValueError("No API key was found in settings.ini.")

    s = requests.Session()

    # here we post and parse site key to 2captcha to get captcha ID
    try:
        captcha_id = s.post(f"http://2captcha.com/in.php?key={API_KEY}"
                            f"&method=userrecaptcha&googlekey={SITE_KEY}"
                            f"&pageurl={SITE_URL}").text.split('|')[1]
    except IndexError:
        print("You likely don't have a valid 2captcha.com API key with funds"
              " in your settings.ini file. Fix and re-run the program.")

    # then we parse gresponse from 2captcha response
    recaptcha_answer = s.get(f"http://2captcha.com/res.php?key={API_KEY}"
                             f"&action=get&id={captcha_id}").text
    print("Solving captcha...")
    while 'CAPCHA_NOT_READY' in recaptcha_answer:
        sleep(6)
        recaptcha_answer = s.get(f"http://2captcha.com/res.php?key={API_KEY}"
                                 f"&action=get&id={captcha_id}").text
    try:
        recaptcha_answer = recaptcha_answer.split('|')[1]
    except IndexError:
        print("2captcha failed to solve this one.. Returning a blank response "
              "If the program fails to continue, please msg Gavin with error.")
        recaptcha_answer = ''
    else:
        return recaptcha_answer
Beispiel #2
0
"""
Solves and returns the captcha answer via the anti-captcha.com service
Documentation: https://pypi.org/project/python-anticaptcha/
Requirements: pip install python-anticaptcha
"""
import sys
try:
    from python_anticaptcha import AnticaptchaClient, NoCaptchaTaskProxylessTask, AnticaptchaException
    from modules.helper_modules.utility import get_site_settings, get_user_settings
except ImportError as error:
    print(error)

SITE_URL = get_site_settings()[1]
SITE_KEY = get_site_settings()[0]  # osrs site key
API_KEY = get_user_settings()[3]  # api key read from settings.ini


def anticaptcha_solver():
    """Solves repcatcha via AntiCaptcha service"""
    print("Solving captcha, please wait...")
    client = AnticaptchaClient(API_KEY)
    task = NoCaptchaTaskProxylessTask(SITE_URL, SITE_KEY, is_invisible=True)

    while True:
        try:
            try:
                job = client.createTask(task)
            except AnticaptchaException as e:
                print(e)
                if e.error_id(2):
                    print("No captcha solver available.. Retrying.")
HEADERS = {
    'User-Agent':
    'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5)'
    ' AppleWebKit/537.36 (KHTML, like Gecko)'
    ' Chrome/58.0.3029.110 Safari/537.36'
}
try:
    PROXY_LIST = open("settings/proxy_list.txt", "r")
except FileNotFoundError:
    sys.exit("proxy_list.txt wasn't found. "
             "Make sure it's in the same directory.")

# Settings pulled from utility.py -> settings.ini file
USE_PROXIES = get_user_settings()[0]
NUM_OF_ACCS = get_user_settings()[4]
SITE_URL = get_site_settings()[1]
TRIBOT_ACTIVE = get_tribot_settings()[0]
OSBOT_ACTIVE = get_osbot_settings()[0]


def get_ip() -> str:
    """
    Gets the user's external IP that will be used to create the account.
    Because of external dependency, we have a backup site to pull from if needed
    """
    users_ip = requests.get('https://api.ipify.org').text
    if not users_ip:
        users_ip = requests.get('http://ip.42.pl/raw').text
    return users_ip