def Run(self, args): """Run.""" pub_key = config_lib.CONFIG["Client.executable_signing_public_key"] if not args.executable.Verify(pub_key): raise OSError("Executable signing failure.") path = self.WriteBlobToFile(args.executable, args.write_path, ".pkg") cmd = "/usr/sbin/installer" cmd_args = ["-pkg", path, "-target", "/"] time_limit = args.time_limit res = client_utils_common.Execute(cmd, cmd_args, time_limit=time_limit, bypass_whitelist=True) (stdout, stderr, status, time_used) = res self.CleanUp(path) # Limit output to 10MB so our response doesn't get too big. stdout = stdout[:10 * 1024 * 1024] stderr = stderr[:10 * 1024 * 1024] result = rdfvalue.ExecuteBinaryResponse( stdout=stdout, stderr=stderr, exit_status=status, # We have to return microseconds. time_used=int(1e6 * time_used)) self.SendReply(result)
def ProcessFile(self, path, args): res = client_utils_common.Execute(path, args.args, args.time_limit, bypass_whitelist=True) (stdout, stderr, status, time_used) = res # Limit output to 10MB so our response doesn't get too big. stdout = stdout[:10 * 1024 * 1024] stderr = stderr[:10 * 1024 * 1024] result = rdfvalue.ExecuteBinaryResponse( stdout=stdout, stderr=stderr, exit_status=status, # We have to return microseconds. time_used=int(1e6 * time_used)) self.SendReply(result)
def ProcessFile(self, path, args): cmd = "/usr/sbin/installer" cmd_args = ["-pkg", path, "-target", "/"] time_limit = args.time_limit res = client_utils_common.Execute(cmd, cmd_args, time_limit=time_limit, bypass_whitelist=True) (stdout, stderr, status, time_used) = res # Limit output to 10MB so our response doesn't get too big. stdout = stdout[:10 * 1024 * 1024] stderr = stderr[:10 * 1024 * 1024] result = rdfvalue.ExecuteBinaryResponse(stdout=stdout, stderr=stderr, exit_status=status, # We have to return microseconds. time_used=int(1e6 * time_used)) self.SendReply(result)
def Run(self, args): """Run.""" # Verify the executable blob. args.executable.Verify( config_lib.CONFIG["Client.executable_signing_public_key"]) if sys.platform == "win32": # We need .exe here. suffix = ".exe" else: suffix = "" lifetime = args.time_limit # Keep the file for at least 5 seconds after execution. if lifetime > 0: lifetime += 5 path = self.WriteBlobToFile(args.executable, lifetime, suffix) res = client_utils_common.Execute(path, args.args, args.time_limit, bypass_whitelist=True) (stdout, stderr, status, time_used) = res self.CleanUp(path) # Limit output to 10MB so our response doesn't get too big. stdout = stdout[:10 * 1024 * 1024] stderr = stderr[:10 * 1024 * 1024] result = rdfvalue.ExecuteBinaryResponse( stdout=stdout, stderr=stderr, exit_status=status, # We have to return microseconds. time_used=int(1e6 * time_used)) self.SendReply(result)