Beispiel #1
0
 def DeleteFile(self, responses):
     """Checks for errors from DeleteGRRTempFiles called from 'Done' state."""
     if not responses.success:
         raise flow.FlowError(
             "Removing local file %s failed: %s" %
             (self.state.memory_src_path, responses.status))
Beispiel #2
0
 def End(self, responses):
     if not responses.success:
         raise flow.FlowError("Delete of %s failed %s" %
                              (self.state.dest_path, responses.status))
     self.Notify("ViewObject", self.state.downloaded_file,
                 "Memory image transferred successfully")
Beispiel #3
0
 def Start(self):
     if self.args.report_name not in reports.Report.classes:
         raise flow.FlowError("No such report %s" % self.args.report_name)
     else:
         self.CallState(next_state="RunReport")
Beispiel #4
0
 def End(self):
     if self.state.plugin_errors:
         all_errors = u"\n".join(
             [unicode(e) for e in self.state.plugin_errors])
         raise flow.FlowError("Error running plugins: %s" % all_errors)
Beispiel #5
0
    def Done(self, responses):
        if not responses.success:
            raise flow.FlowError(str(responses.status))

        for response in responses:
            self.Log(response.data)
Beispiel #6
0
 def Confirmation(self, responses):
     """Confirmation."""
     if not responses.success:
         raise flow.FlowError("Failed to write config. Err: {0}".format(
             responses.status))
Beispiel #7
0
    def SendMessage(self, responses):
        if not responses.success:
            self.Log(responses.status.error_message)
            raise flow.FlowError(responses.status.error_message)

        self.CallClient("Echo", data="Wake up!", next_state="Sleep")
Beispiel #8
0
    def ReadBuffer(self, responses):
        """Read the buffer and write to the file."""
        # Did it work?
        if not responses.success:
            raise IOError("Error running ReadBuffer: %s" % responses.status)

        # Postpone creating the AFF4 object until we get at least one successful
        # buffer back.
        response = responses.First()

        # Initial packet
        if response.offset == 0:
            # Force creation of the new AFF4 object
            self.state.urn = aff4.AFF4Object.VFSGRRClient.PathspecToURN(
                self.state.args.pathspec, self.client_id)

            self.state.Register("file_size", self.state.stat.st_size)

            # Create the output file.
            fd = aff4.FACTORY.Create(self.state.urn,
                                     "VFSFile",
                                     mode="w",
                                     token=self.token)

            fd.SetChunksize(self.state.args.aff4_chunk_size)
            hash_value = fd.Schema.HASH()
            hash_value.sha256 = self.state.file_hash
            fd.Set(hash_value)
            fd.Set(fd.Schema.STAT(self.state.stat))

            self.state.Register("fd", fd)

            # Now we know how large the file is we can fill the window
            self.FetchWindow()

        if not response:
            raise IOError("Missing response to ReadBuffer: %s" %
                          responses.status)

        # We need to be synced to the file size.
        if self.state.fd.size != response.offset:
            raise flow.FlowError("File transfer out of sync.")

        self.state.fd.Write(response.data)

        # If the file is done, we dont hang around
        if self.state.fd.Tell() >= self.state.file_size:
            self.Terminate()

        offset_to_read = self.state.current_chunk_number * self.CHUNK_SIZE
        bytes_needed_to_read = (
            self.state.file_size -
            self.CHUNK_SIZE * self.state.current_chunk_number)

        # Dont read past the end of file
        if offset_to_read < self.state.file_size:
            self.CallClient("ReadBuffer",
                            pathspec=self.state.args.pathspec,
                            offset=offset_to_read,
                            length=min(bytes_needed_to_read, self.CHUNK_SIZE),
                            next_state="ReadBuffer")

        self.state.current_chunk_number += 1
Beispiel #9
0
 def State1(self, responses):
     if not responses.success:
         raise flow.FlowError(responses.status)
     self.CallClient("BusyHang", integer=5, next_state="Done")
Beispiel #10
0
 def TemporaryImageRemoved(self, responses):
     """Verify that the temporary image has been removed successfully."""
     if not responses.success:
         raise flow.FlowError("Unable to delete the temporary flash image: "
                              "{0}".format(responses.status))
Beispiel #11
0
 def Done(self, responses):
     if not responses.success:
         raise flow.FlowError(responses.status)
Beispiel #12
0
  def CheckAnalyzeClientMemory(self, responses):
    if not responses.success:
      raise flow.FlowError("Unable to image memory: %s." % responses.status)

    self.Log("Memory imaged successfully.")
    self.Status("Memory imaged successfully")
Beispiel #13
0
 def MultiGetFile(self, responses):
   if not responses.success:
     raise flow.FlowError(responses.status)
   self.state.Register("dest_path", responses.First().dest_path)
   self.CallFlow("MultiGetFile", pathspecs=[self.state.dest_path],
                 next_state="Done")
Beispiel #14
0
 def LogDeleteFiles(self, responses):
     # Check that the DeleteFiles flow worked.
     if not responses.success:
         raise flow.FlowError("Could not delete file: %s" %
                              responses.status)
Beispiel #15
0
 def Done(self, responses):
     if not responses.success:
         self.Log(responses.status.error_message)
         raise flow.FlowError(responses.status.error_message)
Beispiel #16
0
 def End(self):
     if not self.state.success:
         raise flow.FlowError("Failed to uninstall memory driver.")
Beispiel #17
0
  def Done(self, responses):
    if not responses.success:
      raise flow.FlowError("Registry search failed %s" % responses.status)

    for response in responses:
      self.SendReply(response)