def extract_encrypted(t): src = t._source if src: token = util.get_between(src, '<wst:RequestedSecurityToken>', '</wst:RequestedSecurityToken>') else: token = t.RequestedSecurityToken.EncryptedData._to_xml(pretty=False) return token
def handle_success_inbox(self, _name, resp): if self.check_message_at_login(resp): return data = resp.content redirect_url = self.check_for_redirect(data) if redirect_url is not None: log.info("Detected redirect in inbox: %r", redirect_url) if self.check_success_inbox(_name, resp): self.clear_waiting('inbox') self.request('inbox') return got_page_info = False got_app_info = False self.base_url = resp.geturl() doc = resp.document for script in doc.findall('.//script'): if not script.text: continue if not got_app_info: app_info_raw = util.get_between(script.text, 'App =', ';') if app_info_raw is not None: got_app_info = True if not got_page_info: page_info_raw = util.get_between(script.text, 'Page =', ';') if page_info_raw not in (None, ' {}'): got_page_info = True if got_app_info and got_page_info: break else: raise NotInbox("Could not find app info or page info. Here's status, headers, raw data: (%r, %r, %r)", resp.code, str(resp.headers), resp.content) try: app_info = jsdict_to_python(app_info_raw) except Exception: raise NotInbox("Error parsing app info. Here's raw data: (%r, %r)", app_info_raw, resp.content) try: page_info = jsdict_to_python(page_info_raw) except Exception: raise NotInbox("Error parsing page info. Here's raw data: (%r, %r)", page_info_raw, resp.content) log.info('Got app & page info: App = %r, Page = %r', app_info, page_info) self._app_info = app_info self._cfg_info = page_info cfg_info = page_info.get('fppCfg', {}) trash_id = app_info.get('config', {}).get('sysFldrs', {}).get('trashFid', None) if trash_id is not None: self._trash_id = uuid.UUID(trash_id) else: self._trash_id = uuid.UUID(int=folderids.trash) network = ajax.Network_Type(ajax.FPPConfig(self), self, cfg_info) self.HM = ajax.HM_Type(network, urlparse.urlparse(self.base_url).hostname, app_info) log.info("Hotmail site version: %r", self.HM.build) if self.HM.build > max(sum((x.keys() for x in ajax._versioned_classes.values()), [])): if not getattr(self, 'warned_newbuild', False): self.warned_newbuild = True try: raise Exception("New hotmail build detected: %r" % self.HM.build) except: import traceback; traceback.print_exc() self._process_folderlist(doc) folders = self.folders inboxid = uuid.UUID(int=folderids.inbox) self.inbox = ([f for f in folders if f.id == inboxid] or [None])[0] self.trash = ([f for f in folders if f.id == self._trash_id] or [None])[0] self.GetInboxData(folders = True, messages = True, success = self._process_ajax_inbox)
def handle_success_loginpage(self, _name, resp): doc = resp.document if doc is None: raise NotInbox() if int(self.PP_AUTH_VERSION) < 900: form = None for form in doc.forms: if form.get('name') == 'f1': # it would be great if this had a real name, like "login" or something. break if form is None: self.handle_error(_name, Exception('No login form found')) log.error("Document: %r", HTML.tostring(doc)) return form.fields['login'] = self.username form.fields['passwd'] = self._decryptedpw() self._login_form = form else: data = HTML.tostring(doc) log.error("Document: %r", data) ppft_html = eval(util.get_between(data, "sFTTag:", ",") or 'None') ppft_token = HTML.fromstring(ppft_html).attrib['value'] bk = str(int(time.time())) action_url = net.UrlQuery('https://login.live.com/ppsecure/post.srf', **{'bk': bk, 'cbcxt': 'mai', 'ct': bk, 'id': '64855', 'lc': '1033', 'mkt': 'en-us', 'rpsnv': '11', 'rver': '6.1.6206.0', 'snsc': '1', 'wa': 'wsignin1.0', 'wp': 'MBI', 'wreply': 'https://mail.live.com/default.aspx'}) if _is_login_domain_exception(self.username): action_url = action_url.replace('login.live.com', 'msnia.login.live.com') self._login_form = util.Storage(form_values = lambda: dict(login = self.username, passwd = self._decryptedpw(), type = '11', LoginOptions = '2', NewUser='******', MEST='', PPSX='Passp', PPFT= ppft_token, idsbho = '1', PwdPad = '', sso = '', i1 = '1', i2 = '1', i3 = '161605', i4 = '', i12 = '1', ), action = action_url) log.info('Got loginform for %r, submitting', self) self.request('sendauth')
def handle_success_inbox(self, _name, resp): if self.check_message_at_login(resp): return data = resp.content redirect_url = self.check_for_redirect(data) if redirect_url is not None: log.info("Detected redirect in inbox: %r", redirect_url) if self.check_success_inbox(_name, resp): self.clear_waiting('inbox') self.request('inbox') return got_page_info = False got_app_info = False self.base_url = resp.geturl() doc = resp.document for script in doc.findall('.//script'): if not script.text: continue if not got_app_info: app_info_raw = util.get_between(script.text, 'App =', ';') if app_info_raw is not None: got_app_info = True if not got_page_info: page_info_raw = util.get_between(script.text, 'Page =', ';') if page_info_raw not in (None, ' {}'): got_page_info = True if got_app_info and got_page_info: break else: raise NotInbox( "Could not find app info or page info. Here's status, headers, raw data: (%r, %r, %r)", resp.code, str(resp.headers), resp.content) try: app_info = jsdict_to_python(app_info_raw) except Exception: raise NotInbox("Error parsing app info. Here's raw data: (%r, %r)", app_info_raw, resp.content) try: page_info = jsdict_to_python(page_info_raw) except Exception: raise NotInbox( "Error parsing page info. Here's raw data: (%r, %r)", page_info_raw, resp.content) log.info('Got app & page info: App = %r, Page = %r', app_info, page_info) self._app_info = app_info self._cfg_info = page_info cfg_info = page_info.get('fppCfg', {}) trash_id = app_info.get('config', {}).get('sysFldrs', {}).get('trashFid', None) if trash_id is not None: self._trash_id = uuid.UUID(trash_id) else: self._trash_id = uuid.UUID(int=folderids.trash) network = ajax.Network_Type(ajax.FPPConfig(self), self, cfg_info) self.HM = ajax.HM_Type(network, urlparse.urlparse(self.base_url).hostname, app_info) log.info("Hotmail site version: %r", self.HM.build) if self.HM.build > max( sum((x.keys() for x in ajax._versioned_classes.values()), [])): if not getattr(self, 'warned_newbuild', False): self.warned_newbuild = True try: raise Exception("New hotmail build detected: %r" % self.HM.build) except: import traceback traceback.print_exc() self._process_folderlist(doc) folders = self.folders inboxid = uuid.UUID(int=folderids.inbox) self.inbox = ([f for f in folders if f.id == inboxid] or [None])[0] self.trash = ([f for f in folders if f.id == self._trash_id] or [None])[0] self.GetInboxData(folders=True, messages=True, success=self._process_ajax_inbox)
def handle_success_loginpage(self, _name, resp): doc = resp.document if doc is None: raise NotInbox() if int(self.PP_AUTH_VERSION) < 900: form = None for form in doc.forms: if form.get( 'name' ) == 'f1': # it would be great if this had a real name, like "login" or something. break if form is None: self.handle_error(_name, Exception('No login form found')) log.error("Document: %r", HTML.tostring(doc)) return form.fields['login'] = self.username form.fields['passwd'] = self._decryptedpw() self._login_form = form else: data = HTML.tostring(doc) log.error("Document: %r", data) ppft_html = eval(util.get_between(data, "sFTTag:", ",") or 'None') ppft_token = HTML.fromstring(ppft_html).attrib['value'] bk = str(int(time.time())) action_url = net.UrlQuery( 'https://login.live.com/ppsecure/post.srf', **{ 'bk': bk, 'cbcxt': 'mai', 'ct': bk, 'id': '64855', 'lc': '1033', 'mkt': 'en-us', 'rpsnv': '11', 'rver': '6.1.6206.0', 'snsc': '1', 'wa': 'wsignin1.0', 'wp': 'MBI', 'wreply': 'https://mail.live.com/default.aspx' }) if _is_login_domain_exception(self.username): action_url = action_url.replace('login.live.com', 'msnia.login.live.com') self._login_form = util.Storage(form_values=lambda: dict( login=self.username, passwd=self._decryptedpw(), type='11', LoginOptions='2', NewUser='******', MEST='', PPSX='Passp', PPFT=ppft_token, idsbho='1', PwdPad='', sso='', i1='1', i2='1', i3='161605', i4='', i12='1', ), action=action_url) log.info('Got loginform for %r, submitting', self) self.request('sendauth')