Example #1
0
    async def authenticate(self, stored_credentials=None):
        if not stored_credentials:
            return NextStep(
                "web_session",
                AUTH_PARAMS,
                cookies=[Cookie("passedICO", "true", ".bethesda.net")],
                js=JS)
        try:
            log.info("Got stored credentials")
            cookies = pickle.loads(
                bytes.fromhex(stored_credentials['cookie_jar']))
            cookies_parsed = []
            for cookie in cookies:
                if cookie.key in cookies_parsed and cookie.domain:
                    self._http_client.update_cookies(
                        {cookie.key: cookie.value})
                elif cookie.key not in cookies_parsed:
                    self._http_client.update_cookies(
                        {cookie.key: cookie.value})
                cookies_parsed.append(cookie.key)

            log.info("Finished parsing stored credentials, authenticating")
            user = await self._http_client.authenticate()

            self._http_client.set_auth_lost_callback(self.lost_authentication)
            return Authentication(user_id=user['user_id'],
                                  user_name=user['display_name'])
        except (AccessDenied, Banned, UnknownError) as e:
            log.error(
                f"Couldn't authenticate with stored credentials {repr(e)}")
            raise InvalidCredentials()
Example #2
0
async def test_no_stored_credentials(backend_client, plugin, cookies,
                                     auth_info, stored_credentials, mocker):
    steam_fake_cookie = Cookie(name="n", value="v")
    mocker.patch.object(plugin,
                        "_create_two_factor_fake_cookie",
                        return_value=steam_fake_cookie)
    assert NextStep(
        "web_session",
        AUTH_PARAMS,
        [steam_fake_cookie],
        {re.escape(LOGIN_URI): [JS_PERSISTENT_LOGIN]},
    ) == await plugin.authenticate()

    backend_client.get_profile.return_value = PROFILE_URL
    backend_client.get_profile_data.return_value = auth_info[0], auth_info[
        1], auth_info[2]

    store_credentials = mocker.patch.object(plugin, "store_credentials")
    assert Authentication(
        auth_info[0], auth_info[2]) == await plugin.pass_login_credentials(
            "random step name", {
                "end_uri":
                "https://steamcommunity.com/id/{}/goto".format(auth_info[0])
            }, cookies)
    store_credentials.assert_called_with(stored_credentials)

    backend_client.get_profile.assert_called_once_with()
    backend_client.get_profile_data.assert_called_once_with(PROFILE_URL)
Example #3
0
 def _create_two_factor_fake_cookie():
     return Cookie(
         # random SteamID with proper "instance", "type" and "universe" fields
         # (encoded in most significant bits)
         name="steamMachineAuth{}".format(
             random.randint(1, 2**32 - 1) + 0x01100001 * 2**32),
         # 40-bit random string encoded as hex
         value=hex(random.getrandbits(20 * 8))[2:].upper())
Example #4
0
STEAM_REGISTRY = "Software\\Valve\\Steam"
UBISOFT_REGISTRY_LAUNCHER = "SOFTWARE\\Ubisoft\\Launcher"
UBISOFT_REGISTRY_LAUNCHER_INSTALLS = "SOFTWARE\\Ubisoft\\Launcher\\Installs"

if SYSTEM == System.WINDOWS:
    UBISOFT_SETTINGS_YAML = os.path.join(os.getenv('LOCALAPPDATA'), 'Ubisoft Game Launcher', 'settings.yml')

UBISOFT_CONFIGURATIONS_BLACKLISTED_NAMES = ["gamename", "l1", '', 'ubisoft game', 'name']

CHROME_USERAGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36"
CLUB_APPID = "f35adcb5-1911-440c-b1c9-48fdc1701c68"
CLUB_GENOME_ID = "8ec37540-95c5-4a46-9174-86e04b8630cb"

AUTH_PARAMS = {
    "window_title": "Login to Uplay",
    "window_width": 400,
    "window_height": 680,
    "start_uri": f"https://connect.ubi.com/Default/Login?appId={CLUB_APPID}&genomeId={CLUB_GENOME_ID}&nextUrl=https%3A%2F%2Fclub.ubisoft.com",
    "end_uri_regex": r"^https://club\.ubisoft\.com/.*"
}

# Adding these cookies disables the cookie disclaimer which blocked major part of the view.
COOKIES = [Cookie("thirdPartyOk", "ok", ".ubi.com"),
           Cookie("TC_OPTOUT", "0@@@005@@@ALL", ".ubi.com"),
           Cookie("TC_OPTOUT_categories", "18%2C19", ".ubi.com")]

# another skin:
# UPLAY_GENOME_ID = "031c6c79-623d-4831-9c01-0f01d1f77c88"  # has to be matched with UPLAY APPID?
# Set with pixelated mac stuff
# CLUB_APPID = "314d4fef-e568-454a-ae06-43e3bece12a6"
# CLUB_GENOME_ID = "85c31714-0941-4876-a18d-2c7e9dce8d40"
Example #5
0
 def get_next_step_cookies(self):
     return [Cookie(cookie.key, cookie.value) for cookie in self.cookieJar]