Exemple #1
0
    def traverse_dir(self, p_dir_entry, p_cur_path, p_list):
        l_loc = p_dir_entry["extent_loc"].value * SECTOR_SIZE
        l_len = p_dir_entry["size"].value

        l_read = 0

        if self.DEBUG is True:
            print(80 * "*")
            for l_index, l_field in enumerate(p_list):
                print("[%d] 0x%0.8x" %
                      (l_index, l_field.absolute_address // 8))
            print(80 * "*")

        while l_read < l_len:
            l_entry = self.find_entry(l_loc, p_list)
            if l_entry is not None:

                if self.DEBUG:
                    for l_field in l_entry:
                        print("%#x:%s=%s" % (l_field.absolute_address // 8,
                                             l_field.name, l_field.display))

                l_new_len = l_entry["rec_length"].value
                l_read += l_new_len
                if l_entry["name_length"].value > 1:
                    l_filename = self.get_filename(l_entry)
                    if l_entry["file_flags"].value & 2:
                        if self.DEBUG:
                            print("entering directory %s" % l_filename)
                        self.traverse_dir(
                            l_entry, "%s%s%s" % (p_cur_path, l_filename, sep),
                            p_list)
                        if self.DEBUG:
                            print("leaving directory %s" % l_filename)
                    else:
                        (acc_time, crea_time,
                         mod_time) = self.get_dates(l_entry)
                        meta = Metadata(self)
                        meta.filename = "%s%s" % (p_cur_path, l_filename)
                        meta.last_modification = mod_time
                        meta.creation_date = crea_time
                        meta.file_size = l_entry["size"].value
                        self.addGroup("file[]", meta,
                                      "File \"%s\"" % meta.get('filename'))
                        if self.DEBUG:
                            print("adding file[] %s" % meta.get('filename'))
                l_loc = l_loc + l_new_len
            else:
                l_node_sec, l_node_rest = divmod(l_loc, SECTOR_SIZE)
                if self.DEBUG:
                    print(
                        "no entry found at %#x, skipping %d bytes to sector boundary"
                        % (l_loc, SECTOR_SIZE - l_node_rest))
                l_loc = (l_node_sec + 1) * SECTOR_SIZE
                l_read += (SECTOR_SIZE - l_node_rest)
Exemple #2
0
 def useFile(self, field):
     meta = Metadata(self)
     meta.filename = field["filename"].value
     meta.file_size = field["filesize"].value
     meta.creation_date = field["timestamp"].value
     attr = field["attributes"].value
     if attr != "(none)":
         meta.file_attr = attr
     if meta.has("filename"):
         title = "File \"%s\"" % meta.getText('filename')
     else:
         title = "File"
     self.addGroup(field.name, meta, title)
Exemple #3
0
 def useFile(self, field):
     meta = Metadata(self)
     meta.filename = field["filename"].value
     meta.file_size = field["filesize"].value
     meta.creation_date = field["timestamp"].value
     attr = field["attributes"].value
     if attr != "(none)":
         meta.file_attr = attr
     if meta.has("filename"):
         title = _("File \"%s\"") % meta.getText('filename')
     else:
         title = _("File")
     self.addGroup(field.name, meta, title)
Exemple #4
0
 def processFile(self, field):
     meta = Metadata(self)
     meta.filename = field["filename"].value
     meta.creation_date = field["last_mod"].value
     meta.compression = field["compression"].display
     if "data_desc" in field:
         meta.file_size = field["data_desc/file_uncompressed_size"].value
         if field["data_desc/file_compressed_size"].value:
             meta.compr_size = field["data_desc/file_compressed_size"].value
     else:
         meta.file_size = field["uncompressed_size"].value
         if field["compressed_size"].value:
             meta.compr_size = field["compressed_size"].value
     computeCompressionRate(meta)
     self.addGroup(field.name, meta, "File \"%s\"" % meta.get('filename'))
Exemple #5
0
 def processFile(self, field):
     meta = Metadata(self)
     meta.filename = field["filename"].value
     meta.creation_date = field["last_mod"].value
     meta.compression = field["compression"].display
     if "data_desc" in field:
         meta.file_size = field["data_desc/file_uncompressed_size"].value
         if field["data_desc/file_compressed_size"].value:
             meta.compr_size = field["data_desc/file_compressed_size"].value
     else:
         meta.file_size = field["uncompressed_size"].value
         if field["compressed_size"].value:
             meta.compr_size = field["compressed_size"].value
     computeCompressionRate(meta)
     self.addGroup(field.name, meta, "File \"%s\"" % meta.get('filename'))