Ejemplo n.º 1
0
def parse_pfs(data):
    pfs = PFSFile(data)
    if not pfs.check_header():
        print "Error: Cannot parse file (%s) as a Dell PFS." % args.file
        return None

    pfs.process()
    return pfs
def parse_pfs(data):
    pfs = PFSFile(data)
    if not pfs.check_header():
        print "Error: Cannot parse file (%s) as a Dell PFS." % args.file
        return None
    
    pfs.process()
    return pfs
Ejemplo n.º 3
0
def load_pfs(firmware_id, data):
    pfs = PFSFile(data)
    if not pfs.check_header():
        print "This is not a valid DELL PFS update."
        sys.exit(1)

    pfs.process()

    ### Store PFS info
    if not args.force and not objects_table.get_all(firmware_id, index="object_id").is_empty().run():
        print "PFS object (%s) exists." % firmware_id
        return

    child_ids = []
    for section in pfs.objects:
        section_info = section.info(include_content= True)

        if not objects_table.get_all(firmware_id, index="firmware_id").filter({"guid": section_info["guid"]}).is_empty().run():
            print "Skipping PFS (%s) GUID %s, object exists." % (firmware_id, section_info["guid"])
            if args.test: continue
            primary = objects_table.get_all(firmware_id, index="firmware_id").filter({"guid": section_info["guid"]}).\
                limit(1).pluck("id").coerce_to('array').run()[0]["id"]
            child_ids.append(primary)
            continue

        section_id = get_firmware_id(section_info["content"])
        section_info["object_id"] = section_id

        #for chunk in section_info["chunks"]:
        #    store_content(firmware_id, section_id, chunk, content_type= "pfs_chunk")

        object_keys = []
        if section_info["guid"] == PFS_GUIDS["FIRMWARE_VOLUMES"]:
            ### Brute search for volumes here
            volumes = search_firmware_volumes(section_info["content"])
            print volumes
            for i, index in enumerate(volumes):
                volume_keys = load_uefi_volume(firmware_id, section_info["content"][index-40:], 
                    guid= section_info["guid"], order= i, generate_object_id= True)
                if volume_keys is not None:
                    object_keys += volume_keys
        else:
            object_keys = store_object(firmware_id, section_info, object_type= "pfs_section")
            
        if object_keys is not None:
            child_ids += object_keys

        print "Stored PFS section (%s) GUID %s." % (firmware_id, section_info["guid"])

    if args.test: return
    objects_table.insert({
        "firmware_id": firmware_id,
        "object_id": firmware_id,
        "children": child_ids,
        "type": "dell_pfs",
        "size": len(data)
    }).run()
    pass
Ejemplo n.º 4
0
def parse_pfs(data):
    print "Parsing Dell PFS.HDR update"
    pfs = PFSFile(data)
    if not pfs.check_header():
        return
    _process_show_extract(pfs)
Ejemplo n.º 5
0
def parse_pfs(data):
    print "Parsing Dell PFS.HDR update"
    pfs = PFSFile(data)
    if not pfs.check_header():
        return
    _process_show_extract(pfs)
Ejemplo n.º 6
0
def load_pfs(firmware_id, data):
    pfs = PFSFile(data)
    if not pfs.check_header():
        print "This is not a valid DELL PFS update."
        sys.exit(1)

    pfs.process()

    ### Store PFS info
    if not args.force and not objects_table.get_all(
            firmware_id, index="object_id").is_empty().run():
        print "PFS object (%s) exists." % firmware_id
        return

    child_ids = []
    for section in pfs.objects:
        section_info = section.info(include_content=True)

        if not objects_table.get_all(firmware_id, index="firmware_id").filter({
                "guid":
                section_info["guid"]
        }).is_empty().run():
            print "Skipping PFS (%s) GUID %s, object exists." % (
                firmware_id, section_info["guid"])
            if args.test: continue
            primary = objects_table.get_all(firmware_id, index="firmware_id").filter({"guid": section_info["guid"]}).\
                limit(1).pluck("id").coerce_to('array').run()[0]["id"]
            child_ids.append(primary)
            continue

        section_id = get_firmware_id(section_info["content"])
        section_info["object_id"] = section_id

        #for chunk in section_info["chunks"]:
        #    store_content(firmware_id, section_id, chunk, content_type= "pfs_chunk")

        object_keys = []
        if section_info["guid"] == PFS_GUIDS["FIRMWARE_VOLUMES"]:
            ### Brute search for volumes here
            volumes = search_firmware_volumes(section_info["content"])
            print volumes
            for i, index in enumerate(volumes):
                volume_keys = load_uefi_volume(firmware_id,
                                               section_info["content"][index -
                                                                       40:],
                                               guid=section_info["guid"],
                                               order=i,
                                               generate_object_id=True)
                if volume_keys is not None:
                    object_keys += volume_keys
        else:
            object_keys = store_object(firmware_id,
                                       section_info,
                                       object_type="pfs_section")

        if object_keys is not None:
            child_ids += object_keys

        print "Stored PFS section (%s) GUID %s." % (firmware_id,
                                                    section_info["guid"])

    if args.test: return
    objects_table.insert({
        "firmware_id": firmware_id,
        "object_id": firmware_id,
        "children": child_ids,
        "type": "dell_pfs",
        "size": len(data)
    }).run()
    pass