Example #1
0
 def get_account(self, node):
     db = SQLiteParser.Database.FromNode(node, canceller)
     if db is None:
         return
     if 'loginUserTable' not in db.Tables:
         return
     tbs = SQLiteParser.TableSignature("loginUserTable")
     for rec in db.ReadTableRecords(tbs, False):
         try:
             if canceller.IsCancellationRequested:
                 return
             account = model_im.Account()
             account.source = node.AbsolutePath
             if "uid" in rec and (not rec["uid"].IsDBNull):
                 account.account_id = rec["uid"].Value
             if "password" in rec and (not rec["password"].IsDBNull):
                 account.password = rec["password"].Value
             if "loginDataString" in rec and (
                     not rec["loginDataString"].IsDBNull):
                 data = json.loads(rec["loginDataString"].Value)
                 if "name" in data:
                     account.nickname = data["name"]
                 if "avatar" in data:
                     account.photo = data["avatar"]
                 if "birthday" in data:
                     account.birthday = data["birthday"]
                 if "age" in data:
                     account.age = data["age"]
             if account.account_id:
                 self.blued.db_insert_table_account(account)
         except Exception as e:
             pass
     self.blued.db_commit()
Example #2
0
    def _generate_account_table(self, account_file):
        """
        创建account table,dropbox 不支持多账户
        :param account_file: 保存账户信息的文件地址
        :return:
        """
        print(account_file)
        account_info = Utils.json_loads(Utils.open_file(account_file)).get(
            "contacts", [None])[0]
        if not account_info:
            return

        account = model_im.Account()
        account.account_id = self.__process_account_id(
            account_info.get("account_info", {}).get("id", None))
        account.username = account_info.get("name", {}).get("display", None)
        account.nickname = account.username
        account.email = account_info.get("email_addresses", [None])[0]
        account.telephone = account_info.get("phone_numbers", [None])[0]
        account.photo = account_info.get("account_info",
                                         {}).get("photo_url", None)
        account.source = account_file

        # 挂载正在使用的account
        self.using_account = account

        self.model_im_col.db_insert_table_account(account)
        self.model_im_col.db_commit()
Example #3
0
    def _generate_account_table(self):
        with self.checking_account_col as db_col:
            sql = """SELECT PROFILE_ID, 
                            IDENTITY_TYPE, 
                            DISPLAY_NAME, 
                            AVATAR_URL, 
                            NICK, 
                            GENDER, 
                            BIRTH_TIME, 
                            MODIFY_TIME, 
                            SIGNATURE, 
                            ACCOUNT_TYPE, 
                            BIZ_TYPE, 
                            EXT_INFO 
                    FROM profile 
                    WHERE BIZ_TYPE = -1;"""
            db_col.execute_sql(sql)
            while db_col.has_rest():
                a = model_im.Account()
                a.account_id = db_col.get_string(0)
                a.username = db_col.get_string(4)
                a.source = self.checking_account_col.db_path
                a.nickname = db_col.get_string(8)
                a.photo = db_col.get_string(3)
                # TODO add
                a.gender = None
                a.birthday = None

                self.using_account = a
                self.model_im_col.db_insert_table_account(a)
        self.model_im_col.db_commit()
Example #4
0
 def get_account(self, node):
     try:
         db = SQLiteParser.Database.FromNode(node, canceller)
         if db is None:
             return
         if 'im_friend' not in db.Tables:
             return
         tbs = SQLiteParser.TableSignature("im_friend")
         for rec in db.ReadTableRecords(tbs, False, True):
             if canceller.IsCancellationRequested:
                 return
             try:
                 account = model_im.Account()
                 if rec.Deleted == DeletedState.Deleted:
                     account.deleted = 1
                 account.source = node.AbsolutePath
                 if "im_user_id" in rec and (
                         not rec["im_user_id"].IsDBNull):
                     if "relation" in rec and rec["relation"].Value == 0:
                         account.account_id = rec["im_user_id"].Value
                         self.account_id = rec["im_user_id"].Value
                         if "name" in rec and (not rec["name"].IsDBNull):
                             account.nickname = rec["name"].Value
                         if "img" in rec and (not rec["img"].IsDBNull):
                             account.photo = rec["img"].Value
                         self.qunar_db.db_insert_table_account(account)
             except Exception as e:
                 TraceService.Trace(
                     TraceLevel.Info,
                     "qunar(ios) get_accounts record failed")
     except Exception as e:
         TraceService.Trace(TraceLevel.Error,
                            "qunar(ios) get_accounts failed")
     self.qunar_db.db_commit()
Example #5
0
    def _generate_account_table(self):

        account_file = self._search_file_simple("mqc_private.xml$")
        if account_file is None:
            return
        info = XElement.Parse(account_file.read())
        es = info.Elements("string")
        ns = info.Elements("boolean")
        self.master_account = account = model_im.Account()
        for rec in ns:
            if rec.Attribute("name") and rec.Attribute(
                    "name").Value.startswith("hasEnterTripList"):
                account.account_id = rec.Attribute("name").Value.replace(
                    'hasEnterTripList', '')
        for rec in es:
            if rec.Attribute("name") and rec.Attribute(
                    "name").Value == "login_phone":
                account.telephone = rec.FirstNode.Value
            elif rec.Attribute("name") and rec.Attribute(
                    "name").Value == "HEAD_PHOTO_URL":
                account.photo = rec.FirstNode.Value
            elif rec.Attribute("name") and rec.Attribute(
                    "name").Value == "lOGIN_USER_NAME":
                account.nickname = account.username = rec.FirstNode.Value
            elif rec.Attribute("name") and rec.Attribute(
                    "name").Value == "flight_number":
                search = rec.FirstNode.Value
                self._generate_search_table(search.split(","))

        account.insert_db(self.model_im_col)
        self.model_im_col.db_commit()
Example #6
0
    def _generate_history_account(self):
        db = self._search_file("Chat.sqlite$")
        if not db:
            return
        db_col = ModelCol(db)

        with db_col:
            db_col.execute_sql("SELECT name FROM sqlite_master")
            while db_col.has_rest():
                try:
                    name = db_col.get_string(0)
                    if not name.startswith('UME_ChatMsg'):
                        continue
                    account_id = name.replace('UME_ChatMsg', "")
                    if account_id == str(self.master_account.account_id):
                        continue

                    self.history_account_list.append(account_id)

                    account = model_im.Account()
                    account.account_id = account.username = account.nickname = account_id

                    account.insert_db(self.model_im_col)
                except Exception as e:
                    self.logger.error()
            self.model_im_col.db_commit()
Example #7
0
    def _generate_account_table(self, db):
        account_id = os.path.basename(db.PathWithMountPoint)

        user_info_1 = db.GetByPath('/userinfo1.json')
        user_info_2 = db.GetByPath('/userinfo2.json')

        photo = None
        name = None
        sign = None

        if user_info_1 is not None:
            user_info = self._open_json_file(user_info_1)
            photo = user_info['presp'].get('pdata', {}).get('headUrl', None)

        if user_info_2 is not None:
            user_info = self._open_json_file(user_info_2)
            name = user_info['presp'].get('pdata', {}).get('chnName', None)
            sign = user_info['presp'].get('pdata', {}).get('homePageEditDesc', None)

        account = model_im.Account()
        account.account_id = account.username = account.nickname = account.telephone = account_id
        account.username = name
        account.signature = sign
        account.photo = photo

        self.csm.db_insert_table_account(account)
        self.csm.db_commit()
        return account_id
Example #8
0
    def _get_account_table(self):
        file_name = os.path.basename(self.checking_col.db_path)
        account_sign = file_name.split(".")[0].split("-")[1]
        account_info = json.loads(self.__query_account_info(account_sign))

        account = model_im.Account()
        account.account_id = account_info["mri"].split(":", 1)[1]
        account.username = account_info.get("fullName", None)
        account.nickname = account_info.get("displayNameOverride", None)
        account.photo = account_info.get("thumbUrl", None)
        account.gender = self.__convert_gender(account_info.get("gender", 0))
        account.source = self.checking_col.db_path
        account.signature = account_info.get("mood", None)
        account.telephone = self.__choose_phone_number(
            account_info.get("phones", []))
        account.birthday = self._handle_birthday(
            account_info.get("birthday", None))
        account.country = account_info.get("country", None)
        account.city = account_info.get("city", None)

        # 挂载正在使用的account
        self.using_account = account

        self.model_im_col.db_insert_table_account(account)
        self.model_im_col.db_commit()
Example #9
0
    def _generate_account_table(self):
        with self.account_col as db_col:
            sql = """SELECT account_uid, 
                            account_name, 
                            account_phone, 
                            account_email, 
                            uk, 
                            name, 
                            nick_name, 
                            intro, 
                            avatar_url, 
                            display_name, 
                            remark
                    FROM info;"""
            db_col.execute_sql(sql)
            while db_col.has_rest():
                try:
                    account = model_im.Account()

                    account.account_id = db_col.get_string(0)
                    account.username = db_col.get_string(1)
                    account.nickname = db_col.get_string(6)
                    account.telephone = db_col.get_string(2)
                    account.email = db_col.get_string(3)
                    account.photo = db_col.get_string(8)
                    account.uk = db_col.get_int64(4)

                    self.using_account = account
                    self.model_im_col.db_insert_table_account(account)
                    yield account
                except Exception as e:
                    pass
            self.model_im_col.db_commit()
Example #10
0
 def get_account(self, node):
     db = SQLiteParser.Database.FromNode(node, canceller)
     if db is None:
         return
     if 'ZUSER' not in db.Tables:
         return
     tbs = SQLiteParser.TableSignature("ZUSER")
     for rec in db.ReadTableRecords(tbs, False):
         if canceller.IsCancellationRequested:
             return
         try:
             account = model_im.Account()
             if rec.Deleted == DeletedState.Deleted:
                 account.deleted = 1
             account.source = node.AbsolutePath
             if "ZUSERNIMACCID" in rec and (
                     not rec["ZUSERNIMACCID"].IsDBNull):
                 account.account_id = rec["ZUSERNIMACCID"].Value
             if "ZUSERNAME" in rec and (not rec["ZUSERNAME"].IsDBNull):
                 account.nickname = rec["ZUSERNAME"].Value
                 self.contact_list[account.account_id] = account.nickname
             if "ZUSERAVATAR" in rec and (not rec["ZUSERAVATAR"].IsDBNull):
                 account.photo = rec["ZUSERAVATAR"].Value
             if "ZUSERPHONE" in rec and (not rec["ZUSERPHONE"].IsDBNull):
                 account.telephone = rec["ZUSERPHONE"].Value
             if account.account_id:
                 self.bulletMessage.db_insert_table_account(account)
         except Exception as e:
             TraceService.Trace(TraceLevel.Info, e)
     self.bulletMessage.db_commit()
Example #11
0
    def get_user(self):
        if self.user is None:
            return

        account = model_im.Account()
        account.account_id = self.user
         
        dbPath = self.root.GetByPath('../../../Documents/' + self.user + '/StrangePersonInfo.Sqlite3')
        db = SQLiteParser.Database.FromNode(dbPath)
        if db is None:
            return

        account.source = dbPath.AbsolutePath
        if 'StrangePhonePersonInfo' in db.Tables:
            ts = SQLiteParser.TableSignature('tatnlinelistusers')
            SQLiteParser.Tools.AddSignatureToTable(ts, "[uid]", SQLiteParser.FieldType.Text, SQLiteParser.FieldConstraints.NotNull)
            for rec in db.ReadTableRecords(ts, False):
                if rec['[uid]'].Value != self.user:
                    continue

                obj = json.loads(rec['[info]'].Value)
                account.username = obj['name']
                self.username = account.username
                if rec['[type]'].Value == '2':
                    account.photo = obj['picture']
                    account.signature = obj['signature']
                account.gender = model_im.GENDER_MALE if obj['sex'] == '男' else model_im.GENDER_FEMALE
                try:
                    account.birthday = int(time.mktime(time.strptime(obj['birthday'], '%Y-%m-%d')))
                except:
                    pass
                break

        self.im.db_insert_table_account(account)
        self.im.db_commit()
Example #12
0
 def parse_account(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.user_id, a.account_name, b.name, b.gender, 
             b.birthday, b.signature, a.deleted from bb_account_info as a 
             left join bb_user_info as b on a.user_id = b.userid'''
         sr = db_cmd.ExecuteReader()
         try:
             if not sr.HasRows:
                 account = model_im.Account()
                 account.account_id = re.sub(
                     '\D', '', os.path.basename(self.node.AbsolutePath))
                 account.username = '******'
                 account.source = self.node.AbsolutePath
                 account.deleted = 0
                 self.account_id = account.account_id
                 self.account_name = account.username
                 self.db_insert_table_account(account)
             while (sr.Read()):
                 account = model_im.Account()
                 account.account_id = sr.GetInt64(
                     0) if not sr.IsDBNull(0) else ''
                 account.telephone = self._db_reader_get_string_value(sr, 1)
                 account.username = sr.GetString(
                     2) if not sr.IsDBNull(3) else '未知用户'
                 account.birthday = self._db_reader_get_int_value(sr, 4)
                 account.gender = 1 if self._db_reader_get_int_value(
                     sr, 3) == 0 else 0
                 account.signature = self._db_reader_get_string_value(sr, 5)
                 account.source = self.node.AbsolutePath
                 account.deleted = self._db_reader_get_int_value(sr, 6)
                 self.account_id = account.account_id
                 self.account_name = account.username
                 self.db_insert_table_account(account)
         except:
             traceback.print_exc()
         self.db_commit()
         db_cmd.Dispose()
         db.Close()
     except Exception as e:
         print(e)
Example #13
0
 def _add_master_account(self):
     plist = PlistHelper.ReadPlist(self.root)
     account = model_im.Account()
     account.source = self.root.AbsolutePath
     account.account_id = account.nickname = account.username = plist[
         'WXLogUtils_lastUsernick'].ToString()
     self.im.db_insert_table_account(account)
     self.im.db_commit()
Example #14
0
    def get_user(self):
        if self.user is None:
            return

        account = model_im.Account()
        account.account_id = self.user
        account.username = self.user
        self.csm.db_insert_table_account(account)
        self.csm.db_commit()
Example #15
0
 def _generate_account_table(self, db):
     if not db:
         return
     account = model_im.Account()
     account.account_id = os.path.basename(db.PathWithMountPoint).replace(".db", "").replace('cloudisk__', "")
     account.username = account.nickname = '360U' + str(account.account_id)
     account.insert_db(self.model_im_col)
     self.model_im_col.db_commit()
     return account
Example #16
0
 def parse_account(self):
     '''解析账户数据'''
     try:
         userNode = self.node.Parent.GetByPath('/default.realm')
         if userNode is None:
             return
         userDir = userNode.PathWithMountPoint
         f = open(userDir, 'rb')
         content = f.read()
         f.close()
         user = []
         for item in self.extract_json(content):
             try:
                 account = model_im.Account()
                 item = json.loads(item)
                 userid = item["userid"] if "userid" in item else ""
                 if userid in user:
                     continue
                 else:
                     user.append(userid)
                 picture = item["imageb"]
                 picture = re.sub('@.*', '', picture)
                 birthday = item["birthday"]
                 timeArray = time.strptime(birthday, '%Y-%m-%d')
                 timestamp = time.mktime(timeArray)
                 birthday = int(timestamp)
                 nickname = item["nickname"]
                 desc = item["desc"]
                 gender = item["gender"]
                 account.account_id = userid
                 account.nickname = nickname
                 account.username = nickname
                 account.photo = picture
                 account.gender = 1 if gender == 0 else 2 if gender == 1 else 0
                 account.signature = desc
                 account.birthday = birthday
                 account.deleted = 0 if len(user) == 1 else 1
                 self.db_insert_table_account(account)
                 friend = model_im.Friend()
                 friend.account_id = userid
                 friend.friend_id = userid
                 friend.nickname = nickname
                 friend.fullname = nickname
                 friend.photo = picture
                 friend.type = model_im.FRIEND_TYPE_FRIEND
                 friend.signature = desc
                 if userid is not None:
                     self.friend[userid] = nickname
                 if userid not in user:
                     self.db_insert_table_account(account)
             except:
                 traceback.print_exc()
         self.account_id = user[0]
         self.db_commit()
     except Exception as e:
         print(e)
Example #17
0
 def _get_account_table(self):
     with self.user_db_col as db_col:
         sql = """SELECT mypin
                 FROM my_config"""
         db_col.execute_sql(sql)
         while db_col.has_rest():
             account = model_im.Account()
             account.account_id = db_col.get_string(0)
             self.model_im_col.db_insert_table_account(account)
         self.model_im_col.db_commit()
Example #18
0
 def parse_account(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 * from cfurl_cache_receiver_data where receiver_data like '%nickname%'"""
         sr = db_cmd.ExecuteReader()
         try:
             account = model_im.Account()
             while (sr.Read()):
                 account = model_im.Account()
                 account.source = self.node.AbsolutePath
                 account_data = json.loads(
                     json.dumps(
                         self._db_reader_get_string_value(sr, 2).replace(
                             '\\', '').replace('\"', "'").replace('"', '')))
                 account_dic = json.loads(account_data.replace("'", '"'))
                 account.account_id = account_dic['nickname']
                 account.username = account_dic['nickname']
                 account.nickname = account_dic['nickname']
                 account.photo = account_dic['headimgurl']
                 account.gender = 1 if account_dic['sex'] == 1 else 0
                 account.country = account_dic['country']
                 account.province = account_dic['province']
                 account.deleted = 0
                 self.db_insert_table_account(account)
             if account.account_id is None:
                 account.account_id = '未知用户'
                 account.username = '******'
                 self.db_insert_table_account(account)
         except:
             traceback.print_exc()
         self.account_id = account.account_id
         self.account_name = account.username
         self.db_commit()
         db_cmd.Dispose()
         db.Close()
     except Exception as e:
         print(e)
Example #19
0
    def parse_Account(self, user_plist_node, group_plist_node):
        ''' 解析两个 .plist

            \Library\Preferences\jp.naver.line.plist
            keys:
                SimCardInfo              # base64
                mid                      # account_id   u423af962f1456db6cba8465cf82bb91b
                migrationDate           
                name                     # nickname     王明
                uid                      # username     chrisnaruto
                statusMessage            # signatue
                tel                      # telephone
            Library\Preferences\group.com.linecorp.line.plist
            keys:
                LineAccountType             
                LineProfilePicturePath   # photo        startwith('/')
                LineProfilePictureStatus # photo
                mid                      # account_id   u423af962f1456db6cba8465cf82bb91b
        '''
        user_plist_res = self._read_plist(user_plist_node, 'mid', 'name',
                                          'uid', 'statusMessage', 'tel')
        group_plist_res = self._read_plist(group_plist_node,
                                           'LineProfilePicturePath')
        account = model_im.Account()
        if user_plist_res:
            account.account_id = self.cur_account_id = user_plist_res['mid']
            account.nickname = user_plist_res.get('name')
            account.username = user_plist_res.get('uid')
            account.signature = user_plist_res.get('statusMessage')
            account.telephone = user_plist_res.get('tel')
            pic_url = group_plist_res.get('LineProfilePicturePath')
            if pic_url and pic_url.startswith('/'):
                account.photo = self._search_profile_img(pic_url)
            account.source = self.user_plist_node.AbsolutePath
        else:
            try:
                account_node = self.root.GetByPath(
                    'Library/Application Support/PrivateStore/')
                account_id = account_node.Children[0].AbsolutePath.split(
                    '_')[1]
                if account_id.startswith('u'):
                    account.account_id = account_id
                    account.nickname = DEFAULT_USERNAME
                    account.username = DEFAULT_USERNAME
            except:
                pass
        if not account.account_id:
            return account
        try:
            account.insert_db(self.csm)
        except:
            exc()
        self.csm.db_commit()
        return account
Example #20
0
    def _generate_account_table(self):
        """
        创建account table
        """
        msg_db_col = self.message_col
        account_id = os.path.basename(msg_db_col.db_path).split(".")[0]

        db_col = self.soul_app_col
        table = db_col.get_table(
            "user", {
                "_id": [FieldType.Int, FieldConstraints.NotNull],
                "user": [FieldType.Text, FieldConstraints.NotNull],
            })
        for rec in db_col.read_records(table):
            try:
                if str(rec['_id'].Value) == account_id:
                    account_info = TaoUtils.json_loads(rec['user'].Value)
                    if not account_info:
                        continue

                    account = model_im.Account()
                    account.account_id = rec['_id'].Value
                    account.source = db_col.db_path
                    account.signature = account.username = account.nickname = account_info.get(
                        "signature", None)
                    account.gender = model_im.GENDER_FEMALE if account_info.get("gender", None) == "FEMALE" \
                        else model_im.GENDER_MALE
                    account.birthday = TimeHelper.convert_timestamp(
                        account_info.get("birthday", None))
                    account.email = account_info.get('bindMail', None)
                    account.country = "China" if account_info.get(
                        'area', None) else None
                    account.deleted = 1 if rec.IsDeleted else 0
                else:
                    account = model_im.Account()
                    account.account_id = account.username = account.nickname = account_id
                    account.source = db_col.db_path
                self.model_im_col.db_insert_table_account(account)
            except Exception as e:
                self.logger.error()
        self.model_im_col.db_commit()
Example #21
0
    def _generate_account_table(self, node):

        account_id = os.path.basename(node.PathWithMountPoint)
        source = node.AbsolutePath

        account = model_im.Account()
        account.account_id = account.username = account.nickname = account.telephone = account_id
        account.source = source

        self.model_im_col.db_insert_table_account(account)
        self.model_im_col.db_commit()

        return account_id
Example #22
0
    def get_user(self):
        ''' main.db - yixin_contact
        
            FieldName	SQLType	
            uid         	Varchar	16
            yid         	Varchar	64
            ecpid          	Varchar	64
            mobile         	varchar	16
            email          	Varchar	64
            nickname        Varchar	64
            photourl        Varchar	256
            gender         	INTEGER
            birthday        Varchar	16
            address        	Varchar	128
            signature       Varchar	64
            bkimage        	Varchar	256
            fullspelling    Varchar	128
            shortspelling   Varchar	64
            sinaweibo       Varchar	64
            qqweibo        	archar	64
            renren         	Varchar	64
            config         	Varchar	512
            socials        	Varchar	512
        '''
        account = model_im.Account()
        account.account_id = self.user_id

        dbPath = self.root.GetByPath(self.user_id + '/main.db')
        db = SQLiteParser.Database.FromNode(dbPath)
        if db is None:
            self.csm.db_insert_table_account(account)
            self.csm.db_commit()
            return

        account.source = dbPath.AbsolutePath
        if 'yixin_contact' in db.Tables:
            ts = SQLiteParser.TableSignature('yixin_contact')
            SQLiteParser.Tools.AddSignatureToTable(
                ts, "uid", SQLiteParser.FieldType.Text,
                SQLiteParser.FieldConstraints.NotNull)
            for rec in db.ReadTableRecords(ts, self.extract_deleted):
                if account.account_id != rec['uid'].Value:
                    continue
                account.username = rec['nickname'].Value
                self.username = account.username
                account.gender = 2 if rec['gender'].Value == 0 else 1
                account.email = rec['email'].Value
                account.signature = rec['signature'].Value
                account.address = rec['address'].Value
        self.csm.db_insert_table_account(account)
        self.csm.db_commit()
Example #23
0
 def parse_account(self, node, dbPath, deleteFlag):
     '''解析账户数据(viber_messages)'''
     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 _id, display_name, number from participants_info where _id = 1'''
         sr = db_cmd.ExecuteReader()
         try:
             if not sr.HasRows:
                 account = model_im.Account()
                 account.account_id = '未知用户'
                 account.username = '******'
                 account.source = self.node.AbsolutePath
                 account.deleted = 0
                 self.account_id = account.account_id
                 self.account_name = account.username
                 self.db_insert_table_account(account)
             while(sr.Read()):
                 account = model_im.Account()
                 account.account_id = self._db_reader_get_int_value(sr, 0) if not IsDBNull(sr[0]) else '未知用户'
                 account.telephone = self._db_reader_get_string_value(sr, 2)
                 account.username = self._db_reader_get_string_value(sr, 1) if not IsDBNull(sr[1]) else '未知用户'
                 account.source = node.AbsolutePath
                 account.deleted = deleteFlag
                 self.account_id = account.account_id
                 self.account_name = account.username
                 self.db_insert_table_account(account)
         except:
             traceback.print_exc()
         self.local_number = account.telephone
         self.db_commit()
         db_cmd.Dispose()
         db.Close()
     except Exception as e:
         print(e)
Example #24
0
    def get_user_list(self):
        user_list = {}
        dir = '../../Caches/YWDB/'
        dirNode = self.root.GetByPath(dir)
        if dirNode is None:
            dir = '../../../Documents/YWDB/'
            dirNode = self.root.GetByPath(dir)
            if dirNode is None:
                return user_list

        for file in os.listdir(dirNode.PathWithMountPoint):
            node = self.root.GetByPath(dir + file + '/message.db')
            if node is not None:
                db = SQLiteParser.Database.FromNode(node)
                if db is None:
                    return user_list
                if 'ZUSERINFO' in db.Tables:
                    ts = SQLiteParser.TableSignature('ZUSERINFO')
                    SQLiteParser.Tools.AddSignatureToTable(
                        ts, 'ZUSER_ID', SQLiteParser.FieldType.Text,
                        SQLiteParser.FieldConstraints.NotNull)
                    for rec in db.ReadTableRecords(ts, self.extract_deleted):
                        account = model_im.Account()
                        account.deleted = 0 if rec.Deleted == DeletedState.Intact else 1
                        account.source = node.AbsolutePath
                        account.account_id = UnicodeEncoding.UTF8.GetString(
                            rec['ZUSER_ID'].Value) if not IsDBNull(
                                rec['ZUSER_ID'].Value) else None
                        account.nickname = UnicodeEncoding.UTF8.GetString(
                            rec['ZTBNICK'].Value) if not IsDBNull(
                                rec['ZTBNICK'].Value) else None
                        account.username = UnicodeEncoding.UTF8.GetString(
                            rec['ZNAME'].Value) if not IsDBNull(
                                rec['ZNAME'].Value) else None
                        if account.username is None:
                            account.username = account.nickname
                        self.username = account.username
                        account.photo = rec['ZAVATAR'].Value
                        if rec['ZGENDER'].Value == '男':
                            account.gender = model_im.GENDER_MALE
                        elif rec['ZGENDER'].Value == '女':
                            account.gender = model_im.GENDER_FEMALE
                        else:
                            account.gender = model_im.GENDER_NONE
                        account.province = rec['ZPROVINCE'].Value
                        account.city = rec['ZCITY'].Value
                        self.im.db_insert_table_account(account)
                        user_list[account.account_id] = node
            self.im.db_commit()
        return user_list
Example #25
0
 def add_master_account_to_db(self):
     node = self.node.GetByPath(
         'Documents/TBSUserInfo/TBSettingsUserInfo.json')
     if node is None:
         return
     p = PlistHelper.ReadPlist(node)
     if p is not None:
         try:
             a = model_im.Account()
             a.account_id = p['userId'].ToString()
             a.nickname = a.username = p['userNick'].ToString()
             # a.photo = 'https://' + p['userLogo'].ToString()
             self.im.db_insert_table_account(a)
             self.im.db_commit()
         except:
             traceback.print_exc()
             return
Example #26
0
    def _get_account(self):
        account_info = self.__find_account()
        if not account_info:
            return
        account = model_im.Account()
        account.account_id = account_info.id
        first_name = account_info.first_name if account_info.first_name else ""
        last_name = account_info.last_name if account_info.last_name else ""
        account.username = account.nickname = first_name + " " + last_name
        account.telephone = account_info.phone
        account.deleted = 0 if account_info.deleted is False else 1
        account.source = self.root.GetByPath(
            self.account_db_path).PathWithMountPoint

        self.account = account.account_id
        self.model_col.db_insert_table_account(account)
        self.model_col.db_commit()
        return account.account_id
Example #27
0
    def get_user(self):
        if self.user is None:
            return

        account = model_im.Account()
        account.account_id = self.user

        dbPath = self.root.GetByPath('/databases/' + 'youxin_db_' + self.user)
        db = SQLiteParser.Database.FromNode(dbPath)
        if db is None:
            self.im.db_insert_table_account(account)
            self.im.db_commit()
            return

        account.source = dbPath.AbsolutePath
        if 'MY_NAME_CARD' in db.Tables:
            ts = SQLiteParser.TableSignature('MY_NAME_CARD')
            SQLiteParser.Tools.AddSignatureToTable(
                ts, 'UID', SQLiteParser.FieldType.Text,
                SQLiteParser.FieldConstraints.NotNull)
            for rec in db.ReadTableRecords(ts, self.extract_deleted):
                account.username = self._db_record_get_string_value(
                    rec, 'NAME')
                self.username = account.username
                gender = self._db_record_get_string_value(rec, 'GENDER')
                account.gender = 2 if gender == '女' else 1 if gender == '男' else 0
                account.telephone = self._db_record_get_string_value(
                    rec, 'MOBILE_NUMBER')
                account.email = self._db_record_get_string_value(rec, 'EMAIL')
                birthday = self._db_record_get_string_value(rec, 'BIRTHDAY')
                try:
                    ts = time.strptime(birthday, '%Y-%m-%d')
                    birthday = int(time.mktime(ts))
                    account.birthday = birthday
                except:
                    pass
                photo = self._db_record_get_string_value(rec, 'PHOTO_LOCATION')
                if photo is not '':
                    photo_nodes = self.app_root.Search(
                        os.path.basename(photo) + '$')
                    if len(list(photo_nodes)) != 0:
                        account.photo = photo_nodes[0].AbsolutePath
        self.im.db_insert_table_account(account)
        self.im.db_commit()
Example #28
0
 def decode_recover_account(self):
     node = self.root.GetByPath("databases/__icssdk_database.db")
     if node is None:
         return
     db = SQLiteParser.Database.FromNode(node, canceller)
     if db is None:
         return
     table = 'my_config'
     ts = SQLiteParser.TableSignature(table)
     for rec in db.ReadTableDeletedRecords(ts, False):
         if canceller.IsCancellationRequested:
             return
         try:
             account = model_im.Account()
             account.account_id = rec["mypin"].Value
             self.model_im_col.db_insert_table_account(account)
         except Exception as e:
             print("error happen", e)
     self.model_im_col.db_commit()
Example #29
0
    def get_account(self):
        account = model_im.Account()
        # account.source = "WhatsApp"
        account_node = self.root.GetByPath(
            "/shared_prefs/com.whatsapp_preferences.xml")
        account.source = account_node.AbsolutePath
        if account_node is None:
            return
        es = []
        try:
            account_node.Data.seek(0)
            xml = XElement.Parse(account_node.read())
            es = xml.Elements("string")
        except Exception as e:
            print e
        for rec in es:
            if canceller.IsCancellationRequested:
                return
            if rec.Attribute('name') and rec.Attribute(
                    'name').Value == 'push_name':
                name = rec.FirstNode.Value
                account.nickname = name.decode('utf-8')
                self.account_pushname = name.decode('utf-8')
            if rec.Attribute('name') and rec.Attribute(
                    'name').Value == 'registration_jid':
                account.account_id = rec.FirstNode.Value + "@s.whatsapp.net"
                self.account_id = account.account_id
                account.telephone = rec.FirstNode.Value
            if rec.Attribute('name') and rec.Attribute(
                    'name').Value == 'my_current_status':
                account.signature = rec.FirstNode.Value
        try:
            if self.account_id is None:
                self.account_id = "unknown"
                # account.account_id = self.account_id
                account.account_id = "whatsapp:" + self.account_id
            if self.account_pushname is None:
                self.account_pushname = "unknown"
            self.whatsapp.db_insert_table_account(account)
        except Exception as e:
            pass

        self.whatsapp.db_commit()
Example #30
0
    def _generate_account_table(self):

        account_file = self._search_account_file()
        if account_file is None:
            return
        file_data = PlistHelper.ReadPlist(account_file)

        account = model_im.Account()
        account.account_id = file_data.Get('uid')
        account.username = file_data.Get('userName')
        account.country = file_data.Get('country')
        account.gender = file_data.Get('gender')
        account.photo = file_data.Get('headUrl')
        account.signature = file_data.Get('homePageEditDesc')
        account.telephone = file_data.Get('mobile')
        account.nickname = file_data.Get('nickName')

        self.master_account = account
        self.history_account_list.append(account.account_id)
        account.insert_db(self.model_im_col)
        self.model_im_col.db_commit()