Exemplo n.º 1
0
    def login(self):

        try:
            donotcache = self.now_milliseconds()

            self.httputil.rsa_data['donotcache'] = donotcache
            self.httputil.login_data['donotcache'] = donotcache

            temp_rsa = req.post('https://steamcommunity.com/login/getrsakey/',
                                headers=self.httputil.rsa_headers,
                                data=self.httputil.rsa_data)

            temp_ras_good = json.loads(temp_rsa.content)
            self.httputil.login_data['rsatimestamp'] = temp_ras_good[
                'timestamp']
            mod = long(temp_ras_good['publickey_mod'], 16)
            exp = long(temp_ras_good['publickey_exp'], 16)
            rsa_key = RSA.construct((mod, exp))
            rsa = PKCS1_v1_5.PKCS115_Cipher(rsa_key)
            encrypted_password = rsa.encrypt(self.httputil.password)
            encrypted_password = base64.b64encode(encrypted_password)
            self.httputil.login_data['password'] = encrypted_password

            temp_dologin = req.post(
                'https://steamcommunity.com/login/dologin/',
                headers=self.httputil.rsa_headers,
                data=self.httputil.login_data)

            temp_dologin_good = json.loads(temp_dologin.content)
            self.httputil.transfer_data['steamid'] = temp_dologin_good[
                'transfer_parameters']['steamid']
            self.httputil.transfer_data['token'] = temp_dologin_good[
                'transfer_parameters']['token']
            self.httputil.transfer_data['auth'] = temp_dologin_good[
                'transfer_parameters']['auth']
            self.httputil.transfer_data['remember_login'] = temp_dologin_good[
                'transfer_parameters']['remember_login']
            self.httputil.transfer_data['token_secure'] = temp_dologin_good[
                'transfer_parameters']['token_secure']

            req.post('https://store.steampowered.com/login/transfer',
                     headers=self.httputil.transfer_headers,
                     data=self.httputil.transfer_data)
        except:
            return False
Exemplo n.º 2
0
    def login(self, cookie_file=None, **details):
        '''
        Initiates login for Steam Web chat.
        '''
        if cookie_file:
            self.load_cookies(cookie_file)

        rsakey = self.session.post(CommunityURL("login", "getrsakey"),
                                   data={"username": details["username"]},
                                   headers=self._mobileHeaders)

        if rsakey.status_code != requests.codes.ok:
            rsakey.raise_for_status()
            return None, None

        rsakey = rsakey.json()

        mod = long(rsakey["publickey_mod"], 16)
        exp = long(rsakey["publickey_exp"], 16)
        rsa_key = RSA.construct((mod, exp))
        rsa = PKCS1_v1_5.PKCS115_Cipher(rsa_key)

        form = {
            "captcha_text": details.get("captcha", ""),
            "captchagid": self._captchaGid,
            "emailauth": details.get('steamguard', ""),
            "emailsteamid": "",
            "password": base64.b64encode(rsa.encrypt(details["password"])),
            "remember_login": "******",
            "rsatimestamp": rsakey["timestamp"],
            "twofactorcode": details.get('twofactor', ""),
            "username": details['username'],
            "oauth_client_id": "DE45CD61",
            "oauth_scope":
            "read_profile write_profile read_client write_client",
            "loginfriendlyname": "#login_emailauth_friendlyname_mobile"
        }

        dologin = self.session.post(CommunityURL("login", "dologin"),
                                    data=form,
                                    headers=self._mobileHeaders).json()

        self._cache = details
        if not dologin["success"] and dologin.get("emailauth_needed"):
            return LoginStatus.SteamGuard
        elif not dologin["success"] and dologin.get("requires_twofactor"):
            return LoginStatus.TwoFactor
        elif not dologin["success"] and dologin.get("captcha_needed"):
            print "Captcha URL: https://steamcommunity.com/public/captcha.php?gid=" + dologin[
                "captcha_gid"]
            self._captchaGid = dologin["captcha_gid"]
            return LoginStatus.Captcha
        elif not dologin["success"]:
            raise Exception(dologin.get("message", "Unknown error"))
        else:
            sessionID = generateSessionID()
            oAuth = json.loads(dologin["oauth"])
            self.session.cookies.set("sessionid", str(sessionID))
            self.sessionID = str(sessionID)

            self.steamID = SteamID.SteamID(oAuth["steamid"])
            self.oAuthToken = oAuth["oauth_token"]

            self._cache = {}
            self.steamguard = str(self.steamID) + "||" + \
                self.session.cookies.get(
                    "steamMachineAuth" + str(self.steamID), '')

            if cookie_file:
                self.save_cookies(cookie_file)

            return LoginStatus.LoginSuccessful

        self._cache = details
        return LoginStatus.LoginFailed