예제 #1
0
    def copy_physical_address_space(self, renderer, resolver, volume):
        """Copies the physical address space to the output volume.

        The result is a map object.
        """
        image_urn = volume.urn.Append("PhysicalMemory")
        source = self.session.physical_address_space

        # Mark the stream as a physical memory stream.
        resolver.Set(image_urn, lexicon.AFF4_CATEGORY,
                     rdfvalue.URN(lexicon.AFF4_MEMORY_PHYSICAL))

        if self.compression:
            storage_urn = image_urn.Append("data")
            resolver.Set(storage_urn, lexicon.AFF4_IMAGE_COMPRESSION,
                         rdfvalue.URN(self.compression))

        with volume.CreateMember(
                image_urn.Append("information.yaml")) as metadata_fd:
            metadata_fd.Write(
                yaml_utils.encode(self.create_metadata(source)))

        renderer.format("Imaging Physical Memory:\n")
        with aff4_map.AFF4Map.NewAFF4Map(
                resolver, image_urn, volume.urn) as image_stream:
            total_length = self._WriteToTarget(resolver, source, image_stream)

        renderer.format("Wrote {0} mb of Physical Memory to {1}\n",
                        total_length/1024/1024, image_stream.urn)
예제 #2
0
    def copy_physical_address_space(self, renderer, resolver, volume):
        """Copies the physical address space to the output volume.

        The result is a map object.
        """
        image_urn = volume.urn.Append("PhysicalMemory")
        source = self.session.physical_address_space

        # Mark the stream as a physical memory stream.
        resolver.Set(image_urn, lexicon.AFF4_CATEGORY,
                     rdfvalue.URN(lexicon.AFF4_MEMORY_PHYSICAL))

        if self.compression:
            storage_urn = image_urn.Append("data")
            resolver.Set(storage_urn, lexicon.AFF4_IMAGE_COMPRESSION,
                         rdfvalue.URN(self.compression))

        with volume.CreateMember(
                image_urn.Append("information.yaml")) as metadata_fd:
            metadata_fd.Write(yaml_utils.encode(self.create_metadata(source)))

        renderer.format("Imaging Physical Memory:\n")
        with aff4_map.AFF4Map.NewAFF4Map(resolver, image_urn,
                                         volume.urn) as image_stream:
            total_length = self._WriteToTarget(resolver, source, image_stream)

        renderer.format("Wrote {0} mb of Physical Memory to {1}\n",
                        total_length / 1024 / 1024, image_stream.urn)
예제 #3
0
    def copy_physical_address_space(self, renderer, resolver, volume):
        """Copies the physical address space to the output volume."""
        image_urn = volume.urn.Append("PhysicalMemory")
        source = self.session.physical_address_space

        # Mark the stream as a physical memory stream.
        resolver.Set(image_urn, lexicon.AFF4_CATEGORY,
                     rdfvalue.URN(lexicon.AFF4_MEMORY_PHYSICAL))

        if self.compression:
            storage_urn = image_urn.Append("data")
            resolver.Set(storage_urn, lexicon.AFF4_IMAGE_COMPRESSION,
                         rdfvalue.URN(self.compression))

        with volume.CreateMember(
                image_urn.Append("information.yaml")) as metadata_fd:

            metadata_fd.Write(
                yaml_utils.encode(self.create_metadata(source)))

        renderer.format("Imaging Physical Memory:\n")

        with aff4_map.AFF4Map.NewAFF4Map(
            resolver, image_urn, volume.urn) as image_stream:

            total = 0
            last_tick = time.time()

            for run in source.get_address_ranges():
                length = run.length
                offset = run.start

                image_stream.seek(offset)

                while length > 0:
                    to_read = min(length, self.BUFFERSIZE)
                    data = source.read(offset, to_read)

                    image_stream.write(data)
                    now = time.time()

                    read_len = len(data)
                    if now > last_tick:
                        rate = read_len / (now - last_tick) / 1e6
                    else:
                        rate = 0

                    self.session.report_progress(
                        "%s: Wrote %#x (%d mb total) (%02.2d Mb/s)",
                        source, offset, total / 1e6, rate)

                    length -= read_len
                    offset += read_len
                    total += read_len
                    last_tick = now

        resolver.Close(image_stream)
        renderer.format("Wrote {0} mb of Physical Memory to {1}\n",
                        total/1024/1024, image_stream.urn)
예제 #4
0
    def copy_physical_address_space(self, renderer, resolver, volume):
        """Copies the physical address space to the output volume."""
        image_urn = volume.urn.Append("PhysicalMemory")
        source = self.session.physical_address_space

        # Mark the stream as a physical memory stream.
        resolver.Set(image_urn, lexicon.AFF4_CATEGORY,
                     rdfvalue.URN(lexicon.AFF4_MEMORY_PHYSICAL))

        if self.compression:
            storage_urn = image_urn.Append("data")
            resolver.Set(storage_urn, lexicon.AFF4_IMAGE_COMPRESSION,
                         rdfvalue.URN(self.compression))

        with volume.CreateMember(
                image_urn.Append("information.yaml")) as metadata_fd:

            metadata_fd.Write(yaml_utils.encode(self.create_metadata(source)))

        renderer.format("Imaging Physical Memory:\n")

        with aff4_map.AFF4Map.NewAFF4Map(resolver, image_urn,
                                         volume.urn) as image_stream:

            total = 0
            last_tick = time.time()

            for run in source.get_address_ranges():
                length = run.length
                offset = run.start

                image_stream.seek(offset)

                while length > 0:
                    to_read = min(length, self.BUFFERSIZE)
                    data = source.read(offset, to_read)

                    image_stream.write(data)
                    now = time.time()

                    read_len = len(data)
                    if now > last_tick:
                        rate = read_len / (now - last_tick) / 1e6
                    else:
                        rate = 0

                    self.session.report_progress(
                        "%s: Wrote %#x (%d mb total) (%02.2d Mb/s)", source,
                        offset, total / 1e6, rate)

                    length -= read_len
                    offset += read_len
                    total += read_len
                    last_tick = now

        resolver.Close(image_stream)
        renderer.format("Wrote {0} mb of Physical Memory to {1}\n",
                        total / 1024 / 1024, image_stream.urn)
예제 #5
0
 def Encoder(self, data):
     return yaml_utils.encode(data)