Exemple #1
0
 def parse_chatroom(self, dbPath, deleteFlag):
     '''解析群组数据'''
     db = SQLite.SQLiteConnection('Data Source = {}; ReadOnly = True'.format(dbPath))
     db.Open()
     db_cmd = SQLite.SQLiteCommand(db)
     if deleteFlag is 1:
         self.db = SQLite.SQLiteConnection('Data Source = {}'.format(self.cachedb))
         self.db.Open()
         self.db_cmd = SQLite.SQLiteCommand(self.db)
     try:
         if db is None:
             return
         db_cmd.CommandText = '''select distinct _id, date, participant_id_1, participant_id_2, participant_id_3, participant_id_4, name from conversations where conversation_type = 1'''
         sr = db_cmd.ExecuteReader()
         dic = {}
         while (sr.Read()):
             try:
                 id = self._db_reader_get_int_value(sr, 0)
                 if id != 0:
                     if id not in dic.keys():
                         dic[id] = []
                         dic[id].append(deleteFlag)
                     elif deleteFlag in dic[id]:
                         continue
                 chatroom = model_im.Chatroom()
                 if canceller.IsCancellationRequested:
                     break
                 chatroom.account_id = self.account_id
                 chatroom.chatroom_id = self._db_reader_get_int_value(sr, 0)
                 chatroom.create_time = self._get_timestamp(sr[1]) if not IsDBNull(sr[1]) else 0
                 chatroom.deleted = deleteFlag
                 if sr[5] != 0:
                     count = 4
                 elif sr[4] != 0:
                     count = 3
                 elif sr[3] != 0:
                     count = 2
                 else:
                     count = 0
                 chatroom.member_count = count
                 chatroom.name = self._db_reader_get_string_value(sr, 6)
                 chatroom.source = self.node.AbsolutePath
                 self.db_insert_table_chatroom(chatroom)
             except:
                 traceback.print_exc()
         sr.Close()
         if deleteFlag is 0: 
             self.db_commit()
         db_cmd.Dispose()
         db.Close()
     except Exception as e:
         print(e)
Exemple #2
0
 def parse_chatroom(self, dbPath):
     '''解析群组数据'''
     db = SQLite.SQLiteConnection(
         'Data Source = {}; ReadOnly = True'.format(dbPath))
     db.Open()
     db_cmd = SQLite.SQLiteCommand(db)
     try:
         if db is None:
             return
         db_cmd.CommandText = '''select groupname, myuid, groupicon, groupId, deleted from DBTableNmae_GroupMsg'''
         sr = db_cmd.ExecuteReader()
         while (sr.Read()):
             try:
                 chatroom = model_im.Chatroom()
                 if canceller.IsCancellationRequested:
                     break
                 chatroom.account_id = self.account_id
                 chatroom.chatroom_id = self._db_reader_get_int_value(sr, 3)
                 chatroom.photo = self._db_reader_get_string_value(sr, 2)
                 chatroom.deleted = self._db_reader_get_int_value(sr, 4)
                 chatroom.name = self._db_reader_get_string_value(sr, 0)
                 chatroom.source = self.node.AbsolutePath
                 self.db_insert_table_chatroom(chatroom)
             except:
                 traceback.print_exc()
         sr.Close()
         self.db_commit()
         db_cmd.Dispose()
         db.Close()
     except Exception as e:
         print(e)
Exemple #3
0
 def _generate_contact(self):
     try:
         self.db_cmd = SQLite.SQLiteCommand(self.db)
         if self.db_cmd is None:
             return
         self.db_cmd.CommandText = '''select distinct b.account_user, a.contact_user,a.contact_alias, a.contact_group,
                                      a.contact_remark, a.contact_phone, a.contact_birthday, a.contact_profession, 
                                      a.contact_addr, a.contact_head_pic, a.contact_reg_date, a.contact_last_login,
                                      a.contact_last_modify, a.deleted from contact as a left join account as b on a.owner_account_id = b.account_id'''
         sr = self.db_cmd.ExecuteReader()
         while (sr.Read()):
             if canceller.IsCancellationRequested:
                 break
             contact = Contact()
             contact.COLLECT_TARGET_ID = self.collect_target_id
             contact.MAIL_TOOL_TYPE = self.mail_tool_type
             contact.ACCOUNT = sr[0]
             contact.FRIEND_ACCOUNT = sr[1]
             contact.FRIEND_NICKNAME = sr[2]
             contact.FRIEND_GROUP = sr[3]
             contact.FRIEND_REMARK = sr[4]
             contact.FIXED_PHONE = sr[5]
             contact.BIRTHDAY = sr[6]
             contact.OCCUPATION_NAME = sr[7]
             contact.POSTAL_ADDRESS = sr[8]
             contact.USER_PHOTO = sr[9]
             contact.ACCOUNT_REG_DATE = sr[10]
             contact.LAST_LOGIN_TIME = sr[11]
             contact.LATEST_MOD_TIME = sr[12]
             contact.DELETE_STATUS = sr[13]
             self.mail.db_insert_table_contact(contact)
         self.mail.db_commit()
     except Exception as e:
         print(e)
Exemple #4
0
 def __prepare_contact(self):
     im_conn = unity_c37r.create_connection(self.cache + '.IM')
     cmd = sql.SQLiteCommand(im_conn)
     cmd.CommandText = '''
         select account_id, nickname, photo from account
     '''
     reader = cmd.ExecuteReader()
     while reader.Read():
         o = O()
         o.uid = unity_c37r.c_sharp_get_string(reader, 0)
         o.nick = unity_c37r.c_sharp_get_string(reader, 1)
         o.photo = unity_c37r.c_sharp_get_string(reader, 2)
         self.contact[o.uid] = o
     reader.Close()
     #cmd.Dispose()
     cmd.CommandText = '''
         select friend_id, nickname, photo from friend
     '''
     reader = cmd.ExecuteReader()
     while reader.Read():
         o = O()
         o.uid = unity_c37r.c_sharp_get_string(reader, 0)
         o.nick = unity_c37r.c_sharp_get_string(reader, 1)
         o.photo = unity_c37r.c_sharp_get_string(reader, 2)
         if self.contact.__contains__(o.uid):
             continue
         self.contact[o.uid] = o
     reader.Close()
     cmd.Dispose()
     im_conn.Close()
Exemple #5
0
 def generate_deal_bcp(self):
     conn = unity_c37r.create_connection(self.cache_db + '.IM')
     cmds  = sql.SQLiteCommand(conn)
     cmds.CommandText = '''
         select * from deal
     '''
     reader = cmds.ExecuteReader()
     res = dict()
     while reader.Read():
         deal = DealInfo()
         deal.set_value_with_idx(deal.colltection_target_id, self.colltection_target_id)
         deal.set_value_with_idx(deal.app_code, self.app_code)
         deal.set_value_with_idx(deal.deal_id, unity_c37r.c_sharp_get_string(reader, 0))
         try:
             deal.set_value_with_idx(deal.money, unity_c37r.c_sharp_get_real(reader, 2))
         except:
             deal.set_value_with_idx(deal.money, 0)
         deal.set_value_with_idx(deal.description, unity_c37r.c_sharp_get_string(reader, 3))
         t = unity_c37r.c_sharp_get_long(reader, 6)
         if t != 0:
             deal.set_value_with_idx(deal.time, t)
         pass
         unity_c37r.execute_query(self.cmd, TBL_BCP_INSERT_DEAL, deal.get_values())
         # status... not supported right now
         # type ... not suppoted right now
     reader.Close()
     cmds.Dispose()
     conn.Close()
Exemple #6
0
 def _generate_call_record(self):
     try:
         self.db_cmd = SQLite.SQLiteCommand(self.db)
         if self.db_cmd is None:
             return
         self.db_cmd.CommandText = '''select distinct * from records'''
         sr = self.db_cmd.ExecuteReader()
         while (sr.Read()):
             if canceller.IsCancellationRequested:
                 break
             record = CallRecords()
             record.COLLECT_TARGET_ID = self.collect_target_id
             record.RELATIONSHIP_ACCOUNT = sr[1]
             record.RELATIONSHIP_NAME = sr[5]
             record.CALL_STATUS = CALL_STATUS_CONNECTD if sr[
                 4] is 1 else CALL_STATUS_MISSED if sr[
                     4] is 3 else CALL_STATUS_OTHER
             record.LOCAL_ACTION = LOCAL_ACTION_RECEIVE if sr[4] is 1 or sr[
                 4] is 3 else LOCAL_ACTION_SEND if sr[
                     4] is 2 else LOCAL_ACTION_OTHER
             record.START_TIME = sr[2]
             record.DUAL_TIME = sr[3]
             record.DELETE_STATUS = DELETE_STATUS_DELETED if sr[
                 12] == 1 else DELETE_STATUS_INTACT
             self.basic.db_insert_table_call_record(record)
         self.basic.db_commit()
         self.db_cmd.Dispose()
     except Exception as e:
         pass
Exemple #7
0
 def read_deleted_table_mailcontactgroup(self):
     self.db = SQLite.SQLiteConnection('Data Source = {}'.format(
         self.recoverDB))
     self.db.Open()
     self.db_cmd = SQLite.SQLiteCommand(self.db)
     try:
         node = self.node.Parent.GetByPath("/FMContact.db")
         if node is None:
             return
         db = SQLiteParser.Database.FromNode(node, canceller)
         if db is None:
             return
         ts = SQLiteParser.TableSignature('FMContactGroup')
         for rec in db.ReadTableDeletedRecords(ts, False):
             if canceller.IsCancellationRequested:
                 break
             param = ()
             param = param + (rec['groupid'].Value, )
             param = param + (rec['name'].Value, )
             self.db_insert_table(SQL_INSERT_TABLE_RECOVER_MAILCONTACTGROUP,
                                  param)
         self.db_cmd.Dispose()
         self.db.Close()
     except Exception as e:
         print(e)
Exemple #8
0
 def create_deleted_db(self):
     '''创建恢复数据库'''
     if os.path.exists(self.recoverDB):
         os.remove(self.recoverDB)
     self.db = SQLite.SQLiteConnection('Data Source = {}'.format(
         self.recoverDB))
     self.db.Open()
     self.db_cmd = SQLite.SQLiteCommand(self.db)
     if self.db_cmd is not None:
         self.db_cmd.CommandText = SQL_CREATE_TABLE_RECOVER_MAILACCOUNT
         self.db_cmd.ExecuteNonQuery()
         self.db_cmd.CommandText = SQL_CREATE_TABLE_RECOVER_MAILATTACH
         self.db_cmd.ExecuteNonQuery()
         self.db_cmd.CommandText = SQL_CREATE_TABLE_RECOVER_MAILCONTACT
         self.db_cmd.ExecuteNonQuery()
         self.db_cmd.CommandText = SQL_CREATE_TABLE_RECOVER_MAILCONTACTGROUP
         self.db_cmd.ExecuteNonQuery()
         self.db_cmd.CommandText = SQL_CREATE_TABLE_RECOVER_MAILCONTACTITEM
         self.db_cmd.ExecuteNonQuery()
         self.db_cmd.CommandText = SQL_CREATE_TABLE_RECOVER_MAILCONTENT
         self.db_cmd.ExecuteNonQuery()
         self.db_cmd.CommandText = SQL_CREATE_TABLE_RECOVER_MAILFOLDER
         self.db_cmd.ExecuteNonQuery()
         self.db_cmd.CommandText = SQL_CREATE_TABLE_RECOVER_MAILINFO
         self.db_cmd.ExecuteNonQuery()
     self.db_cmd.Dispose()
     self.db.Close()
Exemple #9
0
 def parse_chatroom(self, dbPath):
     '''解析群组数据'''
     db = SQLite.SQLiteConnection(
         'Data Source = {}; ReadOnly = True'.format(dbPath))
     db.Open()
     db_cmd = SQLite.SQLiteCommand(db)
     try:
         if db is None:
             return
         db_cmd.CommandText = '''select a.discussionid, a.title, a.memberver, count(b.memberid) as member_count, a.deleted from bb_discussion_info as a 
             left join bb_discussion_member_info as b on a.discussionid = b.discussionid group by a.discussionid'''
         sr = db_cmd.ExecuteReader()
         while (sr.Read()):
             try:
                 chatroom = model_im.Chatroom()
                 if canceller.IsCancellationRequested:
                     break
                 chatroom.account_id = self.account_id
                 chatroom.chatroom_id = self._db_reader_get_int_value(sr, 0)
                 chatroom.create_time = self._db_reader_get_int_value(sr, 2)
                 chatroom.deleted = self._db_reader_get_int_value(sr, 4)
                 chatroom.member_count = self._db_reader_get_int_value(
                     sr, 3)
                 chatroom.name = self._db_reader_get_string_value(sr, 1)
                 chatroom.source = self.node.AbsolutePath
                 self.db_insert_table_chatroom(chatroom)
             except:
                 traceback.print_exc()
         sr.Close()
         self.db_commit()
         db_cmd.Dispose()
         db.Close()
     except Exception as e:
         print(e)
Exemple #10
0
 def analyze_logic_calendar(self):
     try:
         db_source = self.node.PathWithMountPoint
         self.db = SQLite.SQLiteConnection(
             'Data Source = {}'.format(db_source))
         self.db.Open()
         self.db_cmd = SQLite.SQLiteCommand(self.db)
         if self.db is None:
             return
         self.db_cmd.CommandText = '''select distinct * from Calendar'''
         sr = self.db_cmd.ExecuteReader()
         while (sr.Read()):
             calendar = Calendar()
             if canceller.IsCancellationRequested:
                 break
             try:
                 calendar.calendar_id = sr[0]
                 calendar.title = sr[1]
                 calendar.description = sr[3]
                 calendar.dtstart = sr[5]
                 calendar.dtend = sr[6]
                 calendar.rrule = self._extractData(sr[4], 'FREQ')
                 calendar.interval = self._extractData(sr[4], 'INTERVAL')
                 calendar.until = self._extractData(sr[4], 'UNTIL')
                 calendar.source = self.node.AbsolutePath
                 self.mc.db_insert_calendar(calendar)
             except:
                 pass
         self.mc.db_commit()
         sr.Close()
         self.db.Close()
     except:
         pass
Exemple #11
0
def CheckVersion(db_name, v_key, v_value):
    try:
        if not os.path.exists(db_name):
            return False
        conn = None
        cmd = None
        reader = None
        res = False
        conn = create_connection(db_name)
        cmd = sql.SQLiteCommand(conn)
        cmd.CommandText = '''
            select v_val from tb_version where v_key = '{}'
        '''.format(v_key)
        reader = cmd.ExecuteReader()
        if reader.Read():
            value = c_sharp_get_long(reader, 0)
            if value == v_value:
                res = True
            else:
                res = False
        reader.Close()
        cmd.Dispose()
        conn.Close()
        return res
    except:
        if reader is not None:
            reader.Close()
        if cmd is not None:
            cmd.Dispose()
        if conn is not None:
            conn.Close()
        return False
Exemple #12
0
 def _get_media_thumbnail(self, media_id):
     try:
         db_cmd = SQLite.SQLiteCommand(self.db)
         db_cmd.CommandText = '''select distinct * from thumbnails where media_id = {}'''.format(media_id)
         sr = db_cmd.ExecuteReader()
         while(sr.Read()):
             try:
                 if canceller.IsCancellationRequested:
                     break
                 thumbnail = MediaFile.ThumbnailFile()
                 filePath = self._db_reader_get_string_value(sr, 1)
                 thumbnail.FileName = os.path.basename(filePath)
                 thumbnail.Path = filePath
                 thumbnail.Height = self._db_reader_get_int_value(sr, 4)
                 thumbnail.Width = self._db_reader_get_int_value(sr, 3)
                 addTime = self._db_reader_get_int_value(sr, 5)
                 thumbnail.AddTime = self._get_timestamp(addTime)
                 thumbnail.FileSuffix = self._db_reader_get_string_value(sr, 6)
                 thumbnail.MimeType = self._db_reader_get_string_value(sr, 6)
                 thumbnail.SourceFile = self._get_source_file(str(sr[7]))
                 thumbnail.Deleted = self._convert_deleted_status(sr[8])
                 return thumbnail
             except:
                 traceback.print_exc()
     except:
         pass
Exemple #13
0
 def _get_media_log(self, media_id):
     model = []
     try:
         db_cmd = SQLite.SQLiteCommand(self.db)
         db_cmd.CommandText = '''select distinct * from media_log where media_id = {}'''.format(media_id)
         sr = db_cmd.ExecuteReader()
         while(sr.Read()):
             try:
                 if canceller.IsCancellationRequested:
                     break
                 add_date = self.transtime(sr, 2)
                 adj_date = self.transtime(sr, 3)
                 cloudshare_date = self.transtime(sr, 4)
                 create_date = self.transtime(sr, 5)
                 faceadj_date = self.transtime(sr, 6)
                 lastshare_date = self.transtime(sr, 7)
                 modify_date = self.transtime(sr, 8)
                 taken_date = self.transtime(sr, 9)
                 trash_date = self.transtime(sr, 10)
                 dates = {add_date:"添加", adj_date:"调整", cloudshare_date:"icloud分享", create_date:"创建", 
                          faceadj_date:"面部调整", lastshare_date:"分享", modify_date:"修改", taken_date:"拍摄", trash_date:"删除"}
                 for date in sorted(dates.items(), key = lambda x:x[0], reverse=True):
                     if date[0] is None:
                         continue
                     log = MediaFile.MediaLog()
                     #log.FilePath = self._db_reader_get_string_value(sr, 14)
                     log.Operating = date[1]
                     log.OperatingTime = str(date[0])
                     model.append(log)
             except:
                 pass
     except:
         return []
     return model
Exemple #14
0
 def create_deleted_db(self):
     '''创建删除数据库'''
     if os.path.exists(self.recoverDB):
         os.remove(self.recoverDB)
     db = SQLite.SQLiteConnection('Data Source = {}'.format(self.recoverDB))
     db.Open()
     db_cmd = SQLite.SQLiteCommand(db)
     if db_cmd is not None:
         db_cmd.CommandText = '''create table if not exists cfurl_cache_receiver_data
             (entry_ID INTEGER, IsDataOnFS INTEGER, receiver_data BLOB, deleted INTEGER)'''
         db_cmd.ExecuteNonQuery()
         db_cmd.CommandText = '''create table if not exists DBTableName_UserRelation
             (otheruid INTEGER, icon TEXT, relation INTEGER, nickname TEXT, myuid INTEGER, gender INTEGER, sign TEXT, deleted INTEGER)'''
         db_cmd.ExecuteNonQuery()
         db_cmd.CommandText = '''create table if not exists DBTableNmae_GroupMsg
             (groupname TEXT, myuid INTEGER, groupicon TEXT, groupId INTEGER, deleted INTEGER)'''
         db_cmd.ExecuteNonQuery()
         db_cmd.CommandText = '''create table if not exists DBTableName_P2PMsg
             (time INTEGER, otheruid INTEGER, msgid INTEGER, msgstate INTEGER, attachment TEXT, distance INTEGER, myuid INTEGER, content TEXT, msgtype INTEGER, deleted INTEGER)'''
         db_cmd.ExecuteNonQuery()
         db_cmd.CommandText = '''create table if not exists DBTableName_MySendDynamic
             (address TEXT, userid INTEGER, sendTime INTEGER, nickname TEXT, icon TEXT, myuid INTEGER, likecount INTEGER, datetime INTEGER, reviewcount INTEGER, gender INTEGER, dynamicid INTEGER, sendPhotos BLOB, content TEXT, deleted INTEGER)'''
         db_cmd.ExecuteNonQuery()
     db_cmd.Dispose()
     db.Close()
Exemple #15
0
 def parse_feed_comment(self, dbPath):
     '''解析评论点赞数据'''
     db = SQLite.SQLiteConnection(
         'Data Source = {}; ReadOnly = True'.format(dbPath))
     db.Open()
     db_cmd = SQLite.SQLiteCommand(db)
     fs = self.node.FileSystem
     try:
         if self.db is None:
             return
         db_cmd.CommandText = ''''''
         sr = db_cmd.ExecuteReader()
         while (sr.Read()):
             try:
                 feed_like = model_im.FeedLike()
                 feed_comment = model_im.FeedComment()
                 if canceller.IsCancellationRequested:
                     break
                 pass
             except:
                 traceback.print_exc()
         sr.Close()
         self.db_commit()
         db_cmd.Dispose()
         db.Close()
     except Exception as e:
         print(e)
Exemple #16
0
 def analyze_account(self, mailPath, deleteFlag):
     '''保存账户数据到中间数据库'''
     self.db = SQLite.SQLiteConnection(
         'Data Source = {}; ReadOnly = True'.format(mailPath))
     self.db.Open()
     self.db_cmd = SQLite.SQLiteCommand(self.db)
     try:
         if self.db is None:
             return
         self.db_cmd.CommandText = SQL_ASSOCIATE_TABLE_ACCOUNT
         sr = self.db_cmd.ExecuteReader()
         while (sr.Read()):
             account = Account()
             if canceller.IsCancellationRequested:
                 break
             account.account_id = sr[0]
             account.account_user = sr[1]
             account.account_alias = sr[2]
             account.account_email = sr[1]
             account.source = self.node.AbsolutePath
             account.deleted = deleteFlag
             self.mm.db_insert_table_account(account)
         self.mm.db_commit()
         self.db_cmd.Dispose()
         self.db.Close()
     except Exception as e:
         print(e)
Exemple #17
0
 def analyze_contact(self, contactPath, deleteFlag):
     """保存联系人数据到中间数据库"""
     self.db = SQLite.SQLiteConnection(
         'Data Source = {}; ReadOnly = True'.format(contactPath))
     self.db.Open()
     self.db_cmd = SQLite.SQLiteCommand(self.db)
     try:
         if self.db is None:
             return
         self.db_cmd.CommandText = SQL_ASSOCIATE_TABLE_CONTACT
         sr = self.db_cmd.ExecuteReader()
         while sr.Read():
             contact = Contact()
             if canceller.IsCancellationRequested:
                 break
             contact.contact_id = sr[0]
             contact.owner_account_id = sr[1]
             contact.contact_user = sr[2]
             contact.contact_email = sr[2]
             contact.contact_alias = sr[3]
             contact.contact_group = sr[4]
             contact.contact_remark = sr[5]
             contact.contact_phone = sr[6]
             contact.source = self.node.AbsolutePath
             contact.deleted = deleteFlag
             self.mm.db_insert_table_contact(contact)
         self.mm.db_commit()
         self.db_cmd.Dispose()
         self.db.Close()
     except Exception as e:
         print(e)
Exemple #18
0
    def read_deleted_records(self):
        '''获取删除数据保存至删除数据库'''
        self.create_deleted_db()

        self.rdb = SQLite.SQLiteConnection('Data Source = {}'.format(
            self.recoverDB))
        self.rdb.Open()
        self.rdb_cmd = SQLite.SQLiteCommand(self.rdb)

        dbid = re.findall('\d+', os.path.basename(self.node.AbsolutePath))[0]
        fs = self.node.FileSystem
        nodes = fs.Search('buzz_' + dbid + '.db$')
        for node in nodes:
            self.fnode = node
            break

        self.rdb_trans = self.rdb.BeginTransaction()
        self.read_deleted_table_account()
        self.read_deleted_table_contact()
        self.read_deleted_table_group_user_id()
        self.read_deleted_table_group()
        self.read_deleted_table_group_user()
        self.read_deleted_table_message()
        self.read_deleted_table_group_chat()
        self.read_deleted_table_feed()
        self.read_deleted_table_feed_comments()
        self.rdb_trans.Commit()

        self.rdb_cmd.Dispose()
        self.rdb.Close()
Exemple #19
0
 def read_deleted_table_mailaccount(self):
     self.db = SQLite.SQLiteConnection('Data Source = {}'.format(
         self.recoverDB))
     self.db.Open()
     self.db_cmd = SQLite.SQLiteCommand(self.db)
     try:
         node = self.node
         if node is None:
             return
         db = SQLiteParser.Database.FromNode(node, canceller)
         if db is None:
             return
         ts = SQLiteParser.TableSignature('FM_Account_Setting')
         for rec in db.ReadTableDeletedRecords(ts, False):
             if canceller.IsCancellationRequested:
                 break
             param = ()
             param = param + (rec['id'].Value, )
             param = param + (rec['name'].Value, )
             param = param + (rec['nickname'].Value, )
             self.db_insert_table(SQL_INSERT_TABLE_RECOVER_MAILACCOUNT,
                                  param)
         self.db_cmd.Dispose()
         self.db.Close()
     except Exception as e:
         print(e)
Exemple #20
0
 def try_get_avfs_message_dict(self):
     avfs_dir_node = self.node.GetByPath('Documents/AVFSStorage')
     if avfs_dir_node is None:
         return
     avfs_path = avfs_dir_node.PathWithMountPoint
     pl = os.listdir(avfs_path)
     for f in pl:
         avfs_sqlite_node = self.node.GetByPath(
             'Documents/AVFSStorage/{}/avfs.sqlite'.format(f))
         if avfs_sqlite_node is None:
             continue
         conn = unity_c37r.create_connection_tentatively(avfs_sqlite_node)
         cmd = sql.SQLiteCommand(conn)
         cmd.CommandText = '''
             select tbl_name from sqlite_master where tbl_name = 'MPMProfileim_cc' and type = 'table'
         '''
         reader = cmd.ExecuteReader()
         if not reader.Read():
             reader.Close()
             cmd.Dispose()
             conn.Close()
             continue
         reader.Close()
         cmd.CommandText = '''
             select targetId from MPMProfileim_cc where name is not null
         '''
         reader = cmd.ExecuteReader()
         if reader.Read():
             uid = unity_c37r.c_sharp_get_string(reader, 0)
             self.avfs_message_dict[uid] = avfs_sqlite_node
         reader.Close()
         cmd.Dispose()
         conn.Close()
Exemple #21
0
 def read_deleted_table_mailattach(self):
     self.db = SQLite.SQLiteConnection('Data Source = {}'.format(
         self.recoverDB))
     self.db.Open()
     self.db_cmd = SQLite.SQLiteCommand(self.db)
     try:
         node = self.node
         if node is None:
             return
         db = SQLiteParser.Database.FromNode(node, canceller)
         if db is None:
             return
         ts = SQLiteParser.TableSignature('FM_Mail_Attach')
         for rec in db.ReadTableDeletedRecords(ts, False):
             if canceller.IsCancellationRequested:
                 break
             if IsDBNull(
                     rec['attachId'].Value) or rec['attachId'].Value == 0:
                 continue
             param = ()
             param = param + (rec['attachId'].Value, )
             param = param + (rec['accountId'].Value, )
             param = param + (rec['mailId'].Value, )
             param = param + (rec['name'].Value, )
             param = param + (rec['downloadSize'].Value, )
             param = param + (rec['downloadUtc'].Value, )
             self.db_insert_table(SQL_INSERT_TABLE_RECOVER_MAILATTACH,
                                  param)
         self.db_cmd.Dispose()
         self.db.Close()
     except Exception as e:
         print(e)
Exemple #22
0
 def prepare_message_dict(self):
     db_node = self.node.GetByPath('Library/Caches/YWDB')
     if db_node is None:
         return
     p_l = os.listdir(db_node.PathWithMountPoint)
     db_dirs = list()
     for p in p_l:
         res = re.search('WXOPENIMSDKDB(.*)', p, re.I | re.M)
         if res is not None:
             db_dirs.append(p)
     for d in db_dirs:
         message_node = self.node.GetByPath(
             'Library/Caches/YWDB/%s/message.db' % d)
         if message_node is not None:
             path = unity_c37r.check_sqlite_maturity(
                 message_node, self.cache)
             conn = unity_c37r.create_connection(path)
             cmd = sql.SQLiteCommand(conn)
             cmd.CommandText = '''
                 select ZUSER_ID from ZUSERINFO
             '''
             reader = cmd.ExecuteReader()
             if reader.Read():
                 tb_id = unity_c37r.c_sharp_get_blob(reader, 0).decode(
                     'utf-8')  #cntaobaotb5057305_11
                 tb_id = re.search('cntaobao(.*)', tb_id,
                                   re.I | re.M).group(1)
                 self.message_dict[
                     tb_id] = unity_c37r.check_sqlite_maturity(
                         message_node, self.cache)
             cmd.Dispose()
             conn.Close()
Exemple #23
0
 def _generate_calendar_info(self):
     try:
         self.db_cmd = SQLite.SQLiteCommand(self.db)
         if self.db_cmd is None:
             return
         self.db_cmd.CommandText = '''select distinct * from calendar'''
         sr = self.db_cmd.ExecuteReader()
         while (sr.Read()):
             if canceller.IsCancellationRequested:
                 break
             calendar = CalendarInfo()
             calendar.COLLECT_TARGET_ID = self.collect_target_id
             if not IsDBNull(sr[1]):
                 calendar.TITLE = sr[1]
             if not IsDBNull(sr[5]):
                 calendar.START_TIME = self._get_timestamp(int(sr[5]))
             if not IsDBNull(sr[7]):
                 calendar.END_TIME = self._get_timestamp(int(sr[7]))
             if not IsDBNull(sr[3]):
                 calendar.DESCRIPTION = sr[3]
             if not IsDBNull(sr[12]):
                 calendar.DELETE_STATUS = DELETE_STATUS_DELETED if sr[
                     12] == 1 else DELETE_STATUS_INTACT
             self.basic.db_insert_table_calendar_info(calendar)
         self.basic.db_commit()
         self.db_cmd.Dispose()
     except Exception as e:
         pass
Exemple #24
0
 def parse_search(self, ac):
     db_node = self.node.GetByPath('Library/edge_compute.db')
     if db_node is None:
         return
     path = unity_c37r.check_sqlite_maturity(db_node, self.cache)
     conn = unity_c37r.create_connection(path)
     cmd = sql.SQLiteCommand(conn)
     cmd.CommandText = '''
         select args,create_time from usertrack where owner_id = {} and page_name = 'Page_SearchItemList'
     '''.format(ac.uid)
     reader = cmd.ExecuteReader()
     while reader.Read():
         if canceller.IsCancellationRequested:
             cmd.Dispose()
             conn.Close()
             self.im.db_close()
             raise IOError('E')
         s = model_im.Search()
         s.account_id = ac.uid
         m_str = unity_c37r.c_sharp_get_string(reader, 0)
         try:
             #s.key = re.search('keyword=(.*?),', m_str, re.I | re.M).group(1)
             match = re.search('keyword=(.*?),', m_str, re.I | re.M)
             if match is None:
                 continue
             s.key = match.group(1)
         except:
             self.log.m_err('error string:{}'.format(m_str))
             continue
         s.create_time = unity_c37r.c_sharp_get_long(reader, 1) / 1000
         self.im.db_insert_table_search(s)
     self.im.db_commit()
     cmd.Dispose()
     conn.Close()
Exemple #25
0
 def generate_product_bcp(self):
     conn = unity_c37r.create_connection(self.cache_db)
     cmds = sql.SQLiteCommand(conn)
     cmds.CommandText = '''
         select * from tb_product
     '''
     reader = cmds.ExecuteReader()
     while reader.Read():
         pdt = ProductInfo()
         pdt.set_value_with_idx(pdt.app_code, self.app_code)
         pdt.set_value_with_idx(pdt.colltection_target_id, self.colltection_target_id)
         pdt.set_value_with_idx(pdt.account_id, unity_c37r.c_sharp_get_string(reader, 0))
         tp = unity_c37r.c_sharp_get_string(reader, 1)
         pdt.set_value_with_idx(pdt.source, '0%s' %tp)
         pdt.set_value_with_idx(pdt.product_id, unity_c37r.c_sharp_get_string(reader, 2))
         pdt.set_value_with_idx(pdt.product_name, unity_c37r.c_sharp_get_string(reader, 3))
         pdt.set_value_with_idx(pdt.price, unity_c37r.c_sharp_get_string(reader, 4))
         t = unity_c37r.c_sharp_get_long(reader, 5)
         if t is not 0:
             pdt.set_value_with_idx(pdt.create_time, t)
         pdt.set_value_with_idx(pdt.description, unity_c37r.c_sharp_get_string(reader, 6))
         pdt.set_value_with_idx(pdt.url, unity_c37r.c_sharp_get_string(reader, 7))
         pdt.set_value_with_idx(pdt.shop_id, unity_c37r.c_sharp_get_string(reader, 8))
         pdt.set_value_with_idx(pdt.delete_status, unity_c37r.c_sharp_get_long(reader, 9))
         unity_c37r.execute_query(self.cmd, TBL_BCP_INSERT_PRODUCT, pdt.get_values())
     reader.Close()
     cmds.Dispose()
     conn.Close()
 def get_models(self):
     models = list()
     conn = unity_c37r.create_connection(self.cache_db, True)
     cmd = sql.SQLiteCommand(conn)
     cmd.CommandText = '''
         select * from WA_MFORENSICS_120100
     '''
     reader = cmd.ExecuteReader()
     a = IMEAccount()
     while reader.Read():
         am = Common.User()
         am.ID.Value = unity_c37r.c_sharp_get_string(reader, a.account)
         am.Name.Value = unity_c37r.c_sharp_get_string(reader, a.nick)
         photo = unity_c37r.c_sharp_get_string(reader, a.photo)
         photo = unity_c37r.get_c_sharp_uri(photo)
         am.PhotoUris.Add(photo)
         # reserved gender
         sex = unity_c37r.c_sharp_get_string(reader, a.gender_code)
         models.append(am)
     reader.Close()
     cmd.CommandText = '''
         select * from WA_MFORENSICS_120200
     '''
     reader = cmd.ExecuteReader()
     b = IMEKeyword()
     while reader.Read():
         kw = InputMethod.WordFrequency()
         kw.KeyWord.Value = unity_c37r.c_sharp_get_string(
             reader, b.key_word)
         kw.Count.Value = unity_c37r.c_sharp_get_long(reader, b.times)
         models.append(kw)
     reader.Close()
     cmd.Dispose()
     conn.Close()
     return models
Exemple #27
0
 def before_check(bcp_path, bcp_db):
     r_bcp_db = os.path.join(bcp_path, bcp_db)
     if not os.path.exists(r_bcp_db):
         return True
     try:
         conn = unity_c37r.create_connection(r_bcp_db)
         cmd = sql.SQLiteCommand(conn)
         cmd.CommandText = '''
             select * from tb_version where vkey = '{}'
         '''.format(EB_VERSION_KEY)
         reader = cmd.ExecuteReader()
         if reader.Read():
             value = unity_c37r.c_sharp_get_long(reader, 0)
             reader.Close()
             cmd.Dispose()
             conn.Close()
             if value != EB_VERSION_VALUE:
                 return True
             else:
                 return False
         else:
             reader.Close()
             cmd.Dispose()
             conn.Close()
             return True
     except:
         traceback.print_exc()
         reader.Close()
         cmd.Dispose()
         conn.Close()
         return False
 def parse_sys_ver_1141(self):
     #if the sys ime does not contain zh.db
     if self.version & 0x1 == 0:
         return
     sql_node = self.node.GetByPath('DynamicPhraseLexicon_zh_Hans.db')
     db = unity_c37r.create_connection_tentatively(sql_node, True)
     cmd = sql.SQLiteCommand(db)
     cmd.CommandText = '''
         select Reading, Surface, Seed from Words
     '''
     reader = cmd.ExecuteReader()
     while reader.Read():
         pharse = unity_c37r.c_sharp_get_blob(reader, 0)
         pharse = pharse.decode('utf_16_le',
                                'ignore')  # => TODO:add pharse to sqlite
         bts = unity_c37r.c_sharp_get_blob(reader, 1)
         idx = 0
         words = ''
         while idx < len(bts):
             m_string = r'\u%02x%02x' % (bts[idx + 1], bts[idx]
                                         )  # => note little ending
             try:
                 m_string = m_string.decode('unicode_escape')
             except:
                 idx += 2
                 continue
             words += m_string
             idx += 2
         kw = IMEKeyword()
         kw.set_value_with_idx(kw.key_word, words)
         times = unity_c37r.c_sharp_get_long(reader, 2)
         kw.set_value_with_idx(kw.times, times)
         self.ime.db_insert_key(kw)
     self.ime.db_commit()
Exemple #29
0
 def _generate_attachment(self):
     try:
         self.db_cmd = SQLite.SQLiteCommand(self.db)
         if self.db_cmd is None:
             return
         self.db_cmd.CommandText = '''select distinct b.account_user, a.mail_id, a.attachment_name, a.attachment_save_dir,
                                      a.attachment_size, a.deleted from attachment as a left join account as b on a.owner_account_id = b.account_id'''
         sr = self.db_cmd.ExecuteReader()
         while (sr.Read()):
             if canceller.IsCancellationRequested:
                 break
             attachment = Attachment()
             attachment.COLLECT_TARGET_ID = self.collect_target_id
             attachment.MAIL_TOOL_TYPE = self.mail_tool_type
             attachment.ACCOUNT = sr[0]
             attachment.SEQUENCE_NAME = sr[1]
             attachment.MATERIALS_NAME = sr[2]
             attachment.FILE_NAME = sr[3]
             attachment.FILE_SIZE = sr[4]
             attachment.DELETE_STATUS = sr[5]
             if not IsDBNull(sr[3]):
                 self._copy_attachment(self.mountDir, sr[3])
                 print('拷贝成功')
             self.mail.db_insert_table_attachment(attachment)
         self.mail.db_commit()
     except Exception as e:
         print(e)
Exemple #30
0
 def analyze_account(self):
     '''保存账户数据到中间数据库'''
     self.db = SQLite.SQLiteConnection('Data Source = {}'.format(
         self.recoverDB))
     self.db.Open()
     self.db_cmd = SQLite.SQLiteCommand(self.db)
     try:
         if self.db is None:
             return
         self.db_cmd.CommandText = SQL_ASSOCIATE_TABLE_ACCOUNT
         sr = self.db_cmd.ExecuteReader()
         while (sr.Read()):
             try:
                 account = Account()
                 if canceller.IsCancellationRequested:
                     break
                 account.account_id = self._db_reader_get_int_value(sr, 0)
                 account.account_user = self._db_reader_get_string_value(
                     sr, 1)
                 account.account_alias = self._db_reader_get_string_value(
                     sr, 2)
                 account.account_email = self._db_reader_get_string_value(
                     sr, 1)
                 account.account_passwd = self._db_reader_get_string_value(
                     sr, 3)
                 account.source = self.node.AbsolutePath
                 account.deleted = self._db_reader_get_int_value(sr, 4)
                 self.mm.db_insert_table_account(account)
             except:
                 traceback.print_exc()
         self.mm.db_commit()
         self.db_cmd.Dispose()
         self.db.Close()
     except Exception as e:
         print(e)