Not sure if this is what you want but here it goes:
var OUTPUT_DIR = java.nio.file.Paths.get("/path/to/messages/dir/");
function processMessage(utils, message) {
}
function processResult(utils, fuzzResult){
var filename = fuzzResult.getPayloads().get(0) + '.html';
var file =
java.nio.file.Files.newOutputStream(OUTPUT_DIR.resolve(filename),
java.nio.file.StandardOpenOption.CREATE_NEW);
file.write(fuzzResult.getHttpMessage().getResponseBody().getBytes());
file.close();
return true;
}
The above JavaScript "Fuzzer HTTP Processor" script saves the body of
the HTTP responses to files named with the value of the (first, of each
set) payload, appended with "html" extension.
For example, if you are fuzzing a field with 1, 2, 3... it will create
files "1.html", "2.html", "3.html"... in the OUTPUT_DIR.
Tested with ZAP 2.4.2 (using Java 7).
Let us know if you need help on how to create the script.
(Note that you need to enable the script to be able to select it in
"Fuzzer" dialogue)
Best regards.