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


Python biplist.InvalidPlistException方法代码示例

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


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

示例1: GetTopLevel

# 需要导入模块: import biplist [as 别名]
# 或者: from biplist import InvalidPlistException [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 InvalidPlistException [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 InvalidPlistException [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: _GetSystemInfo

# 需要导入模块: import biplist [as 别名]
# 或者: from biplist import InvalidPlistException [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', '')
                    self.os_friendly_name = plist.get('ProductName', '')
                    log.info ('iOS 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,代码行数:24,代码来源:macinfo.py

示例5: getRootElementNames

# 需要导入模块: import biplist [as 别名]
# 或者: from biplist import InvalidPlistException [as 别名]
def getRootElementNames(f):
    ''' The top element is usually called "root", but sometimes it is not!
        Hence we retrieve the correct name here. In some plists, there is
        more than one top element, this function will retrieve them all.
    '''
    roots = []
    try:
        plist = biplist.readPlist(f)
        top_element = plist.get('$top', None)
        if top_element:
            roots = [ x for x in top_element.keys() ]
        else:
            log.error('$top element not found! Not an NSKeyedArchive?')
    except biplist.InvalidPlistException:
        log.error('Had an exception (error) trying to read plist using biplist')
        traceback.print_exc()
    return roots 
开发者ID:ydkhatri,项目名称:mac_apt,代码行数:19,代码来源:deserializer.py

示例6: write_plist_to_file

# 需要导入模块: import biplist [as 别名]
# 或者: from biplist import InvalidPlistException [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

示例7: getRootElementNames

# 需要导入模块: import biplist [as 别名]
# 或者: from biplist import InvalidPlistException [as 别名]
def getRootElementNames(f):
    ''' The top element is usually called "root", but sometimes it is not!
        Hence we retrieve the correct name here. In some plists, there is
        more than one top element, this function will retrieve them all.
    '''
    roots = []
    try:
        plist = biplist.readPlist(f)
        top_element = plist.get('$top', None)
        if top_element:
            roots = [ x for x in top_element.keys() ]
        else:
            print('$top element not found! Not an NSKeyedArchive?')
    except biplist.InvalidPlistException:
        print('Had an exception (error) trying to read plist using biplist')
        traceback.print_exc()
    return roots 
开发者ID:abrignoni,项目名称:iLEAPP,代码行数:19,代码来源:deserializer.py

示例8: main

# 需要导入模块: import biplist [as 别名]
# 或者: from biplist import InvalidPlistException [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

示例9: ParseNotificationcenterRow

# 需要导入模块: import biplist [as 别名]
# 或者: from biplist import InvalidPlistException [as 别名]
def ParseNotificationcenterRow(
      self, parser_mediator, query, row, **unused_kwargs):
    """Parses a message row.

    Args:
      parser_mediator (ParserMediator): mediates interactions between parsers
          and other components, such as storage and dfvfs.
      query (str): query that created the row.
      row (sqlite3.Row): row.
    """
    query_hash = hash(query)

    event_data = MacNotificationCenterEventData()
    event_data.bundle_name = self._GetRowValue(query_hash, row, 'bundle_name')
    event_data.presented = self._GetRowValue(query_hash, row, 'presented')

    blob = self._GetRowValue(query_hash, row, 'dataBlob')

    try:
      full_biplist = biplist.readPlistFromString(blob)
      # req is the 'req' dictionary from the plist containing extra information
      # about the notification entry.
      req = full_biplist['req']

    except (biplist.InvalidPlistException, KeyError) as exception:
      parser_mediator.ProduceExtractionWarning(
          'unable to read plist from database with error: {0!s}'.format(
              exception))
      return

    event_data.title = req.get('titl', None)
    event_data.subtitle = req.get('subt', None)
    event_data.body = req.get('body', None)

    timestamp = self._GetRowValue(query_hash, row, 'timestamp')
    date_time = dfdatetime_cocoa_time.CocoaTime(timestamp=timestamp)
    event = time_events.DateTimeValuesEvent(
        date_time, definitions.TIME_DESCRIPTION_CREATION)
    parser_mediator.ProduceEventWithEventData(event, event_data) 
开发者ID:log2timeline,项目名称:plaso,代码行数:41,代码来源:mac_notificationcenter.py

示例10: _DictFromSubprocess

# 需要导入模块: import biplist [as 别名]
# 或者: from biplist import InvalidPlistException [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

示例11: ReadPlist

# 需要导入模块: import biplist [as 别名]
# 或者: from biplist import InvalidPlistException [as 别名]
def ReadPlist(path):
        '''
            Safely open and read a plist.
            Returns a tuple (True/False, plist/None, "error_message")
        '''
        #log.debug("Trying to open plist file : " + path)
        error = ''
        try:
            with open(path, 'rb') as f:
                if f != None:
                    try:
                        #log.debug("Trying to read plist file : " + path)
                        plist = biplist.readPlist(f)
                        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
                            f.seek(0)
                            data = f.read()
                            data = data.lstrip(" \r\n\t")
                            plist = biplist.readPlistFromString(data)
                            return (True, plist, '')
                        except biplist.InvalidPlistException 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 OSError as ex:
            error = 'Exception from ReadPlist while trying to open file. Exception=' + str(ex)
        return (False, None, error) 
开发者ID:ydkhatri,项目名称:mac_apt,代码行数:34,代码来源:common.py

示例12: _ReadPasswordPolicyData

# 需要导入模块: import biplist [as 别名]
# 或者: from biplist import InvalidPlistException [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

示例13: _ReadAccountPolicyData

# 需要导入模块: import biplist [as 别名]
# 或者: from biplist import InvalidPlistException [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

示例14: extract_nsa_plist

# 需要导入模块: import biplist [as 别名]
# 或者: from biplist import InvalidPlistException [as 别名]
def extract_nsa_plist(f):
    '''Return the embedded plist, if this is such a file.
       Sometimes there is a single data blob which then has 
       the NSKeyedArchiver plist in it.
    '''
    try:
        plist = biplist.readPlist(f)
        if isinstance(plist, bytes):
            data = plist
            f.close()
            f = io.BytesIO(data)
    except biplist.InvalidPlistException:
        log.exception('Had an exception (error) trying to read plist using biplist')
        return None
    f.seek(0)

    # Check if file to be returned is an XML plist
    header = f.read(8)
    f.seek(0)
    if header[0:6] != b'bplist': # must be xml
        # Convert xml to binary (else ccl_bplist wont load!)
        try:
            tempfile = io.BytesIO()
            plist = biplist.readPlist(f)
            ConvertCFUID_to_UID(plist)
            biplist.writePlist(plist, tempfile)
            f.close()
            tempfile.seek(0)
            return tempfile
        except biplist.InvalidPlistException:
            log.exception('Had exception (error) trying to read plist using biplist')
            return None
    return f 
开发者ID:ydkhatri,项目名称:mac_apt,代码行数:35,代码来源:deserializer.py

示例15: extract_nsa_plist

# 需要导入模块: import biplist [as 别名]
# 或者: from biplist import InvalidPlistException [as 别名]
def extract_nsa_plist(f):
    '''Return the embedded plist, if this is such a file.
       Sometimes there is a single data blob which then has 
       the NSKeyedArchiver plist in it.
    '''
    try:
        plist = biplist.readPlist(f)
        if isinstance(plist, bytes):
            data = plist
            f.close()
            f = io.BytesIO(data)
    except biplist.InvalidPlistException:
        print('Had an exception (error) trying to read plist using biplist')
        return None
    f.seek(0)

    # Check if file to be returned is an XML plist
    header = f.read(8)
    f.seek(0)
    if header[0:6] != b'bplist': # must be xml
        # Convert xml to binary (else ccl_bplist wont load!)
        try:
            tempfile = io.BytesIO()
            plist = biplist.readPlist(f)
            ConvertCFUID_to_UID(plist)
            biplist.writePlist(plist, tempfile)
            f.close()
            tempfile.seek(0)
            return tempfile
        except biplist.InvalidPlistException:
            print('Had exception (error) trying to read plist using biplist')
            return None
    return f 
开发者ID:abrignoni,项目名称:iLEAPP,代码行数:35,代码来源:deserializer.py


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