Commit 51ccbd2a authored by Robert David Graham's avatar Robert David Graham
Browse files

faster banners, on FIN instead of TCB destruction

parent 5737ea54
Loading
Loading
Loading
Loading
+4 −4
Changes for src/main-conf.c: 4 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -1345,7 +1345,7 @@ masscan_set_parameter(struct Masscan *masscan,
    } else if (EQUALS("datadir", name)) {
        strcpy_s(masscan->nmap.datadir, sizeof(masscan->nmap.datadir), value);
    } else if (EQUALS("data-length", name)) {
        unsigned x = strtoul(value, 0, 0);
        unsigned x = (unsigned)strtoul(value, 0, 0);
        if (x >= 1514 - 14 - 40) {
            fprintf(stderr, "error: %s=<n>: expected number less than 1500\n", name);
        } else {
@@ -1655,7 +1655,7 @@ masscan_set_parameter(struct Masscan *masscan,
            while (offset < max_offset && isspace(value[offset]))
                offset++;
            if (offset+1 < max_offset && value[offset] == ':' && isdigit(value[offset+1]&0xFF)) {
                port = strtoul(value+offset+1, 0, 0);
                port = (unsigned)strtoul(value+offset+1, 0, 0);
                if (port > 65535 || port == 0) {
                    LOG(0, "FAIL: bad redis port: %s\n", value+offset+1);
                    exit(1);
@@ -1679,7 +1679,7 @@ masscan_set_parameter(struct Masscan *masscan,
    } else if (EQUALS("resume-count", name)) {
        masscan->resume.count = parseInt(value);
    } else if (EQUALS("retries", name) || EQUALS("retry", name)) {
        unsigned x = strtoul(value, 0, 0);
        unsigned x = (unsigned)strtoul(value, 0, 0);
        if (x >= 1000) {
            fprintf(stderr, "error: retries=<n>: expected number less than 1000\n");
        } else {
@@ -1809,7 +1809,7 @@ masscan_set_parameter(struct Masscan *masscan,
        if (EQUALS("csv", value))
            masscan->is_test_csv = 0;
    } else if (EQUALS("ttl", name)) {
        unsigned x = strtoul(value, 0, 0);
        unsigned x = (unsigned)strtoul(value, 0, 0);
        if (x >= 256) {
            fprintf(stderr, "error: %s=<n>: expected number less than 256\n", name);
        } else {
+4
Changes for src/masscan-app.h: 4 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -30,6 +30,10 @@ enum ApplicationProtocol {
    PROTO_VNC_RFB,
    PROTO_SAFE,
    PROTO_MEMCACHED,
    
    
    
    PROTO_end_of_list /* must be last one */
};

const char *
+14 −2
Changes for src/proto-banner1.c: 14 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -238,7 +238,9 @@ banner1_create(void)
    memset(b, 0, sizeof(*b));

    /*
     * These patterns match the start of the TCP stream
     * This creates a pattern-matching blob for heuristically determining
     * a protocol that runs on wrong ports, such as how FTP servers
     * often respond with "220 " or VNC servers respond with "RFB".
     */
    b->smack = smack_create("banner1", SMACK_CASE_INSENSITIVE);
    for (i=0; patterns[i].pattern; i++)
@@ -251,9 +253,19 @@ banner1_create(void)
    smack_compile(b->smack);


    /* 
     * This goes down the list of all the TCP protocol handlers and initializes
     * them.
     */
    banner_ftp.init(b);
    banner_http.init(b);
    banner_vnc.init(b);
    banner_imap4.init(b);
    banner_memcached.init(b);
    banner_pop3.init(b);
    banner_smtp.init(b);
    banner_ssh.init(b);
    banner_ssl.init(b);
    banner_vnc.init(b);

    b->tcp_payloads[80] = &banner_http;
    b->tcp_payloads[8080] = &banner_http;
+12
Changes for src/proto-banner1.h: 12 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -3,11 +3,21 @@
#include <stdint.h>
#define STATE_DONE 0xFFFFFFFF
#include <stdio.h>
#include "masscan-app.h"
#include "proto-banout.h"
#include "proto-x509.h"

struct InteractiveData;
struct Banner1;
struct ProtocolState;

typedef void (*BannerParser)(
              const struct Banner1 *banner1,
              void *banner1_private,
              struct ProtocolState *stream_state,
              const unsigned char *px, size_t length,
              struct BannerOutput *banout,
              struct InteractiveData *more);
struct Banner1
{
    struct SMACK *smack;
@@ -25,6 +35,8 @@ struct Banner1
    unsigned is_poodle_sslv3:1;

    struct ProtocolParserStream *tcp_payloads[65536];
    
    BannerParser parser[PROTO_end_of_list];
};

struct BannerBase64
+1
Changes for src/proto-banout.c: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ banout_release(struct BannerOutput *banout)
        free(banout->next);
        banout->next = next;
    }
    banout_init(banout);
}


Loading