def captcha_solver():
    """Handles and returns recaptcha answer for osrs account creation page"""
    SITE_KEY = get_settings_variables()[3]  # osrs site key
    API_KEY = get_settings_variables()[1]  # 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
Exemplo n.º 2
0
def use_tribot(charname, charpass, proxy=None):
    # Storing all of our settings while we're in the correct directory
    use_proxies = get_settings_variables()[0]
    tribot_username = get_settings_variables()[9]
    tribot_password = get_settings_variables()[10]
    script_to_use = get_settings_variables()[11]
    script_args = get_settings_variables()[12]

    if use_proxies:
        proxy_username = format_current_proxy(proxy)[0]
        proxy_password = format_current_proxy(proxy)[1]
        proxy_host = format_current_proxy(proxy)[2]
        proxy_port = format_current_proxy(proxy)[3]

    original_path = os.getcwd()
    client = find_tribot()

    # Create our CLI command according to if we're using proxies or not
    if use_proxies:
        cli_cmd = (
            f'java -jar {client} '
            f'--username "{tribot_username}" --password "{tribot_password}" '
            f'--charusername "{charname}" --charpassword "{charpass}" '
            f'--script "{script_to_use}" --charworld "433" '
            f'--proxyhost "{proxy_host}" '
            f'--proxyport "{proxy_port}" '
            f'--proxyusername "{proxy_username}" '
            f'--proxypassword "{proxy_password}" ')
    else:
        cli_cmd = (
            f'java -jar {client} '
            f'--username "{tribot_username}" --password "{tribot_password}" '
            f'--charusername "{charname}" --charpassword "{charpass}" '
            f'--script "{script_to_use}" --charworld "433"')

    print("")
    print("\nLoading tribot with the following settings...")
    print(cli_cmd)

    # Run the Tribot CLI in a separate, hidden shell to decrease clutter
    CREATE_NO_WINDOW = 0x08000000
    subprocess.Popen(f"start /B start cmd.exe @cmd /k {cli_cmd}",
                     shell=True,
                     creationflags=CREATE_NO_WINDOW)

    # Changing back to the account creator directory
    # So we can see the settings.ini file for the next account.
    print(f"Changing our directory back to {original_path}")
    os.chdir(original_path)
def save_account(payload, proxy=None):
    """Save the needed account information to created_accs.txt"""
    if USE_PROXIES:
        # Formatting our proxy string to only save the IP
        proxy = str(proxy)
        proxy = proxy[proxy.find('@') + 1:]
        proxy = proxy[:proxy.find(':')]
    else:
        proxy = get_ip()

    # Check if we want user friendly formatting or bot manager friendly
    acc_details_format = get_settings_variables()[7]
    if acc_details_format:
        formatted_payload = (
            f"\nemail:{payload['email1']}, password:{payload['password1']},"
            f" Birthday:{payload['month']}/{payload['day']}/{payload['year']},"
            f" Proxy:{proxy}")
    else:
        formatted_payload = (f"\n{payload['email1']}:{payload['password1']}")

    with open("created_accs.txt", "a+") as acc_list:
        acc_list.write(formatted_payload)
    if acc_details_format:
        print(f"Created account and saved to created_accs.txt"
              f" with the following details:{formatted_payload}")
    else:
        print(f"Created account and saved to created_accs.txt"
              f" with the following details: {formatted_payload}:{proxy}")
def get_payload(captcha) -> dict:
    """
	Generates and fills out our payload.
	returns:
	payload (dict): account creation payload data
	"""
    # Get username/password options from settings.ini
    email = get_settings_variables()[5]
    password = get_settings_variables()[6]

    if not email:  # We aren't using a custom username prefix -> make it random
        email = ''.join([
            random.choice(string.ascii_lowercase + string.digits)
            for n in range(6)
        ]) + '@gmail.com'
    else:  # We're using a custom prefix for our usernames
        email = email + str(random.randint(1000, 9999)) + '@gmail.com'

    if not password:
        password = email[:-10] + str(random.randint(1, 1000))

    # Generate random birthday for the account
    day = str(random.randint(1, 25))
    month = str(random.randint(1, 12))
    year = str(random.randint(1980, 2006))  # Be at least 13 years old

    payload = {
        'theme': 'oldschool',
        'email1': email,
        'onlyOneEmail': '1',
        'password1': password,
        'onlyOnePassword': '******',
        'day': day,
        'month': month,
        'year': year,
        'create-submit': 'create',
        'g-recaptcha-response': captcha
    }
    return payload
             "Make sure it's in the same directory.")

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("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 get_settings_variables -> settings.ini file
USE_PROXIES = get_settings_variables()[0]
NUM_OF_ACCS = get_settings_variables()[2]
SITE_URL = get_settings_variables()[4]
tribot_active = get_settings_variables()[8]


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
	"""
    ip = requests.get('https://api.ipify.org').text
    if not ip:
        ip = requests.get('http://ip.42.pl/raw').text
    return ip