示例#1
0
    def _parse_SearchHistory_lenovo(self, table_name):
        ''' databases/lebrowser.db - search_record

            Table Columns
                FieldName	SQLType     	
                _id	        INTEGER
                search	    TEXT
                date	    INTEGER
                url	        TEXT
                visits	    INTEGER
                created	    INTEGER
        '''
        for rec in self._read_table(table_name):
            try:
                if (self._is_empty(rec, '_id', 'search')
                        or self._is_duplicate(rec, '_id')):
                    continue
                search_history = model_browser.SearchHistory()
                search_history.id = rec['_id'].Value
                search_history.name = rec['search'].Value
                search_history.url = rec['url'].Value if self._is_url(
                    rec, 'url') else None
                search_history.datetime = rec['date'].Value
                search_history.owneruser = self.cur_account_name
                search_history.source = self.cur_db_source
                search_history.deleted = 1 if rec.IsDeleted else 0
                self.csm.db_insert_table_searchhistory(search_history)
            except:
                exc()
        self.csm.db_commit()
示例#2
0
 def parse_SearchHistory(self, db_path, table_name):
     """
         dbbrowser.db - url_input_record - 输入记录
         RecNo	    FieldName
         1	date	        INTEGER
         2	_id	            INTEGER
         3	title	        TEXT
         4	url	            TEXT
         5	visits	        INTEGER
         """
     if not self._read_db(db_path):
         return
     for rec in self._read_table(table_name):
         if canceller.IsCancellationRequested:
             return
         if self._is_empty(rec, 'url',
                           'title') or not self._is_url(rec, 'url'):
             continue
         if self._is_duplicate(rec, '_id'):
             continue
         search_history = model_browser.SearchHistory()
         search_history.id = rec['_id'].Value
         search_history.name = rec['title'].Value
         search_history.url = rec['url'].Value
         search_history.datetime = rec['date'].Value
         search_history.source = self.cur_db_source
         search_history.deleted = 1 if rec.IsDeleted else 0
         try:
             self.csm.db_insert_table_searchhistory(search_history)
         except:
             exc()
     try:
         self.csm.db_commit()
     except:
         exc()
示例#3
0
 def parse_SearchHistory(self, db_path, table_name):
     """ SearchBox.db - clicklog
     RecNo	FieldName	SQLType	Size	Precision	PKDisplay	
     1	_id	            INTEGER
     2	intent_key	        TEXT
     3	query	            TEXT
     4	hit_time	        INTEGER
     5	source	            TEXT
     """
     if not self._read_db(db_path):
         return
     for rec in self._read_table(table_name):
         if canceller.IsCancellationRequested:
             return
         if self._is_empty(rec, 'intent_key',
                           'query') or self._is_duplicate(rec, '_id'):
             continue
         search_history = model_browser.SearchHistory()
         search_history.id = rec['_id'].Value
         search_history.name = rec['query'].Value
         # search_history.url      = rec['query'].Value
         search_history.datetime = rec['hit_time'].Value
         search_history.source = self.cur_db_source
         search_history.deleted = 1 if rec.IsDeleted else 0
         try:
             self.csm.db_insert_table_searchhistory(search_history)
         except:
             exc()
     try:
         self.csm.db_commit()
     except:
         exc()
示例#4
0
    def _parse_SearchHistory_xiaomi(self, table_name):
        ''' databases/browser2.db - mostvisited

            Table Columns
                FieldName	    SQLType       	
                _id	            INTEGER
                title	        TEXT
                sub_title	    TEXT
                type	        TEXT
                doc_type	    TEXT
                ads_info	    TEXT
                url	            TEXT
                web_url	        TEXT
                date	        LONG
        '''
        for rec in self._read_table(table_name):
            try:
                if (self._is_empty(rec, '_id', 'title')
                        or self._is_duplicate(rec, '_id')
                        or rec['type'].Value != 'search'):
                    continue
                search_history = model_browser.SearchHistory()
                search_history.id = rec['_id'].Value
                search_history.name = rec['title'].Value
                search_history.url = rec['url'].Value if self._is_url(
                    rec, 'url') else None
                search_history.datetime = rec['date'].Value
                search_history.owneruser = self.cur_account_name
                search_history.source = self.cur_db_source
                search_history.deleted = 1 if rec.IsDeleted else 0
                self.csm.db_insert_table_searchhistory(search_history)
            except:
                exc()
        self.csm.db_commit()
示例#5
0
 def _parse_SearchHistory_oppo(self, table_name):
     ''' databases/browser2.db - oppo_quicksearch_history
             FieldName	                SQLType		
             _id	                        INTEGER			
             keyword	                    TEXT			
             keyword_normalized	        TEXT			
             keyword_pinyin_normalized	TEXT			
             keyword_type	INTEGER	    False	
             time	                    INTEGER			
             url	                        TEXT			
     '''
     for rec in self._read_table(table_name):
         try:
             if (self._is_empty(rec, '_id', 'keyword')
                     or self._is_duplicate(rec, '_id')
                     or not self._is_url(rec, 'url')):
                 continue
             search_history = model_browser.SearchHistory()
             search_history.id = rec['_id'].Value
             search_history.name = rec['keyword'].Value
             search_history.url = rec['url'].Value if self._is_url(
                 rec, 'url') else None
             search_history.datetime = rec['time'].Value
             search_history.owneruser = self.cur_account_name
             search_history.source = self.cur_db_source
             search_history.deleted = 1 if rec.IsDeleted else 0
             self.csm.db_insert_table_searchhistory(search_history)
         except:
             exc()
     self.csm.db_commit()
示例#6
0
    def _parse_SearchHistory_vivo_huawei(self, table_name):
        ''' databases/browser2.db - searches 无 URL

            FieldName	SQLType   	
            _id	        INTEGER
            search	    TEXT
            date	    LONG
            type	    INTEGER          # old android non
            extra	    TEXT         # old android non
        '''
        for rec in self._read_table(table_name):
            try:
                if (self._is_empty(rec, '_id', 'search')
                        or self._is_duplicate(rec, '_id')):
                    continue
                search_history = model_browser.SearchHistory()
                search_history.id = rec['_id'].Value
                search_history.name = rec['search'].Value
                search_history.datetime = rec['date'].Value
                search_history.owneruser = self.cur_account_name
                search_history.source = self.cur_db_source
                search_history.deleted = 1 if rec.IsDeleted else 0
                self.csm.db_insert_table_searchhistory(search_history)
            except:
                exc()
        self.csm.db_commit()
示例#7
0
    def parse_Browserecord_SearchHistory(self, db_path, table_name):
        ''' databases/history - history 浏览记录

            FieldName	    SQLType	    	
            id	            INTEGER
            name	        TEXT
            url	            TEXT
            original_url    TEXT
            visited_time    INTEGER
            host	        TEXT
            visited_count	INTEGER
            state	        INTEGER
            media_type	    INTEGER
            url_hashcode	INTEGER
            from_type	    INTEGER
            source	        TEXT
            daoliu_type	    INTEGER
            article_id	    TEXT
            channel_id	    INTEGER
            icon_url	    TEXT
            temp_1	        TEXT
            temp_2	        TEXT
            temp_3	        TEXT
        '''
        if not self._read_db(db_path):
            return
        for rec in self._read_table(table_name):
            try:
                if (self._is_empty(rec, 'url', 'name') or
                    self._is_duplicate(rec, 'id') or
                        not self._is_url(rec, 'url')):
                    continue
                browser_record = model_browser.Browserecord()
                browser_record.id          = rec['id'].Value
                browser_record.name        = rec['name'].Value
                browser_record.url         = rec['url'].Value
                browser_record.datetime    = rec['visited_time'].Value
                browser_record.visit_count = rec['visited_count'].Value if rec['visited_count'].Value > 0 else 1
                browser_record.owneruser   = self.cur_account_name
                browser_record.source      = self.cur_db_source
                browser_record.deleted     = 1 if rec.IsDeleted else 0
                self.csm.db_insert_table_browserecords(browser_record)

                if browser_record.name.startswith('网页搜索_'):
                    search_history           = model_browser.SearchHistory()
                    search_history.id        = rec['id'].Value
                    search_history.name      = rec['name'].Value.replace('网页搜索_', '')
                    search_history.url       = rec['url'].Value
                    search_history.datetime  = rec['visited_time'].Value
                    search_history.owneruser = self.cur_account_name
                    search_history.source    = self.cur_db_source
                    search_history.deleted   = 1 if rec.IsDeleted else 0
                    self.csm.db_insert_table_searchhistory(search_history)
            except:
                exc()
        self.csm.db_commit()
示例#8
0
    def parse_Browserecord_SearchHistory(self, URLID_KEYWORD, table_name):
        ''' Default/History - urls

            FieldName	    SQLType     	        	
            id	            INTEGER
            url	            LONGVARCHAR
            title	            LONGVARCHAR
            visit_count	        INTEGER
            typed_count	        INTEGER
            last_visit_time	    INTEGER
            hidden	            INTEGER
        '''
        for rec in self._read_table(table_name):
            try:
                if (self._is_empty(rec, 'url', 'last_visit_time') or
                    self._is_duplicate(rec, 'id') or
                    not self._is_url(rec, 'url')):
                    continue
                browser_record = model_browser.Browserecord()
                browser_record.id          = rec['id'].Value
                browser_record.name        = rec['title'].Value
                browser_record.url         = rec['url'].Value
                browser_record.datetime    = self._convert_webkit_ts(rec['last_visit_time'].Value)
                browser_record.visit_count = rec['visit_count'].Value if rec['visit_count'].Value > 0 else 1
                browser_record.owneruser   = self.cur_account_name
                browser_record.source      = self.cur_db_source
                browser_record.deleted     = 1 if rec.IsDeleted else rec['hidden'].Value
                self.csm.db_insert_table_browserecords(browser_record)

                # 补充 keyword_search_terms 表中漏掉的搜索关键字
                if not URLID_KEYWORD.has_key(rec['id'].Value):
                    _search_item = self._search_item_from_browser_record(rec['title'].Value)
                else:
                    _search_item = ''

                if URLID_KEYWORD.has_key(rec['id'].Value) or _search_item:
                    search_history = model_browser.SearchHistory()
                    search_history.name = _search_item if _search_item else URLID_KEYWORD.get(rec['id'].Value, None)
                    search_history.id        = rec['id'].Value
                    search_history.url       = rec['url'].Value
                    search_history.datetime  = browser_record.datetime
                    search_history.owneruser = self.cur_account_name
                    search_history.source    = self.cur_db_source
                    search_history.deleted   = browser_record.deleted              
                    self.csm.db_insert_table_searchhistory(search_history)
            except:
                exc()
        self.csm.db_commit()
示例#9
0
 def _insert_search_from_browser_record(self, rec, _time):
     browser_title = rec['title'].Value
     try:
         _search_item = self._search_from_browser_record(browser_title)
         if not _search_item:
             return
         search_history = model_browser.SearchHistory()
         search_history.name = _search_item
         search_history.id = rec['_id'].Value
         search_history.url = rec['url'].Value
         search_history.datetime = _time
         search_history.owneruser = self.cur_account_name
         search_history.source = self.cur_db_source
         search_history.deleted = 1 if rec.IsDeleted else 0
         self.csm.db_insert_table_searchhistory(search_history)
     except:
         exc()
         return ''
示例#10
0
 def analyze_search_history(self):
     searchHistory = model_browser.SearchHistory()
     pattern = re.compile('[\\x00-\\x08\\x0b-\\x0c\\x0e-\\x1f]')
     fs = self.node.Parent
     ns = fs.Search(r'/\d+.db$')
     nodes = []
     for n in ns:
         nodes.append(n)
     nodes.append(self.node)
     try:
         for node in nodes:
             self.db = SQLiteParser.Database.FromNode(self.node, canceller)
             if self.db is None:
                 return
             ts = SQLiteParser.TableSignature('search_history')
             for rec in self.db.ReadTableRecords(ts, self.extractDeleted,
                                                 True):
                 canceller.ThrowIfCancellationRequested()
                 searchHistory.id = rec['ID'].Value if 'ID' in rec else None
                 searchHistory.name = rec[
                     'NAME'].Value if 'NAME' in rec and rec[
                         'NAME'].Value is not '' else None
                 searchHistory.url = rec[
                     'URL'].Value if 'URL' in rec and rec[
                         'URL'].Value is not '' else None
                 if not IsDBNull(rec['DATETIME'].Value):
                     searchHistory.datetime = self._timeHandler(
                         rec['DATETIME'].Value
                     ) if 'DATETIME' in rec else None
                 users = re.findall(r'^.*/(.+).db', node.AbsolutePath)
                 searchHistory.owneruser = users[0]
                 searchHistory.source = node.AbsolutePath
                 searchHistory.deleted = rec.IsDeleted
                 self.mb.db_insert_table_searchhistory(searchHistory)
             self.mb.db_commit()
     except Exception as e:
         traceback.print_exc()
         print(e)
示例#11
0
 def parse_formdata(self, table_name, id_url_dict):
     ''' FieldName  SQLType
         _id	        INTEGER    PK
         urlid	    INTEGER
         name	        TEXT
         value	    TEXT
     '''
     for rec in self._read_table(table_name):
         try:
             if (self._is_duplicate(rec, '_id')
                     or self._is_empty(rec, 'value')):
                 continue
             _url = id_url_dict.get(rec['urlid'].Value)
             _name = rec['name'].Value
             _value = rec['value'].Value
             if 'key' in _name or 'word' in _name:
                 search_history = model_browser.SearchHistory()
                 search_history.name = _value
                 search_history.url = _url
                 search_history.owneruser = self.cur_account_name
                 search_history.source = self.cur_db_source
                 search_history.deleted = 1 if rec.IsDeleted else 0
                 self.csm.db_insert_table_searchhistory(search_history)
             else:
                 form_data = model_browser.DBFormdata()
                 form_data.key = _value
                 # form_data.value = None
                 form_data.url = _url
                 # form_data.last_visited = _url
                 # form_data.visited_count = _url
                 form_data.form_type = self._convert_form_data_type(_name)
                 form_data.source = self.cur_db_source
                 form_data.deleted = 1 if rec.IsDeleted else 0
                 self.csm.db_insert_tb_from_mdbmodel(form_data)
         except:
             exc()
     self.csm.db_commit()
示例#12
0
    def parse_model(self):
        '''  WebBookmark
                Title
                Url
                Path
                # TimeStamp
                # Position
                # PositionAddress 
                # LastVisited (timestamp)
                Deleted
                Source.Value

            VisitedPage
                Title.Value
                Url.Value
                VisitCount.Value
                LastVisited.Value 

            SearchedItem
                TimeStamp
                Value

                # Position
                # PositionAddress
                # ItemType
                # SearchResultCount
                # OwnerUserID
                # SearchResults
        '''
        for item in self.results_model:
            if item.I18N == "书签":  # WebBookmark
                bookmark = model_browser.Bookmark()
                bookmark.id = self.bookmark_id
                self.bookmark_id += 1
                # bookmark.owneruser  =
                # bookmark.time       =
                bookmark.title = item.Title.Value
                bookmark.url = item.Url.Value
                bookmark.source = item.Source.Value
                bookmark.deleted = 0 if item.Deleted == DeletedState.Intact else 1
                self.mb.db_insert_table_bookmarks(bookmark)

            elif item.I18N == "浏览记录":  # VisitedPage
                browser_record = model_browser.Browserecord()
                # browser_record.id       =
                browser_record.name = item.Title.Value
                browser_record.url = item.Url.Value
                browser_record.datetime = self._convert_2_timestamp(
                    item.LastVisited)
                browser_record.source = item.Source.Value
                browser_record.deleted = 0 if item.Deleted == DeletedState.Intact else 1

                self.mb.db_insert_table_browserecords(browser_record)

            elif item.I18N == "搜索项":  # SearchedItem
                search_history = model_browser.SearchHistory()
                # search_history.id       =
                search_history.name = item.Value
                # search_history.url      =
                search_history.datetime = self._convert_2_timestamp(
                    item.TimeStamp)
                search_history.source = item.Source.Value
                search_history.deleted = 0 if item.Deleted == DeletedState.Intact else 1

                self.mb.db_insert_table_searchhistory(search_history)