diff --git a/src/out-grepable.c b/src/out-grepable.c index bd98a40f..fc47d818 100644 --- a/src/out-grepable.c +++ b/src/out-grepable.c @@ -174,7 +174,9 @@ grepable_out_banner(struct Output *out, FILE *fp, time_t timestamp, (unsigned char)(ip>> 8), (unsigned char)(ip>> 0) ); - fprintf(fp, "\tApp: %s", masscan_app_to_string(proto)); + fprintf(fp, "\tPort: %u", port); + + fprintf(fp, "\tService: %s", masscan_app_to_string(proto)); normalize_string(px, length, banner_buffer, sizeof(banner_buffer)); @@ -183,6 +185,7 @@ grepable_out_banner(struct Output *out, FILE *fp, time_t timestamp, } + /**************************************************************************** * This is the only structure exposed to the rest of the system. Everything * else in the file is defined 'static' or 'private'. diff --git a/src/out-text.c b/src/out-text.c index 9d9e9adb..39adb08f 100644 --- a/src/out-text.c +++ b/src/out-text.c @@ -54,20 +54,13 @@ text_out_banner(struct Output *out, FILE *fp, time_t timestamp, enum ApplicationProtocol proto, const unsigned char *px, unsigned length) { char banner_buffer[4096]; - char ip_proto_sz[64]; - switch (ip_proto) { - case 1: strcpy_s(ip_proto_sz, sizeof(ip_proto_sz), "icmp"); break; - case 6: strcpy_s(ip_proto_sz, sizeof(ip_proto_sz), "tcp"); break; - case 17: strcpy_s(ip_proto_sz, sizeof(ip_proto_sz), "udp"); break; - default: sprintf_s(ip_proto_sz, sizeof(ip_proto_sz), "(%u)", ip_proto); break; - } UNUSEDPARM(out); fprintf(fp, "%s %s %u %u.%u.%u.%u %u %s %s\n", "banner", - ip_proto_sz, + proto_from_proto(ip_proto), port, (ip>>24)&0xFF, (ip>>16)&0xFF, diff --git a/src/out-xml.c b/src/out-xml.c index 9a8ed70d..87e8936c 100644 --- a/src/out-xml.c +++ b/src/out-xml.c @@ -97,17 +97,9 @@ xml_out_banner(struct Output *out, FILE *fp, time_t timestamp, enum ApplicationProtocol proto, const unsigned char *px, unsigned length) { char banner_buffer[4096]; - char ip_proto_sz[64]; UNUSEDPARM(out); - switch (ip_proto) { - case 1: strcpy_s(ip_proto_sz, sizeof(ip_proto_sz), "icmp"); break; - case 6: strcpy_s(ip_proto_sz, sizeof(ip_proto_sz), "tcp"); break; - case 17: strcpy_s(ip_proto_sz, sizeof(ip_proto_sz), "udp"); break; - default: sprintf_s(ip_proto_sz, sizeof(ip_proto_sz), "(%u)", ip_proto); break; - } - fprintf(fp, "" "
" "" @@ -124,7 +116,7 @@ xml_out_banner(struct Output *out, FILE *fp, time_t timestamp, (ip>>16)&0xFF, (ip>> 8)&0xFF, (ip>> 0)&0xFF, - ip_proto_sz, + proto_from_proto(ip_proto), port, masscan_app_to_string(proto), normalize_string(px, length, banner_buffer, sizeof(banner_buffer)) diff --git a/src/output.c b/src/output.c index 6aa88663..e141d366 100644 --- a/src/output.c +++ b/src/output.c @@ -43,6 +43,21 @@ #include +/***************************************************************************** + * The 'status' variable contains both the open/closed info as well as the + * protocol info. This splits it back out into two values. + *****************************************************************************/ +const char * +proto_from_proto(unsigned ip_proto) +{ + switch (ip_proto) { + case 1: return "icmp"; + case 6: return "tcp"; + case 17: return "udp"; + case 132: return "sctp"; + default: return "unknown"; + } +} /***************************************************************************** * The 'status' variable contains both the open/closed info as well as the @@ -740,8 +755,9 @@ output_report_banner(struct Output *out, time_t now, unsigned count; char banner_buffer[4096]; - count = fprintf(stdout, "Banner on port %u/tcp on %u.%u.%u.%u: [%s] %s", + count = fprintf(stdout, "Banner on port %u/%s on %u.%u.%u.%u: [%s] %s", port, + proto_from_proto(ip_proto), (ip>>24)&0xFF, (ip>>16)&0xFF, (ip>> 8)&0xFF, diff --git a/src/output.h b/src/output.h index 4f180734..6e12d309 100644 --- a/src/output.h +++ b/src/output.h @@ -96,6 +96,7 @@ struct Output } xml; }; +const char *proto_from_proto(unsigned ip_proto); const char *proto_from_status(unsigned status); const char *status_string(int x); const char *reason_string(int x, char *buffer, size_t sizeof_buffer); diff --git a/src/templ-pkt.c b/src/templ-pkt.c index 94f200f0..af9bb16f 100644 --- a/src/templ-pkt.c +++ b/src/templ-pkt.c @@ -648,7 +648,7 @@ template_set_target( px[offset_tcp+6] = (unsigned char)(0); px[offset_tcp+7] = (unsigned char)(0); - xsum = udp_checksum(tmpl); + xsum = udp_checksum2(px, offset_ip, offset_tcp, tmpl->length - offset_tcp); /*xsum += (uint64_t)tmpl->checksum_tcp + (uint64_t)ip_me + (uint64_t)ip_them