Loading src/out-binary.c +13 −10 Original line number Diff line number Diff line #include "output.h" #include "masscan.h" #include "out-record.h" /**************************************************************************** ****************************************************************************/ Loading Loading @@ -43,10 +44,10 @@ binary_out_status(struct Output *out, FILE *fp, int status, unsigned ip, unsigne /* [TYPE] field */ switch (status) { case Port_Open: foo[0] = 1; foo[0] = Out_Open; break; case Port_Closed: foo[0] = 2; foo[0] = Out_Closed; break; default: return; Loading Loading @@ -81,7 +82,7 @@ binary_out_status(struct Output *out, FILE *fp, int status, unsigned ip, unsigne /**************************************************************************** ****************************************************************************/ static void binary_out_banner(struct Output *out, FILE *fp, unsigned ip, unsigned port, binary_out_banner(struct Output *out, FILE *fp, unsigned ip, unsigned ip_proto, unsigned port, unsigned proto, const unsigned char *px, unsigned length) { unsigned char foo[256]; Loading @@ -90,7 +91,7 @@ binary_out_banner(struct Output *out, FILE *fp, unsigned ip, unsigned port, UNUSEDPARM(out); /* [TYPE] field */ foo[0] = 3; /*banner*/ foo[0] = Out_Banner; /*banner*/ /* [LENGTH] field*/ if (length >= 128 * 128 - 12) Loading @@ -115,17 +116,19 @@ binary_out_banner(struct Output *out, FILE *fp, unsigned ip, unsigned port, foo[i+6] = (unsigned char)(ip>> 8); foo[i+7] = (unsigned char)(ip>> 0); foo[i+8] = (unsigned char)(port>>8); foo[i+9] = (unsigned char)(port>>0); foo[i+8] = (unsigned char)(ip_proto); foo[i+10] = (unsigned char)(proto>>8); foo[i+11] = (unsigned char)(proto>>0); foo[i+ 9] = (unsigned char)(port>>8); foo[i+10] = (unsigned char)(port>>0); foo[i+11] = (unsigned char)(proto>>8); foo[i+12] = (unsigned char)(proto>>0); /* Banner */ memcpy(foo+i+12, px, length); memcpy(foo+i+13, px, length); fwrite(&foo, 1, length+i+12, fp); fwrite(&foo, 1, length+i+13, fp); } Loading src/out-null.c +2 −1 Original line number Diff line number Diff line Loading @@ -38,12 +38,13 @@ null_out_status(struct Output *out, FILE *fp, /**************************************************************************** ****************************************************************************/ static void null_out_banner(struct Output *out, FILE *fp, unsigned ip, unsigned port, null_out_banner(struct Output *out, FILE *fp, unsigned ip, unsigned ip_proto, unsigned port, unsigned proto, const unsigned char *px, unsigned length) { UNUSEDPARM(out); UNUSEDPARM(fp); UNUSEDPARM(ip); UNUSEDPARM(ip_proto); UNUSEDPARM(port); UNUSEDPARM(proto); UNUSEDPARM(px); Loading src/out-record.h 0 → 100644 +9 −0 Original line number Diff line number Diff line #ifndef OUT_RECORD_H #define OUT_RECORD_H enum OutputRecordType { Out_Open = 1, Out_Closed = 2, Out_Banner = 4, }; #endif No newline at end of file src/out-text.c +11 −2 Original line number Diff line number Diff line Loading @@ -44,14 +44,23 @@ text_out_status(struct Output *out, FILE *fp, /*************************************** ************************************* ****************************************************************************/ static void text_out_banner(struct Output *out, FILE *fp, unsigned ip, unsigned port, text_out_banner(struct Output *out, FILE *fp, unsigned ip, unsigned ip_proto, unsigned port, unsigned proto, const unsigned char *px, unsigned length) { 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 tcp %u %u.%u.%u.%u %u %s %.*s\n", fprintf(fp, "%s %s %u %u.%u.%u.%u %u %s %.*s\n", "banner", ip_proto_sz, port, (ip>>24)&0xFF, (ip>>16)&0xFF, Loading src/out-xml.c +13 −3 Original line number Diff line number Diff line Loading @@ -65,7 +65,7 @@ xml_out_status(struct Output *out, FILE *fp, int status, fprintf(fp, "<host endtime=\"%u\">" "<address addr=\"%u.%u.%u.%u\" addrtype=\"ipv4\"/>" "<ports>" "<port protocol=\"tcp\" portid=\"%u\">" "<port protocol=\"%s\" portid=\"%u\">" "<state state=\"%s\" reason=\"%s\" reason_ttl=\"%u\"/>" "</port>" "</ports>" Loading @@ -76,6 +76,7 @@ xml_out_status(struct Output *out, FILE *fp, int status, (ip>>16)&0xFF, (ip>> 8)&0xFF, (ip>> 0)&0xFF, proto_from_status(status), port, status_string(status), reason_string(reason, reason_buffer, sizeof(reason_buffer)), Loading @@ -86,17 +87,25 @@ xml_out_status(struct Output *out, FILE *fp, int status, /**************************************************************************** ****************************************************************************/ static void xml_out_banner(struct Output *out, FILE *fp, unsigned ip, unsigned port, xml_out_banner(struct Output *out, FILE *fp, unsigned ip, unsigned ip_proto, unsigned port, unsigned proto, const unsigned char *px, unsigned length) { char banner_buffer[1024]; 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, "<host endtime=\"%u\">" "<address addr=\"%u.%u.%u.%u\" addrtype=\"ipv4\"/>" "<ports>" "<port protocol=\"tcp\" portid=\"%u\">" "<port protocol=\"%s\" portid=\"%u\">" "<service name=\"%s\">" "<banner>%s</banner>" "</service>" Loading @@ -109,6 +118,7 @@ xml_out_banner(struct Output *out, FILE *fp, unsigned ip, unsigned port, (ip>>16)&0xFF, (ip>> 8)&0xFF, (ip>> 0)&0xFF, ip_proto_sz, port, proto_string(proto), normalize_string(px, length, banner_buffer, sizeof(banner_buffer)) Loading Loading
src/out-binary.c +13 −10 Original line number Diff line number Diff line #include "output.h" #include "masscan.h" #include "out-record.h" /**************************************************************************** ****************************************************************************/ Loading Loading @@ -43,10 +44,10 @@ binary_out_status(struct Output *out, FILE *fp, int status, unsigned ip, unsigne /* [TYPE] field */ switch (status) { case Port_Open: foo[0] = 1; foo[0] = Out_Open; break; case Port_Closed: foo[0] = 2; foo[0] = Out_Closed; break; default: return; Loading Loading @@ -81,7 +82,7 @@ binary_out_status(struct Output *out, FILE *fp, int status, unsigned ip, unsigne /**************************************************************************** ****************************************************************************/ static void binary_out_banner(struct Output *out, FILE *fp, unsigned ip, unsigned port, binary_out_banner(struct Output *out, FILE *fp, unsigned ip, unsigned ip_proto, unsigned port, unsigned proto, const unsigned char *px, unsigned length) { unsigned char foo[256]; Loading @@ -90,7 +91,7 @@ binary_out_banner(struct Output *out, FILE *fp, unsigned ip, unsigned port, UNUSEDPARM(out); /* [TYPE] field */ foo[0] = 3; /*banner*/ foo[0] = Out_Banner; /*banner*/ /* [LENGTH] field*/ if (length >= 128 * 128 - 12) Loading @@ -115,17 +116,19 @@ binary_out_banner(struct Output *out, FILE *fp, unsigned ip, unsigned port, foo[i+6] = (unsigned char)(ip>> 8); foo[i+7] = (unsigned char)(ip>> 0); foo[i+8] = (unsigned char)(port>>8); foo[i+9] = (unsigned char)(port>>0); foo[i+8] = (unsigned char)(ip_proto); foo[i+10] = (unsigned char)(proto>>8); foo[i+11] = (unsigned char)(proto>>0); foo[i+ 9] = (unsigned char)(port>>8); foo[i+10] = (unsigned char)(port>>0); foo[i+11] = (unsigned char)(proto>>8); foo[i+12] = (unsigned char)(proto>>0); /* Banner */ memcpy(foo+i+12, px, length); memcpy(foo+i+13, px, length); fwrite(&foo, 1, length+i+12, fp); fwrite(&foo, 1, length+i+13, fp); } Loading
src/out-null.c +2 −1 Original line number Diff line number Diff line Loading @@ -38,12 +38,13 @@ null_out_status(struct Output *out, FILE *fp, /**************************************************************************** ****************************************************************************/ static void null_out_banner(struct Output *out, FILE *fp, unsigned ip, unsigned port, null_out_banner(struct Output *out, FILE *fp, unsigned ip, unsigned ip_proto, unsigned port, unsigned proto, const unsigned char *px, unsigned length) { UNUSEDPARM(out); UNUSEDPARM(fp); UNUSEDPARM(ip); UNUSEDPARM(ip_proto); UNUSEDPARM(port); UNUSEDPARM(proto); UNUSEDPARM(px); Loading
src/out-record.h 0 → 100644 +9 −0 Original line number Diff line number Diff line #ifndef OUT_RECORD_H #define OUT_RECORD_H enum OutputRecordType { Out_Open = 1, Out_Closed = 2, Out_Banner = 4, }; #endif No newline at end of file
src/out-text.c +11 −2 Original line number Diff line number Diff line Loading @@ -44,14 +44,23 @@ text_out_status(struct Output *out, FILE *fp, /*************************************** ************************************* ****************************************************************************/ static void text_out_banner(struct Output *out, FILE *fp, unsigned ip, unsigned port, text_out_banner(struct Output *out, FILE *fp, unsigned ip, unsigned ip_proto, unsigned port, unsigned proto, const unsigned char *px, unsigned length) { 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 tcp %u %u.%u.%u.%u %u %s %.*s\n", fprintf(fp, "%s %s %u %u.%u.%u.%u %u %s %.*s\n", "banner", ip_proto_sz, port, (ip>>24)&0xFF, (ip>>16)&0xFF, Loading
src/out-xml.c +13 −3 Original line number Diff line number Diff line Loading @@ -65,7 +65,7 @@ xml_out_status(struct Output *out, FILE *fp, int status, fprintf(fp, "<host endtime=\"%u\">" "<address addr=\"%u.%u.%u.%u\" addrtype=\"ipv4\"/>" "<ports>" "<port protocol=\"tcp\" portid=\"%u\">" "<port protocol=\"%s\" portid=\"%u\">" "<state state=\"%s\" reason=\"%s\" reason_ttl=\"%u\"/>" "</port>" "</ports>" Loading @@ -76,6 +76,7 @@ xml_out_status(struct Output *out, FILE *fp, int status, (ip>>16)&0xFF, (ip>> 8)&0xFF, (ip>> 0)&0xFF, proto_from_status(status), port, status_string(status), reason_string(reason, reason_buffer, sizeof(reason_buffer)), Loading @@ -86,17 +87,25 @@ xml_out_status(struct Output *out, FILE *fp, int status, /**************************************************************************** ****************************************************************************/ static void xml_out_banner(struct Output *out, FILE *fp, unsigned ip, unsigned port, xml_out_banner(struct Output *out, FILE *fp, unsigned ip, unsigned ip_proto, unsigned port, unsigned proto, const unsigned char *px, unsigned length) { char banner_buffer[1024]; 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, "<host endtime=\"%u\">" "<address addr=\"%u.%u.%u.%u\" addrtype=\"ipv4\"/>" "<ports>" "<port protocol=\"tcp\" portid=\"%u\">" "<port protocol=\"%s\" portid=\"%u\">" "<service name=\"%s\">" "<banner>%s</banner>" "</service>" Loading @@ -109,6 +118,7 @@ xml_out_banner(struct Output *out, FILE *fp, unsigned ip, unsigned port, (ip>>16)&0xFF, (ip>> 8)&0xFF, (ip>> 0)&0xFF, ip_proto_sz, port, proto_string(proto), normalize_string(px, length, banner_buffer, sizeof(banner_buffer)) Loading