Loading src/main-conf.c +60 −2 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ #include "proto-banner1.h" #include "templ-payloads.h" #include "templ-port.h" #include "crypto-base64.h" #include <ctype.h> #include <limits.h> Loading Loading @@ -289,6 +290,18 @@ masscan_echo(struct Masscan *masscan, FILE *fp) fprintf(fp, "%scapture = cert\n", masscan->is_capture_cert?"":"no"); fprintf(fp, "%scapture = html\n", masscan->is_capture_html?"":"no"); /* * TCP payloads */ fprintf(fp, "\n"); { struct TcpCfgPayloads *pay; for (pay = masscan->tcp_payloads; pay; pay = pay->next) { fprintf(fp, "hello-string[%u] = %s\n", pay->port, pay->payload_base64); } } } /*************************************************************************** Loading Loading @@ -606,7 +619,7 @@ masscan_set_parameter(struct Masscan *masscan, const char *name, const char *value) { unsigned index = ARRAY(name); if (index >= 8) { if (index >= 65536) { fprintf(stderr, "%s: bad index\n", name); exit(1); } Loading Loading @@ -893,7 +906,7 @@ masscan_set_parameter(struct Masscan *masscan, } else if (EQUALS("banners", name) || EQUALS("banner", name)) { masscan->is_banners = 1; } else if (EQUALS("connection-timeout", name)) { masscan->tcp_connection_timeout = parseInt(value); masscan->tcp_connection_timeout = (unsigned)parseInt(value); } else if (EQUALS("datadir", name)) { strcpy_s(masscan->nmap.datadir, sizeof(masscan->nmap.datadir), value); } else if (EQUALS("data-length", name)) { Loading Loading @@ -923,6 +936,51 @@ masscan_set_parameter(struct Masscan *masscan, if (count2 - count1) fprintf(stderr, "%s: excluding %u ranges from file\n", value, count2 - count1); } else if (EQUALS("hello-file", name)) { /* When connecting via TCP, send this file */ FILE *fp; int x; char buf[16384]; char buf2[16384]; size_t bytes_read; size_t bytes_encoded; char foo[64]; x = fopen_s(&fp, value, "rb"); if (x != 0) { LOG(0, "[FAILED] could not read hello file\n"); perror(value); exit(1); } bytes_read = fread(buf, 1, sizeof(buf), fp); if (bytes_read == 0) { LOG(0, "[FAILED] could not read hello file\n"); perror(value); fclose(fp); exit(1); } fclose(fp); bytes_encoded = base64_encode(buf2, sizeof(buf2)-1, buf, bytes_read); buf2[bytes_encoded] = '\0'; sprintf_s(foo, sizeof(foo), "hello-string[%u]", (unsigned)index); masscan_set_parameter(masscan, foo, buf2); } else if (EQUALS("hello-string", name)) { char *value2; struct TcpCfgPayloads *pay; value2 = (char*)malloc(strlen(value)+1); memcpy(value2, value, strlen(value)+1); pay = (struct TcpCfgPayloads *)malloc(sizeof(*pay)); pay->payload_base64 = value2; pay->port = index; pay->next = masscan->tcp_payloads; masscan->tcp_payloads = pay; } else if (EQUALS("host-timeout", name)) { fprintf(stderr, "nmap(%s): unsupported: this is an asynchronous tool, so no timeouts\n", name); exit(1); Loading src/main.c +13 −0 Original line number Diff line number Diff line Loading @@ -47,6 +47,7 @@ #include "proto-zeroaccess.h" #include "siphash24.h" #include "proto-x509.h" #include "crypto-base64.h" /* base64 encode/decode */ #include <assert.h> Loading Loading @@ -584,6 +585,8 @@ receive_thread(void *v) * connections when doing --banners */ if (masscan->is_banners) { struct TcpCfgPayloads *pay; tcpcon = tcpcon_create_table( (size_t)((masscan->max_rate/5) / masscan->nic_count), parms->transmit_queue, Loading @@ -610,6 +613,15 @@ receive_thread(void *v) foo); } for (pay = masscan->tcp_payloads; pay; pay = pay->next) { char name[64]; sprintf_s(name, sizeof(name), "hello-string[%u]", pay->port); tcpcon_set_parameter( tcpcon, name, strlen(pay->payload_base64), pay->payload_base64); } } /* Loading Loading @@ -1454,6 +1466,7 @@ int main(int argc, char *argv[]) */ { int x = 0; x += base64_selftest(); x += banner1_selftest(); x += output_selftest(); x += siphash24_selftest(); Loading src/masscan.h +7 −0 Original line number Diff line number Diff line Loading @@ -39,6 +39,12 @@ enum OutpuFormat { }; struct TcpCfgPayloads { char *payload_base64; unsigned port; struct TcpCfgPayloads *next; }; struct Masscan { Loading Loading @@ -170,6 +176,7 @@ struct Masscan } tcb; struct NmapPayloads *payloads; struct TcpCfgPayloads *tcp_payloads; unsigned char *http_user_agent; unsigned http_user_agent_length; Loading src/proto-banner1.c +11 −11 Original line number Diff line number Diff line Loading @@ -175,17 +175,17 @@ banner1_create(void) b->tcp_payloads[80] = &banner_http; b->tcp_payloads[8080] = &banner_http; b->tcp_payloads[443] = &banner_ssl; /* HTTP/s */ b->tcp_payloads[465] = &banner_ssl; /* SMTP/s */ b->tcp_payloads[990] = &banner_ssl; /* FTP/s */ b->tcp_payloads[993] = &banner_ssl; /* IMAP4/s */ b->tcp_payloads[995] = &banner_ssl; /* POP3/s */ b->tcp_payloads[2083] = &banner_ssl; /* cPanel - SSL */ b->tcp_payloads[2087] = &banner_ssl; /* WHM - SSL */ b->tcp_payloads[2096] = &banner_ssl; /* cPanel webmail - SSL */ b->tcp_payloads[8443] = &banner_ssl; /* Plesk Control Panel - SSL */ b->tcp_payloads[9050] = &banner_ssl; /* Tor */ b->tcp_payloads[8140] = &banner_ssl; /* puppet */ b->tcp_payloads[443] = (void*)&banner_ssl; /* HTTP/s */ b->tcp_payloads[465] = (void*)&banner_ssl; /* SMTP/s */ b->tcp_payloads[990] = (void*)&banner_ssl; /* FTP/s */ b->tcp_payloads[993] = (void*)&banner_ssl; /* IMAP4/s */ b->tcp_payloads[995] = (void*)&banner_ssl; /* POP3/s */ b->tcp_payloads[2083] = (void*)&banner_ssl; /* cPanel - SSL */ b->tcp_payloads[2087] = (void*)&banner_ssl; /* WHM - SSL */ b->tcp_payloads[2096] = (void*)&banner_ssl; /* cPanel webmail - SSL */ b->tcp_payloads[8443] = (void*)&banner_ssl; /* Plesk Control Panel - SSL */ b->tcp_payloads[9050] = (void*)&banner_ssl; /* Tor */ b->tcp_payloads[8140] = (void*)&banner_ssl; /* puppet */ return b; Loading src/proto-banner1.h +1 −3 Original line number Diff line number Diff line Loading @@ -12,12 +12,10 @@ struct Banner1 struct SMACK *http_fields; struct SMACK *html_fields; /*unsigned char *http_header; unsigned http_header_length;*/ unsigned is_capture_html:1; unsigned is_capture_cert:1; const struct ProtocolParserStream *tcp_payloads[65536]; struct ProtocolParserStream *tcp_payloads[65536]; }; struct SSL_SERVER_HELLO { Loading Loading
src/main-conf.c +60 −2 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ #include "proto-banner1.h" #include "templ-payloads.h" #include "templ-port.h" #include "crypto-base64.h" #include <ctype.h> #include <limits.h> Loading Loading @@ -289,6 +290,18 @@ masscan_echo(struct Masscan *masscan, FILE *fp) fprintf(fp, "%scapture = cert\n", masscan->is_capture_cert?"":"no"); fprintf(fp, "%scapture = html\n", masscan->is_capture_html?"":"no"); /* * TCP payloads */ fprintf(fp, "\n"); { struct TcpCfgPayloads *pay; for (pay = masscan->tcp_payloads; pay; pay = pay->next) { fprintf(fp, "hello-string[%u] = %s\n", pay->port, pay->payload_base64); } } } /*************************************************************************** Loading Loading @@ -606,7 +619,7 @@ masscan_set_parameter(struct Masscan *masscan, const char *name, const char *value) { unsigned index = ARRAY(name); if (index >= 8) { if (index >= 65536) { fprintf(stderr, "%s: bad index\n", name); exit(1); } Loading Loading @@ -893,7 +906,7 @@ masscan_set_parameter(struct Masscan *masscan, } else if (EQUALS("banners", name) || EQUALS("banner", name)) { masscan->is_banners = 1; } else if (EQUALS("connection-timeout", name)) { masscan->tcp_connection_timeout = parseInt(value); masscan->tcp_connection_timeout = (unsigned)parseInt(value); } else if (EQUALS("datadir", name)) { strcpy_s(masscan->nmap.datadir, sizeof(masscan->nmap.datadir), value); } else if (EQUALS("data-length", name)) { Loading Loading @@ -923,6 +936,51 @@ masscan_set_parameter(struct Masscan *masscan, if (count2 - count1) fprintf(stderr, "%s: excluding %u ranges from file\n", value, count2 - count1); } else if (EQUALS("hello-file", name)) { /* When connecting via TCP, send this file */ FILE *fp; int x; char buf[16384]; char buf2[16384]; size_t bytes_read; size_t bytes_encoded; char foo[64]; x = fopen_s(&fp, value, "rb"); if (x != 0) { LOG(0, "[FAILED] could not read hello file\n"); perror(value); exit(1); } bytes_read = fread(buf, 1, sizeof(buf), fp); if (bytes_read == 0) { LOG(0, "[FAILED] could not read hello file\n"); perror(value); fclose(fp); exit(1); } fclose(fp); bytes_encoded = base64_encode(buf2, sizeof(buf2)-1, buf, bytes_read); buf2[bytes_encoded] = '\0'; sprintf_s(foo, sizeof(foo), "hello-string[%u]", (unsigned)index); masscan_set_parameter(masscan, foo, buf2); } else if (EQUALS("hello-string", name)) { char *value2; struct TcpCfgPayloads *pay; value2 = (char*)malloc(strlen(value)+1); memcpy(value2, value, strlen(value)+1); pay = (struct TcpCfgPayloads *)malloc(sizeof(*pay)); pay->payload_base64 = value2; pay->port = index; pay->next = masscan->tcp_payloads; masscan->tcp_payloads = pay; } else if (EQUALS("host-timeout", name)) { fprintf(stderr, "nmap(%s): unsupported: this is an asynchronous tool, so no timeouts\n", name); exit(1); Loading
src/main.c +13 −0 Original line number Diff line number Diff line Loading @@ -47,6 +47,7 @@ #include "proto-zeroaccess.h" #include "siphash24.h" #include "proto-x509.h" #include "crypto-base64.h" /* base64 encode/decode */ #include <assert.h> Loading Loading @@ -584,6 +585,8 @@ receive_thread(void *v) * connections when doing --banners */ if (masscan->is_banners) { struct TcpCfgPayloads *pay; tcpcon = tcpcon_create_table( (size_t)((masscan->max_rate/5) / masscan->nic_count), parms->transmit_queue, Loading @@ -610,6 +613,15 @@ receive_thread(void *v) foo); } for (pay = masscan->tcp_payloads; pay; pay = pay->next) { char name[64]; sprintf_s(name, sizeof(name), "hello-string[%u]", pay->port); tcpcon_set_parameter( tcpcon, name, strlen(pay->payload_base64), pay->payload_base64); } } /* Loading Loading @@ -1454,6 +1466,7 @@ int main(int argc, char *argv[]) */ { int x = 0; x += base64_selftest(); x += banner1_selftest(); x += output_selftest(); x += siphash24_selftest(); Loading
src/masscan.h +7 −0 Original line number Diff line number Diff line Loading @@ -39,6 +39,12 @@ enum OutpuFormat { }; struct TcpCfgPayloads { char *payload_base64; unsigned port; struct TcpCfgPayloads *next; }; struct Masscan { Loading Loading @@ -170,6 +176,7 @@ struct Masscan } tcb; struct NmapPayloads *payloads; struct TcpCfgPayloads *tcp_payloads; unsigned char *http_user_agent; unsigned http_user_agent_length; Loading
src/proto-banner1.c +11 −11 Original line number Diff line number Diff line Loading @@ -175,17 +175,17 @@ banner1_create(void) b->tcp_payloads[80] = &banner_http; b->tcp_payloads[8080] = &banner_http; b->tcp_payloads[443] = &banner_ssl; /* HTTP/s */ b->tcp_payloads[465] = &banner_ssl; /* SMTP/s */ b->tcp_payloads[990] = &banner_ssl; /* FTP/s */ b->tcp_payloads[993] = &banner_ssl; /* IMAP4/s */ b->tcp_payloads[995] = &banner_ssl; /* POP3/s */ b->tcp_payloads[2083] = &banner_ssl; /* cPanel - SSL */ b->tcp_payloads[2087] = &banner_ssl; /* WHM - SSL */ b->tcp_payloads[2096] = &banner_ssl; /* cPanel webmail - SSL */ b->tcp_payloads[8443] = &banner_ssl; /* Plesk Control Panel - SSL */ b->tcp_payloads[9050] = &banner_ssl; /* Tor */ b->tcp_payloads[8140] = &banner_ssl; /* puppet */ b->tcp_payloads[443] = (void*)&banner_ssl; /* HTTP/s */ b->tcp_payloads[465] = (void*)&banner_ssl; /* SMTP/s */ b->tcp_payloads[990] = (void*)&banner_ssl; /* FTP/s */ b->tcp_payloads[993] = (void*)&banner_ssl; /* IMAP4/s */ b->tcp_payloads[995] = (void*)&banner_ssl; /* POP3/s */ b->tcp_payloads[2083] = (void*)&banner_ssl; /* cPanel - SSL */ b->tcp_payloads[2087] = (void*)&banner_ssl; /* WHM - SSL */ b->tcp_payloads[2096] = (void*)&banner_ssl; /* cPanel webmail - SSL */ b->tcp_payloads[8443] = (void*)&banner_ssl; /* Plesk Control Panel - SSL */ b->tcp_payloads[9050] = (void*)&banner_ssl; /* Tor */ b->tcp_payloads[8140] = (void*)&banner_ssl; /* puppet */ return b; Loading
src/proto-banner1.h +1 −3 Original line number Diff line number Diff line Loading @@ -12,12 +12,10 @@ struct Banner1 struct SMACK *http_fields; struct SMACK *html_fields; /*unsigned char *http_header; unsigned http_header_length;*/ unsigned is_capture_html:1; unsigned is_capture_cert:1; const struct ProtocolParserStream *tcp_payloads[65536]; struct ProtocolParserStream *tcp_payloads[65536]; }; struct SSL_SERVER_HELLO { Loading