Commit 3e9b90dd authored by robertdavidgraham's avatar robertdavidgraham
Browse files

fixed banner 'tcp' problem

parent c3c7bde3
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -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'.
+1 −8
Original line number Diff line number Diff line
@@ -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,
+1 −9
Original line number Diff line number Diff line
@@ -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, "<host endtime=\"%u\">"
                    "<address addr=\"%u.%u.%u.%u\" addrtype=\"ipv4\"/>"
                    "<ports>"
@@ -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))
+17 −1
Original line number Diff line number Diff line
@@ -43,6 +43,21 @@
#include <string.h>


/*****************************************************************************
 * 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,
+1 −0
Original line number Diff line number Diff line
@@ -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);
Loading