コード例 #1
0
    def logon(self):
        'Login generator.'

        y = self.yahoo

        def fail(exc=None):
            y.set_disconnected(y.Reasons.CONN_FAIL)

        user, password = y.username, y.password
        log.info('logging in %s', user)

        y.change_state(y.Statuses.AUTHENTICATING)

        yield self.send_auth_req(user)
        print 'waiting for auth'
        (_hdr, data) = (yield self.gwait('auth', 'brb', self.logon_err))
        print 'got auth_brb'
        # got a auth challenge back
        auth_challenge = self.from_ydict(data)

        if not '94' in auth_challenge:
            log.warning(
                'auth challenge packet did not have challenge str (94): %r',
                auth_challenge)
            fail()
            return

        challenge_str = auth_challenge['94']
        common.callsback(self.yahoo_15_weblogin)(user,
                                                 password,
                                                 challenge_str,
                                                 error=fail)
コード例 #2
0
ファイル: yahoologinbase.py プロジェクト: niterain/digsby
    def logon(self):
        "Login generator."

        y = self.yahoo

        def fail(exc=None):
            y.set_disconnected(y.Reasons.CONN_FAIL)

        user, password = y.username, y.password
        log.info("logging in %s", user)

        y.change_state(y.Statuses.AUTHENTICATING)

        yield self.send_auth_req(user)
        print "waiting for auth"
        (_hdr, data) = (yield self.gwait("auth", "brb", self.logon_err))
        print "got auth_brb"
        # got a auth challenge back
        auth_challenge = self.from_ydict(data)

        if not "94" in auth_challenge:
            log.warning("auth challenge packet did not have challenge str (94): %r", auth_challenge)
            fail()
            return

        challenge_str = auth_challenge["94"]
        common.callsback(self.yahoo_15_weblogin)(user, password, challenge_str, error=fail)
コード例 #3
0
    def yahoo_15_weblogin(self, user, password, challenge_str, callback=None):
        '''
        Version 15 login, using an SSL connection to an HTTP server.
        '''
        y = self.yahoo
        jar = getattr(y, 'jar', None)

        def yahoo_v15_auth_success(crumb, yc, t, jar):
            y.cookies.update(Y=yc.split()[0][:-1], T=t.split()[0][:-1])
            y.jar = jar

            crumbchallengehash = yahoo64(md5(crumb + challenge_str).digest())

            log.info('logging on with initial status %s', y.initial_status)
            common.netcall(lambda: y.send(
                'authresp',
                y.initial_status,
                [
                    1,
                    user,
                    0,
                    user,
                    'ycookie',
                    yc,
                    'tcookie',
                    t,
                    'crumbchallengehash',
                    crumbchallengehash,
                    'mystery_login_num',
                    '8388543',  #str(0x3fffbf),#'4194239',
                    'identity',
                    user,
                    'locale',
                    'us',
                    'version_str',
                    '10.0.0.1270'
                ]))

        def yahoo_v15_auth_error(e):
            if isinstance(e, YahooRateLimitException):
                return y.set_disconnected(y.Reasons.RATE_LIMIT)
            if isinstance(e, YahooAuthException):
                y._auth_error_msg = getattr(e, 'error_msg', None) or getattr(
                    e, 'error_type', None)
                return y.set_disconnected(y.Reasons.BAD_PASSWORD)
            callback.error(e)

        common.callsback(self.yahoo_v15_auth)(challenge_str,
                                              password,
                                              user,
                                              jar=jar,
                                              success=yahoo_v15_auth_success,
                                              error=yahoo_v15_auth_error)
コード例 #4
0
ファイル: yahoologinbase.py プロジェクト: niterain/digsby
    def yahoo_15_weblogin(self, user, password, challenge_str, callback=None):
        """
        Version 15 login, using an SSL connection to an HTTP server.
        """
        y = self.yahoo
        jar = getattr(y, "jar", None)

        def yahoo_v15_auth_success(crumb, yc, t, jar):
            y.cookies.update(Y=yc.split()[0][:-1], T=t.split()[0][:-1])
            y.jar = jar

            crumbchallengehash = yahoo64(md5(crumb + challenge_str).digest())

            log.info("logging on with initial status %s", y.initial_status)
            common.netcall(
                lambda: y.send(
                    "authresp",
                    y.initial_status,
                    [
                        1,
                        user,
                        0,
                        user,
                        "ycookie",
                        yc,
                        "tcookie",
                        t,
                        "crumbchallengehash",
                        crumbchallengehash,
                        "mystery_login_num",
                        "8388543",  # str(0x3fffbf),#'4194239',
                        "identity",
                        user,
                        "locale",
                        "us",
                        "version_str",
                        "10.0.0.1270",
                    ],
                )
            )

        def yahoo_v15_auth_error(e):
            if isinstance(e, YahooRateLimitException):
                return y.set_disconnected(y.Reasons.RATE_LIMIT)
            if isinstance(e, YahooAuthException):
                y._auth_error_msg = getattr(e, "error_msg", None) or getattr(e, "error_type", None)
                return y.set_disconnected(y.Reasons.BAD_PASSWORD)
            callback.error(e)

        common.callsback(self.yahoo_v15_auth)(
            challenge_str, password, user, jar=jar, success=yahoo_v15_auth_success, error=yahoo_v15_auth_error
        )