當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。