Loading src/in-binary.c +17 −0 Original line number Diff line number Diff line Loading @@ -42,6 +42,9 @@ parse_status(struct Output *out, record.reason = buf[10]; record.ttl = buf[11]; if (out->when_scan_started == 0) out->when_scan_started = record.timestamp; switch (record.port) { case 53: case 123: Loading Loading @@ -93,6 +96,9 @@ parse_status2(struct Output *out, record.reason = buf[11]; record.ttl = buf[12]; if (out->when_scan_started == 0) out->when_scan_started = record.timestamp; /* * Now report the result */ Loading Loading @@ -127,6 +133,8 @@ parse_banner3(struct Output *out, unsigned char *buf, size_t buf_length) record.port = buf[8]<<8 | buf[9]; record.app_proto = buf[10]<<8 | buf[11]; if (out->when_scan_started == 0) out->when_scan_started = record.timestamp; /* * Now print the output Loading Loading @@ -160,6 +168,9 @@ parse_banner4(struct Output *out, unsigned char *buf, size_t buf_length) record.port = buf[9]<<8 | buf[10]; record.app_proto = buf[11]<<8 | buf[12]; if (out->when_scan_started == 0) out->when_scan_started = record.timestamp; /* * Now print the output */ Loading Loading @@ -325,6 +336,12 @@ convert_binary_files(struct Masscan *masscan, out = output_create(masscan, 0); /* * Set the start time to zero. We'll read it from the first file * that we parse */ out->when_scan_started = 0; /* * We don't parse the entire argument list, just a subrange * containing the list of files. The 'arg_first' parameter Loading src/output.c +24 −5 Original line number Diff line number Diff line Loading @@ -196,9 +196,10 @@ open_rotate(struct Output *out, const char *filename) } /* * Write the format-specific headers, like <xml> * Mark the file as newly opened. That way, before writing any data * to it, we'll first have to write headers */ out->funcs->open(out, fp); out->is_virgin_file = 1; return fp; } Loading @@ -220,6 +221,7 @@ close_rotate(struct Output *out, FILE *fp) /* * Write the format-specific trailers, like </xml> */ if (!out->is_virgin_file) out->funcs->close(out, fp); memset(&out->counts, 0, sizeof(out->counts)); Loading Loading @@ -368,6 +370,7 @@ output_create(const struct Masscan *masscan, unsigned thread_index) memset(out, 0, sizeof(*out)); out->masscan = masscan; out->when_scan_started = time(0); out->is_virgin_file = 1; /* * Copy the configuration information from the 'masscan' structure. Loading Loading @@ -644,7 +647,7 @@ output_report_status(struct Output *out, time_t timestamp, int status, * file, rather than in a separate thread right at the time interval. * Thus, if results are coming in slowly, the rotation won't happen * on precise boundaries */ if (now >= out->rotate.next) { if (now >= out->rotate.next && !out->is_virgin_file) { fp = output_do_rotate(out, 0); if (fp == NULL) return; Loading Loading @@ -694,6 +697,14 @@ output_report_status(struct Output *out, time_t timestamp, int status, return; } /* * If this is a newly opened file, then write file headers */ if (out->is_virgin_file) { out->funcs->open(out, fp); out->is_virgin_file = 0; } /* * Now do the actual output, whether it be XML, binary, JSON, Redis, * and so on. Loading Loading @@ -753,12 +764,20 @@ output_report_banner(struct Output *out, time_t now, * file, rather than in a separate thread right at the time interval. * Thus, if results are coming in slowly, the rotation won't happen * on precise boundaries */ if (now >= out->rotate.next) { if (now >= out->rotate.next && !out->is_virgin_file) { fp = output_do_rotate(out, 0); if (fp == NULL) return; } /* * If this is a newly opened file, then write file headers */ if (out->is_virgin_file) { out->funcs->open(out, fp); out->is_virgin_file = 0; } /* * Now do the actual output, whether it be XML, binary, JSON, Redis, * and so on. Loading src/output.h +1 −0 Original line number Diff line number Diff line Loading @@ -48,6 +48,7 @@ struct Output unsigned format; time_t when_scan_started; unsigned is_virgin_file:1; struct { time_t next; Loading Loading
src/in-binary.c +17 −0 Original line number Diff line number Diff line Loading @@ -42,6 +42,9 @@ parse_status(struct Output *out, record.reason = buf[10]; record.ttl = buf[11]; if (out->when_scan_started == 0) out->when_scan_started = record.timestamp; switch (record.port) { case 53: case 123: Loading Loading @@ -93,6 +96,9 @@ parse_status2(struct Output *out, record.reason = buf[11]; record.ttl = buf[12]; if (out->when_scan_started == 0) out->when_scan_started = record.timestamp; /* * Now report the result */ Loading Loading @@ -127,6 +133,8 @@ parse_banner3(struct Output *out, unsigned char *buf, size_t buf_length) record.port = buf[8]<<8 | buf[9]; record.app_proto = buf[10]<<8 | buf[11]; if (out->when_scan_started == 0) out->when_scan_started = record.timestamp; /* * Now print the output Loading Loading @@ -160,6 +168,9 @@ parse_banner4(struct Output *out, unsigned char *buf, size_t buf_length) record.port = buf[9]<<8 | buf[10]; record.app_proto = buf[11]<<8 | buf[12]; if (out->when_scan_started == 0) out->when_scan_started = record.timestamp; /* * Now print the output */ Loading Loading @@ -325,6 +336,12 @@ convert_binary_files(struct Masscan *masscan, out = output_create(masscan, 0); /* * Set the start time to zero. We'll read it from the first file * that we parse */ out->when_scan_started = 0; /* * We don't parse the entire argument list, just a subrange * containing the list of files. The 'arg_first' parameter Loading
src/output.c +24 −5 Original line number Diff line number Diff line Loading @@ -196,9 +196,10 @@ open_rotate(struct Output *out, const char *filename) } /* * Write the format-specific headers, like <xml> * Mark the file as newly opened. That way, before writing any data * to it, we'll first have to write headers */ out->funcs->open(out, fp); out->is_virgin_file = 1; return fp; } Loading @@ -220,6 +221,7 @@ close_rotate(struct Output *out, FILE *fp) /* * Write the format-specific trailers, like </xml> */ if (!out->is_virgin_file) out->funcs->close(out, fp); memset(&out->counts, 0, sizeof(out->counts)); Loading Loading @@ -368,6 +370,7 @@ output_create(const struct Masscan *masscan, unsigned thread_index) memset(out, 0, sizeof(*out)); out->masscan = masscan; out->when_scan_started = time(0); out->is_virgin_file = 1; /* * Copy the configuration information from the 'masscan' structure. Loading Loading @@ -644,7 +647,7 @@ output_report_status(struct Output *out, time_t timestamp, int status, * file, rather than in a separate thread right at the time interval. * Thus, if results are coming in slowly, the rotation won't happen * on precise boundaries */ if (now >= out->rotate.next) { if (now >= out->rotate.next && !out->is_virgin_file) { fp = output_do_rotate(out, 0); if (fp == NULL) return; Loading Loading @@ -694,6 +697,14 @@ output_report_status(struct Output *out, time_t timestamp, int status, return; } /* * If this is a newly opened file, then write file headers */ if (out->is_virgin_file) { out->funcs->open(out, fp); out->is_virgin_file = 0; } /* * Now do the actual output, whether it be XML, binary, JSON, Redis, * and so on. Loading Loading @@ -753,12 +764,20 @@ output_report_banner(struct Output *out, time_t now, * file, rather than in a separate thread right at the time interval. * Thus, if results are coming in slowly, the rotation won't happen * on precise boundaries */ if (now >= out->rotate.next) { if (now >= out->rotate.next && !out->is_virgin_file) { fp = output_do_rotate(out, 0); if (fp == NULL) return; } /* * If this is a newly opened file, then write file headers */ if (out->is_virgin_file) { out->funcs->open(out, fp); out->is_virgin_file = 0; } /* * Now do the actual output, whether it be XML, binary, JSON, Redis, * and so on. Loading
src/output.h +1 −0 Original line number Diff line number Diff line Loading @@ -48,6 +48,7 @@ struct Output unsigned format; time_t when_scan_started; unsigned is_virgin_file:1; struct { time_t next; Loading