Пример #1
0
def eax2RforRS(axis, angles):
    if (len(angles.shape) > 1):
        n = angles.shape[1]
    else:
        n = angles.shape[0]
    theta = np.linalg.norm(axis)
    if theta < np.finfo(float).eps:  # If the rotation is very small...
        return np.tile(
            np.array(((1, -axis[2, 0], axis[1, 0]), (axis[2,
                                                          0], 1, -axis[0, 0]),
                      (-axis[1, 0], axis[0, 0], 1))), (1, n))

    # Otherwise set up standard matrix, first setting up some convenience
    # variables
    axis = axis / theta

    vx = np.tile(ut.x_(axis), (n, 1))
    vx2 = np.tile(ut.x_(axis).dot(ut.x_(axis)), (n, 1))
    s = np.tile(np.sin(angles), (3, 1)).transpose()
    c = np.tile(np.cos(angles), (3, 1)).transpose()
    sM = np.tile(s.ravel().reshape(n * 3, 1), (1, 3))
    cM = np.tile(c.ravel().reshape(n * 3, 1), (1, 3))
    I = np.tile(np.eye(3), (n, 1))

    Rw = I + vx * sM + (1 - cM) * vx2
    return Rw
Пример #2
0
def harvest_tokens_manually():
    """
    Harvest tokens manually
    """
    print (d_(), s_('Manual Token Harvest'), lb_('Number of tokens harvested: %d' % len(captcha_tokens)))

    # Run the harvest server
    # XXX: This threading module is deprecated
    thread.start_new_thread(harvest_server.run, ())

    browser = get_chromedriver(chrome_folder_location='ChromeTokenHarvestFolder', window_size=['640,640'])
    url = 'http://{0}:{1}{2}'.format(user_config.harvestDomain, 5000, '')  # Flask runs on port 5000 by default.
    while len(captcha_tokens) < user_config.numberOfTokens:
        browser.get(url)
        main_window = browser.current_window_handle

        try:
            activate_captcha(driver=browser)
        except:
            print (d_(), x_('Page Load Failed'), lr_('Falling back to 2captcha'))
            browser.quit()
            return

        check_solution(driver=browser, main_window=main_window)
        token = get_token(driver=browser, main_window=main_window)
        if token is not None:
            if len(captcha_tokens) == 0:
                start_time = time.time()
            captcha_tokens.append(token)
            print (d_(), s_('Token Added'))
            print (d_(), s_('Manual Token Harvest'), lb_('Number of tokens harvested: %d' % len(captcha_tokens)))
        current_time = time.time()
        elapsed_time = current_time - start_time
        print (d_(), s_('Total Time Elapsed'), lb_(round(elapsed_time, 2), 'seconds'))
    browser.quit()
Пример #3
0
def calcR6P2linErrEq(M, data):
    w = M[0:3]
    t = M[3:6]
    v = M[6:9]
    C = M[9:12]
    err = np.zeros(data.shape[1])
    i = 0
    for temp in data.transpose():
        X = temp[0:3, None]
        u = temp[3:5, None]
        u = ut.a2h(u)
        eq = np.matmul(
            ut.x_(u),
            np.matmul((np.eye(3) + u[0] * ut.x_(w)),
                      np.matmul((np.eye(3) + ut.x_(v)), X)) + C + u[0] * t)
        err[i] = np.sum(np.absolute(eq))
        i += 1
    return err
Пример #4
0
def activate_captcha(driver):
    """
    Activate the catpcha widget
    """
    iframe = driver.find_element_by_css_selector('iframe[src*="api2/anchor"]')
    driver.switch_to_frame(iframe)
    try:
        checkbox = WebDriverWait(driver, user_config.sleeping).until(
            expected_conditions.presence_of_element_located((By.ID, 'recaptcha-anchor')))
    except:
        try:
            checkbox = WebDriverWait(driver, user_config.sleeping).until(
                expected_conditions.presence_of_element_located((By.ID, 'recaptcha-anchor')))
        except:
            print (d_(), x_('Activate Captcha'), lr_('Failed to find checkbox'))
    checkbox.click()
Пример #5
0
def get_token(driver, main_window):
    """
    We parse the token from the page
    """
    token = None
    driver.switch_to.window(main_window)
    try:
        submit = WebDriverWait(driver, user_config.sleeping).until(
            expected_conditions.presence_of_element_located((By.ID, 'submit')))
        submit.click()
        time.sleep(1)
    except:
        print(d_(), x_('Captcha Submit'), lr_('Failed to click submit'))

    token_element = driver.find_element_by_css_selector('p#token')
    token = token_element.get_attribute('value')
    if token is not None:
        print(d_(), s_('Get Token'), lb_(token))
    return token
Пример #6
0
def check_solution(driver, main_window):
    """
    Check to see if we solved the captcha
    """
    solved = False
    while not solved:
        driver.switch_to.window(main_window)
        try:
            iframe = driver.find_element_by_css_selector('iframe[src*="api2/anchor"]')
        except:
            print (d_(), x_('Check Solution'), lr_('Failed to find checkbox'))
            return
        driver.switch_to_frame(iframe)
        try:
            driver.find_element_by_xpath('//span[@aria-checked="true"]')
            print (d_(), s_('Check Solution'), lb_('Solved'))
            solved = True
        except:
            solved = False
        time.sleep(1)
    return solved
Пример #7
0
import sys

from cart import process_add_to_cart
from product import get_product_info, print_product_info
from settings import exit_code, user_config
from utils import d_, lr_, x_

if __name__ == '__main__':
    # Print the run parameters
    user_config.print_config()

    # Check for dumb asses
    if not user_config.validate_config():
        sys.stdout.flush()
        sys.exit(exit_code)

    # Get product info
    product_info = get_product_info()

    # Print product info
    print_product_info(product_info)

    # If product count is not zero process add to cart
    if product_info['productCount'] > 0:
        process_add_to_cart(product_info)
    elif product_info['productCount'] == -1:
        print(d_(), x_('Variant Count'), lr_('-1'))
        process_add_to_cart(product_info)
    else:
        print(d_(), x_('Variant Count'), lr_('0'))
Пример #8
0
def get_token_from_2captcha():
    session = requests.Session()
    session.verify = False
    session.cookies.clear()
    pageurl = 'http://www.{0}'.format(user_config.marketDomain)
    print(d_(), s_('pageurl'), lb_(pageurl))
    print(d_(), s_('sitekey'), lb_(user_config.sitekey))
    while True:
        data = {
            'key': user_config.apikey2captcha,
            'action': 'getbalance',
            'json': 1,
        }
        response = session.get(url='http://2captcha.com/res.php', params=data)
        if "ERROR_WRONG_USER_KEY" in response.text:
            print(d_(), x_('Response'), y_(response.text))
            sys.exit(exit_code)

        try:
            JSON = response.json()
        except:
            raise
            print(d_(), x_('Sleeping'), y_(user_config.sleeping, 'seconds'))
            time.sleep(user_config.sleeping)
            continue

        if JSON['status'] == 1:
            balance = JSON['request']
            print(d_(), s_('Balance'), lb_('${0}'.format(balance)))
        else:
            print(d_(), x_('Balance'))

        CAPTCHAID = None
        proceed = False
        while not proceed:
            data = {
                'key': user_config.apikey2captcha,
                'method': 'userrecaptcha',
                'googlekey': user_config.sitekey,
                'proxy': user_config.proxy2Captcha,
                'proxytype': 'HTTP',
                'pageurl': pageurl,
                'json': 1
            }
            response = session.post(url='http://2captcha.com/in.php',
                                    data=data)
            try:
                JSON = response.json()
            except:
                print(d_(), x_('Response'), y_(response.text))
                print(d_(), x_('Sleeping'), y_(user_config.sleeping,
                                               'seconds'))
                time.sleep(user_config.sleeping)
                continue

            if JSON['status'] == 1:
                CAPTCHAID = JSON['request']
                proceed = True
                print(d_(), s_('Captcha ID'), lb_(CAPTCHAID))
            else:
                print(d_(), x_('Response'), y_(response.text))
                print(d_(), x_('Sleeping'), y_(user_config.sleeping,
                                               'seconds'))
                time.sleep(user_config.sleeping)
        print(
            d_(), s_('Waiting'),
            '%d seconds before polling for Captcha response' %
            user_config.sleeping)
        time.sleep(user_config.sleeping)

        TOKEN = None
        proceed = False
        while not proceed:
            data = {
                'key': user_config.apikey2captcha,
                'action': 'get',
                'json': 1,
                'id': CAPTCHAID,
            }
            response = session.get(url='http://2captcha.com/res.php',
                                   params=data)
            JSON = response.json()
            if JSON['status'] == 1:
                TOKEN = JSON['request']
                proceed = True
                print(d_(), s_('Token ID'), lb_(TOKEN))
            else:
                print(d_(), x_('Response'), y_(response.text))
                print(d_(), x_('Sleeping'), y_(user_config.sleeping,
                                               'seconds'))
                time.sleep(user_config.sleeping)

        data = {
            'key': user_config.apikey2captcha,
            'action': 'getbalance',
            'json': 1,
        }
        response = session.get(url='http://2captcha.com/res.php', params=data)
        JSON = response.json()
        if JSON['status'] == 1:
            balance = JSON['request']
            print(d_(), s_('Balance'), lb_('${0}'.format(balance)))
        else:
            print(d_(), x_('Balance'))
        if TOKEN is not None:
            return TOKEN