Esempio n. 1
0
def fetch_activation_bytes(username, password):
    if os.getenv("DEBUG"):
        print(
            "[!] Running in DEBUG mode. You will need to login in a semi-automatic way, wait for the login screen to show up ;)"
        )

    # Step 0
    opts = webdriver.ChromeOptions()
    # opts.add_argument("user-agent=Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET4.0C; .NET4.0E; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET CLR 1.1.4322)")
    opts.add_argument(
        "user-agent=Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; AS; rv:11.0) like Gecko"
    )
    driver = webdriver.Chrome(chrome_options=opts,
                              executable_path="./chromedriver")

    # Step 1
    if '@' in username:  # Amazon login using email address
        base_url = "https://www.amazon.com/ap/signin?"
    else:  # Audible member login using username (untested!)
        base_url = "https://www.audible.com/sign-in/ref=ap_to_private?forcePrivateSignIn=true&rdPath=https%3A%2F%2Fwww.audible.com%2F%3F"
    # fake_hash = hashlib.sha1(os.urandom(128)).digest()
    # playerId = base64.encodestring(fake_hash).rstrip()  # generate base64 digest of a random 20 byte string ;)
    playerId = base64.encodestring(hashlib.sha1("").digest()).rstrip()
    payload = {
        'openid.ns':
        'http://specs.openid.net/auth/2.0',
        'openid.identity':
        'http://specs.openid.net/auth/2.0/identifier_select',
        'openid.claimed_id':
        'http://specs.openid.net/auth/2.0/identifier_select',
        'openid.mode':
        'logout',
        'openid.assoc_handle':
        'amzn_audible_us',
        'openid.return_to':
        'https://www.audible.com/player-auth-token?playerType=software&playerId=%s=&bp_ua=y&playerModel=Desktop&playerManufacturer=Audible'
        % (playerId)
    }
    query_string = urlencode(payload)
    url = base_url + query_string
    # print(url, file=sys.stderr)
    # http://chromedriver.storage.googleapis.com/index.html?path=2.19/
    driver.get('https://www.audible.com/?ipRedirectOverride=true')
    driver.get(url)
    search_box = driver.find_element_by_id('ap_email')
    search_box.send_keys(username)
    search_box = driver.find_element_by_id('ap_password')
    search_box.send_keys(password)
    if os.getenv("DEBUG"
                 ):  # enable if you hit CAPTCHA (or other "security" screens)
        time.sleep(32)
    else:
        search_box.submit()

    # Step 2
    driver.get(
        'https://www.audible.com/player-auth-token?playerType=software&bp_ua=y&playerModel=Desktop&playerId=%s&playerManufacturer=Audible&serial='
        % (playerId))
    current_url = driver.current_url
    o = urlparse(current_url)
    data = dict(parse_qsl(o.query))
    # print(data, file=sys.stderr)

    # Step 2.5, switch User-Agent to "Audible Download Manager"
    headers = {
        'User-Agent': "Audible Download Manager",
    }
    cookies = driver.get_cookies()
    s = requests.Session()
    for cookie in cookies:
        s.cookies.set(cookie['name'], cookie['value'])

    # Step 3, de-register first, in order to stop hogging all activation slots (there are 8 of them!)
    durl = 'https://www.audible.com/license/licenseForCustomerToken?' + 'customer_token=' + data[
        "playerToken"] + "&action=de-register"
    # print(durl, file=sys.stderr)
    response = s.get(durl, headers=headers)
    # driver.get(durl)
    # extract_activation_bytes(response.content)

    # Step 4
    # url = 'https://www.audible.com/license/licenseForCustomerToken?' + 'customer_token=' + data["playerToken"] + "&action=register"
    url = 'https://www.audible.com/license/licenseForCustomerToken?' + 'customer_token=' + data[
        "playerToken"]
    # print(url, file=sys.stderr)
    response = s.get(url, headers=headers)
    # driver.get(durl)
    # print(response.content)
    common.extract_activation_bytes(response.content)

    # Step 5 (de-register again to stop filling activation slots)
    # print(durl, file=sys.stderr)
    # driver.get(durl)
    response = s.get(durl, headers=headers)

    # driver.get(url)
    time.sleep(8)
    driver.quit()
def fetch_activation_bytes(username, password, options):
    base_url = 'https://www.audible.com/'
    base_url_license = 'https://www.audible.com/'
    lang = options.lang

    # Step 0
    opts = webdriver.ChromeOptions()
    opts.add_argument(
        "user-agent=Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; AS; rv:11.0) like Gecko"
    )

    # Step 1
    if '@' in username:  # Amazon login using email address
        login_url = "https://www.amazon.com/ap/signin?"
    else:  # Audible member login using username (untested!)
        login_url = "https://www.audible.com/sign-in/ref=ap_to_private?forcePrivateSignIn=true&rdPath=https%3A%2F%2Fwww.audible.com%2F%3F"
    if lang != "us":  # something more clever might be needed
        login_url = login_url.replace('.com', "." + lang)
        base_url = base_url.replace('.com', "." + lang)

    player_id = base64.encodestring(hashlib.sha1("").digest()).rstrip(
    )  # keep this same to avoid hogging activation slots
    if options.player_id:
        player_id = base64.encodestring(binascii.unhexlify(
            options.player_id)).rstrip()
    print("[*] Player ID is %s" % player_id)

    payload = {
        'openid.ns':
        'http://specs.openid.net/auth/2.0',
        'openid.identity':
        'http://specs.openid.net/auth/2.0/identifier_select',
        'openid.claimed_id':
        'http://specs.openid.net/auth/2.0/identifier_select',
        'openid.mode':
        'logout',
        'openid.assoc_handle':
        'amzn_audible_' + lang,
        'openid.return_to':
        base_url +
        'player-auth-token?playerType=software&playerId=%s=&bp_ua=y&playerModel=Desktop&playerManufacturer=Audible'
        % (player_id)
    }

    if sys.platform == 'win32':
        chromedriver_path = "chromedriver.exe"
    else:
        chromedriver_path = "./chromedriver"

    driver = webdriver.Chrome(chrome_options=opts,
                              executable_path=chromedriver_path)

    query_string = urlencode(payload)
    url = login_url + query_string
    driver.get(base_url + '?ipRedirectOverride=true')
    driver.get(url)
    search_box = driver.find_element_by_id('ap_email')
    search_box.send_keys(username)
    search_box = driver.find_element_by_id('ap_password')
    search_box.send_keys(password)
    if os.getenv(
            "DEBUG"
    ) or options.debug:  # enable if you hit CAPTCHA or 2FA or other "security" screens
        print(
            "[!] Running in DEBUG mode. You will need to login in a semi-automatic way, wait for the login screen to show up ;)"
        )
        time.sleep(32)
    else:
        search_box.submit()

    # Step 2
    driver.get(
        base_url +
        'player-auth-token?playerType=software&bp_ua=y&playerModel=Desktop&playerId=%s&playerManufacturer=Audible&serial='
        % (player_id))
    current_url = driver.current_url
    o = urlparse(current_url)
    data = dict(parse_qsl(o.query))

    # Step 2.5, switch User-Agent to "Audible Download Manager"
    headers = {
        'User-Agent': "Audible Download Manager",
    }
    cookies = driver.get_cookies()
    s = requests.Session()
    for cookie in cookies:
        s.cookies.set(cookie['name'], cookie['value'])

    # Step 3, de-register first, in order to stop hogging all activation slots
    # (there are 8 of them!)
    durl = base_url_license + 'license/licenseForCustomerToken?' \
        + 'customer_token=' + data["playerToken"] + "&action=de-register"
    s.get(durl, headers=headers)

    # Step 4
    url = base_url_license + 'license/licenseForCustomerToken?' \
        + 'customer_token=' + data["playerToken"]
    response = s.get(url, headers=headers)

    with open("activation.blob", "wb") as f:
        f.write(response.content)
    activation_bytes, _ = common.extract_activation_bytes(response.content)
    print(activation_bytes)

    # Step 5 (de-register again to stop filling activation slots)
    s.get(durl, headers=headers)

    # driver.get(url)
    time.sleep(8)
    driver.quit()
#!/usr/bin/env python

import sys
import common

template = """REGEDIT4

[HKEY_LOCAL_MACHINE\Software\Audible\SWGIDMAP]
"0"=hex:%s
"1"=hex:%s
"2"=hex:%s
"3"=hex:%s
"4"=hex:%s
"5"=hex:%s
"6"=hex:%s
"7"=hex:%s
"""

if __name__ == "__main__":
    if len(sys.argv) < 2:
        sys.stderr.write("Usage: %s <activation.blob / licenseForCustomerToken file>\n"
                         % sys.argv[0])
        sys.exit(-1)

    with open(sys.argv[1], "rb") as f:
        activation_bytes, output = common.extract_activation_bytes(f.read())
        print(activation_bytes)
        print(template % (output[0], output[1], output[2],
                          output[3], output[4], output[5],
                          output[6], output[7]))
def fetch_activation_bytes(username, password, options):
    base_url = 'https://www.audible.com/'
    base_url_license = 'https://www.audible.com/'
    lang = options.lang

    # Step 0
    opts = webdriver.ChromeOptions()
    opts.add_argument("user-agent=Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; AS; rv:11.0) like Gecko")

    # Step 1
    if '@' in username:  # Amazon login using email address
        login_url = "https://www.amazon.com/ap/signin?"
    else:  # Audible member login using username (untested!)
        login_url = "https://www.audible.com/sign-in/ref=ap_to_private?forcePrivateSignIn=true&rdPath=https%3A%2F%2Fwww.audible.com%2F%3F"
    if lang == "uk":
        login_url = login_url.replace('.com', ".co.uk")
        base_url = base_url.replace('.com', ".co.uk")
    elif lang == "jp":
        login_url = login_url.replace('.com', ".co.jp")
        base_url = base_url.replace('.com', ".co.jp")
    elif lang == "au":
        login_url = login_url.replace('.com', ".com.au")
        base_url = base_url.replace('.com', ".com.au")
    elif lang == "in":
        login_url = login_url.replace('.com', ".in")
        base_url = base_url.replace('.com', ".in")
    elif lang != "us":  # something more clever might be needed
        login_url = login_url.replace('.com', "." + lang)
        base_url = base_url.replace('.com', "." + lang)

    if PY3:
        player_id = base64.encodebytes(hashlib.sha1(b"").digest()).rstrip()  # keep this same to avoid hogging activation slots
        player_id = player_id.decode("ascii")
    else:
        player_id = base64.encodestring(hashlib.sha1(b"").digest()).rstrip()
    if options.player_id:
        player_id = base64.encodestring(binascii.unhexlify(options.player_id)).rstrip()
    print("[*] Player ID is %s" % player_id)

    payload = {
        'openid.ns': 'http://specs.openid.net/auth/2.0',
        'openid.identity': 'http://specs.openid.net/auth/2.0/identifier_select',
        'openid.claimed_id': 'http://specs.openid.net/auth/2.0/identifier_select',
        'openid.mode': 'logout',
        'openid.assoc_handle': 'amzn_audible_' + lang,
        'openid.return_to': base_url + 'player-auth-token?playerType=software&playerId=%s=&bp_ua=y&playerModel=Desktop&playerManufacturer=Audible' % (player_id)
    }

    if options.firefox:
        driver = webdriver.Firefox()
    elif options.remote:
        from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
        driver = webdriver.Remote("http://127.0.0.1:4444/wd/hub", options=opts)
    else:
        if sys.platform == 'win32':
            chromedriver_path = "chromedriver.exe"
        elif os.path.isfile("/usr/bin/chromedriver"):  # Debian/Ubuntu package's chromedriver path
            chromedriver_path = "/usr/bin/chromedriver"
        elif os.path.isfile("/usr/lib/chromium-browser/chromedriver"):  # Ubuntu package chromedriver path
            chromedriver_path = "/usr/lib/chromium-browser/chromedriver"
        elif os.path.isfile("/usr/local/bin/chromedriver"):  # macOS + Homebrew
            chromedriver_path = "/usr/local/bin/chromedriver"
        else:
            chromedriver_path = "./chromedriver"


        driver = webdriver.Chrome(options=opts,
                                  executable_path=chromedriver_path)

    query_string = urlencode(payload)
    url = login_url + query_string
    driver.get(base_url + '?ipRedirectOverride=true')
    driver.get(url)
    if os.getenv("DEBUG") or options.debug:  # enable if you hit CAPTCHA or 2FA or other "security" screens
        print("[!] Running in DEBUG mode. You will need to login in a semi-automatic way, wait for the login screen to show up ;)")
        time.sleep(32)
    else:
        search_box = driver.find_element_by_id('ap_email')
        search_box.send_keys(username)
        search_box = driver.find_element_by_id('ap_password')
        search_box.send_keys(password)
        search_box.submit()
        time.sleep(2)  # give the page some time to load

    # Apparently, automated logins get detected now. The user receives a
    # one-time password via email and is asked to type it into a textbox.
    # After login pause and give user a chance to enter one-time password
    # manually.
    msg = "\nATTENTION: Now you may have to enter a one-time password manually. Once you are done, press enter to continue..."
    if PY3:
        input(msg)
    else:
        raw_input(msg)

    # Step 2
    driver.get(base_url + 'player-auth-token?playerType=software&bp_ua=y&playerModel=Desktop&playerId=%s&playerManufacturer=Audible&serial=' % (player_id))
    current_url = driver.current_url
    o = urlparse(current_url)
    data = dict(parse_qsl(o.query))

    # Step 2.5, switch User-Agent to "Audible Download Manager"
    headers = {
        'User-Agent': "Audible Download Manager",
    }
    cookies = driver.get_cookies()
    s = requests.Session()
    for cookie in cookies:
        s.cookies.set(cookie['name'], cookie['value'])

    # Step 3, de-register first, in order to stop hogging all activation slots
    # (there are 8 of them!)
    durl = base_url_license + 'license/licenseForCustomerToken?' \
        + 'customer_token=' + data["playerToken"] + "&action=de-register"
    s.get(durl, headers=headers)

    # Step 4
    url = base_url_license + 'license/licenseForCustomerToken?' \
        + 'customer_token=' + data["playerToken"]
    response = s.get(url, headers=headers)

    with open("activation.blob", "wb") as f:
        f.write(response.content)
    activation_bytes, _ = common.extract_activation_bytes(response.content)
    print("activation_bytes: " + activation_bytes)

    # Step 5 (de-register again to stop filling activation slots)
    s.get(durl, headers=headers)

    # driver.get(url)
    time.sleep(8)
    driver.quit()
def fetch_activation_bytes(username, password, options):
    base_url = 'https://www.audible.com/'
    base_url_license = 'https://www.audible.com/'
    lang = options.lang

    # Step 0
    opts = webdriver.ChromeOptions()
    opts.add_argument("user-agent=Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; AS; rv:11.0) like Gecko")

    # Step 1
    if '@' in username:  # Amazon login using email address
        login_url = "https://www.amazon.com/ap/signin?"
    else:  # Audible member login using username (untested!)
        login_url = "https://www.audible.com/sign-in/ref=ap_to_private?forcePrivateSignIn=true&rdPath=https%3A%2F%2Fwww.audible.com%2F%3F"
    if lang != "us":  # something more clever might be needed
        login_url = login_url.replace('.com', "." + lang)
        base_url = base_url.replace('.com', "." + lang)

    player_id = base64.encodestring(hashlib.sha1("").digest()).rstrip()  # keep this same to avoid hogging activation slots
    if options.player_id:
        player_id = base64.encodestring(binascii.unhexlify(options.player_id)).rstrip()
    print("[*] Player ID is %s" % player_id)

    payload = {
        'openid.ns': 'http://specs.openid.net/auth/2.0',
        'openid.identity': 'http://specs.openid.net/auth/2.0/identifier_select',
        'openid.claimed_id': 'http://specs.openid.net/auth/2.0/identifier_select',
        'openid.mode': 'logout',
        'openid.assoc_handle': 'amzn_audible_' + lang,
        'openid.return_to': base_url + 'player-auth-token?playerType=software&playerId=%s=&bp_ua=y&playerModel=Desktop&playerManufacturer=Audible' % (player_id)
    }

    if sys.platform == 'win32':
        chromedriver_path = "chromedriver.exe"
    else:
        chromedriver_path = "./chromedriver"

    driver = webdriver.Chrome(chrome_options=opts,
                              executable_path=chromedriver_path)

    query_string = urlencode(payload)
    url = login_url + query_string
    driver.get(base_url + '?ipRedirectOverride=true')
    driver.get(url)
    search_box = driver.find_element_by_id('ap_email')
    search_box.send_keys(username)
    search_box = driver.find_element_by_id('ap_password')
    search_box.send_keys(password)
    if os.getenv("DEBUG") or options.debug:  # enable if you hit CAPTCHA or 2FA or other "security" screens
        print("[!] Running in DEBUG mode. You will need to login in a semi-automatic way, wait for the login screen to show up ;)")
        time.sleep(32)
    else:
        search_box.submit()

    # Step 2
    driver.get(base_url + 'player-auth-token?playerType=software&bp_ua=y&playerModel=Desktop&playerId=%s&playerManufacturer=Audible&serial=' % (player_id))
    current_url = driver.current_url
    o = urlparse(current_url)
    data = dict(parse_qsl(o.query))

    # Step 2.5, switch User-Agent to "Audible Download Manager"
    headers = {
        'User-Agent': "Audible Download Manager",
    }
    cookies = driver.get_cookies()
    s = requests.Session()
    for cookie in cookies:
        s.cookies.set(cookie['name'], cookie['value'])

    # Step 3, de-register first, in order to stop hogging all activation slots
    # (there are 8 of them!)
    durl = base_url_license + 'license/licenseForCustomerToken?' \
        + 'customer_token=' + data["playerToken"] + "&action=de-register"
    s.get(durl, headers=headers)

    # Step 4
    url = base_url_license + 'license/licenseForCustomerToken?' \
        + 'customer_token=' + data["playerToken"]
    response = s.get(url, headers=headers)

    with open("activation.blob", "wb") as f:
        f.write(response.content)
    activation_bytes, _ = common.extract_activation_bytes(response.content)
    print(activation_bytes)

    # Step 5 (de-register again to stop filling activation slots)
    s.get(durl, headers=headers)

    # driver.get(url)
    time.sleep(8)
    driver.quit()
Esempio n. 6
0
#!/usr/bin/env python

import sys
import common

template = """REGEDIT4

[HKEY_LOCAL_MACHINE\Software\Audible\SWGIDMAP]
"0"=hex:%s
"1"=hex:%s
"2"=hex:%s
"3"=hex:%s
"4"=hex:%s
"5"=hex:%s
"6"=hex:%s
"7"=hex:%s
"""

if __name__ == "__main__":
    if len(sys.argv) < 2:
        sys.stderr.write(
            "Usage: %s <activation.blob / licenseForCustomerToken file>\n" %
            sys.argv[0])
        sys.exit(-1)

    with open(sys.argv[1], "rb") as f:
        activation_bytes, output = common.extract_activation_bytes(f.read())
        print(activation_bytes)
        print((template % (output[0], output[1], output[2], output[3],
                           output[4], output[5], output[6], output[7])))
def fetch_activation_bytes(username, password):
    if os.getenv("DEBUG"):
        print("[!] Running in DEBUG mode. You will need to login in a semi-automatic way, wait for the login screen to show up ;)")

    # Step 0
    opts = webdriver.ChromeOptions()
    # opts.add_argument("user-agent=Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET4.0C; .NET4.0E; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET CLR 1.1.4322)")
    opts.add_argument("user-agent=Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; AS; rv:11.0) like Gecko")
    driver = webdriver.Chrome(chrome_options=opts, executable_path="./chromedriver")

    # Step 1
    if '@' in username:  # Amazon login using email address
        base_url = "https://www.amazon.com/ap/signin?"
    else:  # Audible member login using username (untested!)
        base_url = "https://www.audible.com/sign-in/ref=ap_to_private?forcePrivateSignIn=true&rdPath=https%3A%2F%2Fwww.audible.com%2F%3F"
    # fake_hash = hashlib.sha1(os.urandom(128)).digest()
    # playerId = base64.encodestring(fake_hash).rstrip()  # generate base64 digest of a random 20 byte string ;)
    playerId = base64.encodestring(hashlib.sha1("").digest()).rstrip()
    payload = {
        'openid.ns': 'http://specs.openid.net/auth/2.0',
        'openid.identity': 'http://specs.openid.net/auth/2.0/identifier_select',
        'openid.claimed_id': 'http://specs.openid.net/auth/2.0/identifier_select',
        'openid.mode': 'logout',
        'openid.assoc_handle': 'amzn_audible_us',
        'openid.return_to': 'https://www.audible.com/player-auth-token?playerType=software&playerId=%s=&bp_ua=y&playerModel=Desktop&playerManufacturer=Audible' % (playerId)
    }
    query_string = urlencode(payload)
    url = base_url + query_string
    # print(url, file=sys.stderr)
    # http://chromedriver.storage.googleapis.com/index.html?path=2.19/
    driver.get('https://www.audible.com/?ipRedirectOverride=true')
    driver.get(url)
    search_box = driver.find_element_by_id('ap_email')
    search_box.send_keys(username)
    search_box = driver.find_element_by_id('ap_password')
    search_box.send_keys(password)
    if os.getenv("DEBUG"):  # enable if you hit CAPTCHA (or other "security" screens)
        time.sleep(32)
    else:
        search_box.submit()

    # Step 2
    driver.get('https://www.audible.com/player-auth-token?playerType=software&bp_ua=y&playerModel=Desktop&playerId=%s&playerManufacturer=Audible&serial=' % (playerId))
    current_url = driver.current_url
    o = urlparse(current_url)
    data = dict(parse_qsl(o.query))
    # print(data, file=sys.stderr)

    # Step 2.5, switch User-Agent to "Audible Download Manager"
    headers = {
        'User-Agent': "Audible Download Manager",
    }
    cookies = driver.get_cookies()
    s = requests.Session()
    for cookie in cookies:
        s.cookies.set(cookie['name'], cookie['value'])

    # Step 3, de-register first, in order to stop hogging all activation slots (there are 8 of them!)
    durl = 'https://www.audible.com/license/licenseForCustomerToken?' + 'customer_token=' + data["playerToken"] + "&action=de-register"
    # print(durl, file=sys.stderr)
    response = s.get(durl, headers=headers)
    # driver.get(durl)
    # extract_activation_bytes(response.content)

    # Step 4
    # url = 'https://www.audible.com/license/licenseForCustomerToken?' + 'customer_token=' + data["playerToken"] + "&action=register"
    url = 'https://www.audible.com/license/licenseForCustomerToken?' + 'customer_token=' + data["playerToken"]
    # print(url, file=sys.stderr)
    response = s.get(url, headers=headers)
    # driver.get(durl)
    # print(response.content)
    common.extract_activation_bytes(response.content)

    # Step 5 (de-register again to stop filling activation slots)
    # print(durl, file=sys.stderr)
    # driver.get(durl)
    response = s.get(durl, headers=headers)

    # driver.get(url)
    time.sleep(8)
    driver.quit()