Beispiel #1
0
    def Run(self, args):
        """Reads a buffer on the client and sends it to the server."""
        # Make sure we limit the size of our output
        if args.length > constants.CLIENT_MAX_BUFFER_SIZE:
            raise RuntimeError("Can not read buffers this large.")

        data = vfs.ReadVFS(args.pathspec,
                           args.offset,
                           args.length,
                           progress_callback=self.Progress)
        result = rdf_protodict.DataBlob(
            data=zlib.compress(data),
            compression=rdf_protodict.DataBlob.CompressionType.ZCOMPRESSION)

        digest = hashlib.sha256(data).digest()

        # Ensure that the buffer is counted against this response. Check network
        # send limit.
        self.ChargeBytesToSession(len(data))

        # Now return the data to the server into the special TransferStore well
        # known flow.
        self.grr_worker.SendReply(
            result, session_id=rdfvalue.SessionID(flow_name="TransferStore"))

        # Now report the hash of this blob to our flow as well as the offset and
        # length.
        self.SendReply(
            rdf_client.BufferReference(offset=args.offset,
                                       length=len(data),
                                       data=digest))
Beispiel #2
0
    def Run(self, args):
        """Reads a buffer on the client and sends it to the server."""
        # Make sure we limit the size of our output
        if args.length > MAX_BUFFER_SIZE:
            raise RuntimeError("Can not read buffers this large.")

        data = vfs.ReadVFS(args.pathspec, args.offset, args.length)

        digest = hashlib.sha256(data).digest()

        # Now report the hash of this blob to our flow as well as the offset and
        # length.
        self.SendReply(offset=args.offset, length=len(data), data=digest)