当前位置: 首页>>代码示例>>Python>>正文


Python biplist.NotBinaryPlistException方法代码示例

本文整理汇总了Python中biplist.NotBinaryPlistException方法的典型用法代码示例。如果您正苦于以下问题:Python biplist.NotBinaryPlistException方法的具体用法?Python biplist.NotBinaryPlistException怎么用?Python biplist.NotBinaryPlistException使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在biplist的用法示例。


在下文中一共展示了biplist.NotBinaryPlistException方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: GetTopLevel

# 需要导入模块: import biplist [as 别名]
# 或者: from biplist import NotBinaryPlistException [as 别名]
def GetTopLevel(self, file_object):
    """Returns the deserialized content of a plist as a dictionary object.

    Args:
      file_object (dfvfs.FileIO): a file-like object to parse.

    Returns:
      dict[str, object]: contents of the plist.

    Raises:
      UnableToParseFile: when the file cannot be parsed.
    """
    try:
      top_level_object = biplist.readPlist(file_object)

    except (biplist.InvalidPlistException,
            biplist.NotBinaryPlistException) as exception:
      raise errors.UnableToParseFile(
          'Unable to parse plist with error: {0!s}'.format(exception))

    return top_level_object 
开发者ID:log2timeline,项目名称:plaso,代码行数:23,代码来源:plist.py

示例2: Read

# 需要导入模块: import biplist [as 别名]
# 或者: from biplist import NotBinaryPlistException [as 别名]
def Read(self, file_object):
    """Reads a plist from a file-like object.

    Args:
      file_object (dfvfs.FileIO): a file-like object containing plist data.

    Raises:
      IOError: if the plist file-like object cannot be read.
      OSError: if the plist file-like object cannot be read.
    """
    try:
      self.root_key = biplist.readPlist(file_object)

    except (
        biplist.NotBinaryPlistException,
        biplist.InvalidPlistException) as exception:
      raise IOError(exception) 
开发者ID:log2timeline,项目名称:plaso,代码行数:19,代码来源:plist.py

示例3: view

# 需要导入模块: import biplist [as 别名]
# 或者: from biplist import NotBinaryPlistException [as 别名]
def view(self):
        current_app.logger.debug(request.data)

        try:
            plist_data = biplist.readPlistFromString(request.data)
        except biplist.NotBinaryPlistException:
            abort(400, 'The request body does not contain a plist as expected')
        except biplist.InvalidPlistException:
            abort(400, 'The request body does not contain a valid plist')

        for kvr in self.kv_routes:
            if kvr['key'] not in plist_data:
                continue

            if plist_data[kvr['key']] == kvr['value']:
                return kvr['handler'](plist_data)

        abort(404, 'No matching plist route') 
开发者ID:cmdmnt,项目名称:commandment,代码行数:20,代码来源:routers.py

示例4: write_plist_to_file

# 需要导入模块: import biplist [as 别名]
# 或者: from biplist import NotBinaryPlistException [as 别名]
def write_plist_to_file(deserialised_plist, output_path):
    #Using plistLib to write plist
    out_file = None
    try:
        print('Writing out .. ' + output_path)
        out_file = open(output_path, 'wb')
        try:
            plistlib.dump(deserialised_plist, out_file, fmt=plistlib.FMT_BINARY)
            out_file.close()
            return True
        except (TypeError, OverflowError, OSError) as ex:
            out_file.close()
            print('Had an exception (error)')
            traceback.print_exc()
    except OSError as ex:
        print('Error opening file for writing: Error={} Path={}'.format(output_path, str(ex)))
    # Try using biplist
    try:
        print('Writing out (using biplist) .. ' + output_path)
        biplist.writePlist(deserialised_plist, output_path)
        return True
    except (biplist.InvalidPlistException, biplist.NotBinaryPlistException, OSError) as ex:
        print('Had an exception (error)')
        traceback.print_exc() 
开发者ID:ydkhatri,项目名称:mac_apt,代码行数:26,代码来源:deserializer.py

示例5: main

# 需要导入模块: import biplist [as 别名]
# 或者: from biplist import NotBinaryPlistException [as 别名]
def main(plist):
    print("[+] Opening {} file".format(plist))
    try:
        plist_data = biplist.readPlist(plist)
    except (biplist.InvalidPlistException,
            biplist.NotBinaryPlistException) as e:
        print("[-] Invalid PLIST file - unable to be opened by biplist")
        sys.exit(2)

    print("[+] Printing Info.plist Device "
          "and User Information to Console\n")
    for k in plist_data:
        if k != 'Applications' and k != 'iTunes Files':
            print("{:<25s} - {}".format(k, plist_data[k])) 
开发者ID:PacktPublishing,项目名称:Python-Digital-Forensics-Cookbook,代码行数:16,代码来源:plist_parser.py

示例6: _DictFromSubprocess

# 需要导入模块: import biplist [as 别名]
# 或者: from biplist import NotBinaryPlistException [as 别名]
def _DictFromSubprocess(command):
  """Returns a dict based upon a subprocess call with a -plist argument.

  Args:
    command(list(str)): the command to be executed as a list.
  Returns:
    dict: dictionary from command output.
  Raises:
    MacDiskError: if the command failed to run.
  """

  try:
    task = subprocess.Popen(
        command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
  except OSError as e:
    raise MacDiskError('Could not execute: {0:s}'.format(e.strerror))
  (stdout, stderr) = task.communicate()

  if task.returncode != 0:
    raise MacDiskError(
        'Error running command: {0:s}, stderr: {1:s}' .format(
            ' '.join(command), stderr))

  try:
    return biplist.readPlistFromString(stdout)
  except (biplist.InvalidPlistException, biplist.NotBinaryPlistException):
    raise MacDiskError(
        'Error creating plist from output: {0:s}'.format(stdout)) 
开发者ID:google,项目名称:GiftStick,代码行数:30,代码来源:macdisk.py

示例7: _ReadPasswordPolicyData

# 需要导入模块: import biplist [as 别名]
# 或者: from biplist import NotBinaryPlistException [as 别名]
def _ReadPasswordPolicyData(self, password_policy_data, target_user):
        try:
            plist2 = biplist.readPlistFromString(password_policy_data[0])
            target_user.failed_login_count = plist2.get('failedLoginCount', 0)
            target_user.failed_login_timestamp = plist2.get('failedLoginTimestamp', None)
            target_user.last_login_timestamp = plist2.get('lastLoginTimestamp', None)
            target_user.password_last_set_time = plist2.get('passwordLastSetTime', None)
        except (biplist.InvalidPlistException, biplist.NotBinaryPlistException):
            log.exception('Error reading password_policy_data embedded plist') 
开发者ID:ydkhatri,项目名称:mac_apt,代码行数:11,代码来源:macinfo.py

示例8: _ReadAccountPolicyData

# 需要导入模块: import biplist [as 别名]
# 或者: from biplist import NotBinaryPlistException [as 别名]
def _ReadAccountPolicyData(self, account_policy_data, target_user):
        try:
            plist2 = biplist.readPlistFromString(account_policy_data[0])
            target_user.creation_time = CommonFunctions.ReadUnixTime(plist2.get('creationTime', None))
            target_user.failed_login_count = plist2.get('failedLoginCount', 0)
            target_user.failed_login_timestamp = CommonFunctions.ReadUnixTime(plist2.get('failedLoginTimestamp', None))
            target_user.password_last_set_time = CommonFunctions.ReadUnixTime(plist2.get('passwordLastSetTime', None))
        except (biplist.InvalidPlistException, biplist.NotBinaryPlistException):
            log.exception('Error reading password_policy_data embedded plist') 
开发者ID:ydkhatri,项目名称:mac_apt,代码行数:11,代码来源:macinfo.py

示例9: _GetSystemInfo

# 需要导入模块: import biplist [as 别名]
# 或者: from biplist import NotBinaryPlistException [as 别名]
def _GetSystemInfo(self):
        ''' Gets system version information'''
        try:
            log.debug("Trying to get system version from /System/Library/CoreServices/SystemVersion.plist")
            f = self.Open('/System/Library/CoreServices/SystemVersion.plist')
            if f != None:
                try:
                    plist = biplist.readPlist(f)
                    self.os_version = plist.get('ProductVersion', '')
                    self.os_build = plist.get('ProductBuildVersion', '')
                    if self.os_version != '':
                        if   self.os_version.startswith('10.10'): self.os_friendly_name = 'Yosemite'
                        elif self.os_version.startswith('10.11'): self.os_friendly_name = 'El Capitan'
                        elif self.os_version.startswith('10.12'): self.os_friendly_name = 'Sierra'
                        elif self.os_version.startswith('10.13'): self.os_friendly_name = 'High Sierra'
                        elif self.os_version.startswith('10.14'): self.os_friendly_name = 'Mojave'
                        elif self.os_version.startswith('10.15'): self.os_friendly_name = 'Catalina'
                        elif self.os_version.startswith('10.0'): self.os_friendly_name = 'Cheetah'
                        elif self.os_version.startswith('10.1'): self.os_friendly_name = 'Puma'
                        elif self.os_version.startswith('10.2'): self.os_friendly_name = 'Jaguar'
                        elif self.os_version.startswith('10.3'): self.os_friendly_name = 'Panther'
                        elif self.os_version.startswith('10.4'): self.os_friendly_name = 'Tiger'
                        elif self.os_version.startswith('10.5'): self.os_friendly_name = 'Leopard'
                        elif self.os_version.startswith('10.6'): self.os_friendly_name = 'Snow Leopard'
                        elif self.os_version.startswith('10.7'): self.os_friendly_name = 'Lion'
                        elif self.os_version.startswith('10.8'): self.os_friendly_name = 'Mountain Lion'
                        elif self.os_version.startswith('10.9'): self.os_friendly_name = 'Mavericks'
                        elif self.os_version.startswith('11.'): self.os_friendly_name = 'Big Sur'
                        else: self.os_friendly_name = 'Unknown version!'
                    log.info ('macOS version detected is: {} ({}) Build={}'.format(self.os_friendly_name, self.os_version, self.os_build))
                    f.close()
                    return True
                except (biplist.InvalidPlistException, biplist.NotBinaryPlistException) as ex:
                    log.error ("Could not get ProductVersion from plist. Is it a valid xml plist? Error=" + str(ex))
                f.close()
            else:
                log.error("Could not open plist to get system version info!")
        except:
            log.exception("Unknown error from _GetSystemInfo()")
        return False 
开发者ID:ydkhatri,项目名称:mac_apt,代码行数:42,代码来源:macinfo.py

示例10: ReadPlist

# 需要导入模块: import biplist [as 别名]
# 或者: from biplist import NotBinaryPlistException [as 别名]
def ReadPlist(self, path, deserialize=False):
        '''Safely open and read a plist; returns tuple (True/False, plist/None, "error_message")'''
        log.debug("Trying to open plist file : " + path)
        error = ''
        try:
            f = self.Open(path)
            if f != None:
                try:
                    log.debug("Trying to read plist file : " + path)
                    plist = biplist.readPlist(f)
                    if deserialize:
                        try:
                            f.seek(0)
                            plist = self.DeserializeNsKeyedPlist(f)
                            f.close()
                            return (True, plist, '')
                        except:
                            f.close()
                            error = 'Could not read deserialized plist: ' + path + " Error was : " + str(ex)  
                    else:
                        f.close()
                        return (True, plist, '')
                except biplist.InvalidPlistException as ex:
                    try:
                        # Perhaps this is manually edited or incorrectly formatted by a non-Apple utility  
                        # that has left whitespaces at the start of file before <?xml tag
                        # This is assuming XML format!
                        f.seek(0)
                        data = f.read().decode('utf8', 'ignore')
                        f.close()
                        data = data.lstrip(" \r\n\t").encode('utf8', 'backslashreplace')
                        if deserialize:
                            try:
                                temp_file = BytesIO(data)
                                plist = self.DeserializeNsKeyedPlist(temp_file)
                                temp_file.close()
                                return (True, plist, '')
                            except:
                                error = 'Could not read deserialized plist: ' + path + " Error was : " + str(ex)
                        else:
                            plist = biplist.readPlistFromString(data)                        
                            return (True, plist, '')
                    except (biplist.InvalidPlistException, biplist.NotBinaryPlistException) as ex:
                        error = 'Could not read plist: ' + path + " Error was : " + str(ex)
                except OSError as ex:
                    error = 'OSError while reading plist: ' + path + " Error was : " + str(ex)
            else:
                error = 'Failed to open file'
        except Exception as ex:
            error = 'Exception from ReadPlist, trying to open file. Exception=' + str(ex)
        return (False, None, error) 
开发者ID:ydkhatri,项目名称:mac_apt,代码行数:53,代码来源:macinfo.py

示例11: _GetUserInfo

# 需要导入模块: import biplist [as 别名]
# 或者: from biplist import NotBinaryPlistException [as 别名]
def _GetUserInfo(self):
        '''Populates user info from plists under: /private/var/db/dslocal/nodes/Default/users/'''
        #TODO - make a better plugin that gets all user & group info
        users_path  = '/private/var/db/dslocal/nodes/Default/users'
        user_plists = self.ListItemsInFolder(users_path, EntryType.FILES)
        for plist_meta in user_plists:
            if plist_meta['size'] > 0:
                try:
                    user_plist_path = users_path + '/' + plist_meta['name']
                    f = self.Open(user_plist_path)
                    if f!= None:
                        self.ExportFile(user_plist_path, 'USERS', '', False)
                        try:
                            plist = biplist.readPlist(f)
                            home_dir = self.GetArrayFirstElement(plist.get('home', ''))
                            if home_dir != '':
                                #log.info('{} :  {}'.format(plist_meta['name'], home_dir))
                                if home_dir.startswith('/var/'): home_dir = '/private' + home_dir # in mac /var is symbolic link to /private/var
                                target_user = UserInfo()
                                self.users.append(target_user)
                                target_user.UID = str(self.GetArrayFirstElement(plist.get('uid', '')))
                                target_user.GID = str(self.GetArrayFirstElement(plist.get('gid', '')))
                                target_user.UUID = self.GetArrayFirstElement(plist.get('generateduid', ''))
                                target_user.home_dir = home_dir
                                target_user.user_name = self.GetArrayFirstElement(plist.get('name', ''))
                                target_user.real_name = self.GetArrayFirstElement(plist.get('realname', ''))
                                target_user.pw_hint = self.GetArrayFirstElement(plist.get('hint', ''))
                                target_user._source = user_plist_path
                                os_version = self.GetVersionDictionary()
                                if os_version['major'] == 10 and os_version['minor'] <= 9: # Mavericks & earlier
                                    password_policy_data = plist.get('passwordpolicyoptions', None)
                                    if password_policy_data == None:
                                        log.debug('Could not find passwordpolicyoptions for user {}'.format(target_user.user_name))
                                    else:
                                        self._ReadPasswordPolicyData(password_policy_data, target_user)
                                else: # 10.10 - Yosemite & higher
                                    account_policy_data = plist.get('accountPolicyData', None)
                                    if account_policy_data == None: 
                                        pass #log.debug('Could not find accountPolicyData for user {}'.format(target_user.user_name))
                                    else:
                                        self._ReadAccountPolicyData(account_policy_data, target_user)
                            else:
                                log.error('Did not find \'home\' in ' + plist_meta['name'])
                        except (biplist.InvalidPlistException, biplist.NotBinaryPlistException):
                            log.exception("biplist failed to read plist " + user_plist_path)
                            self._CheckFileContents(f)
                        f.close()
                except (OSError, KeyError, ValueError, IndexError, TypeError):
                    log.exception ("Could not open/read plist " + user_plist_path)
        self._GetDomainUserInfo()
        self._GetDarwinFoldersInfo() # This probably does not apply to OSX < Mavericks ! 
开发者ID:ydkhatri,项目名称:mac_apt,代码行数:53,代码来源:macinfo.py


注:本文中的biplist.NotBinaryPlistException方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。