From 6cc83f604df7add2ada50c57a15707d7d052ac48 Mon Sep 17 00:00:00 2001 From: Robert Graham Date: Sun, 11 Jun 2017 04:17:09 -0400 Subject: [PATCH] --noreset --- src/main-conf.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ src/main.c | 9 +++------ src/masscan.h | 1 + 3 files changed, 49 insertions(+), 6 deletions(-) diff --git a/src/main-conf.c b/src/main-conf.c index 6f4f110..f212aaf 100644 --- a/src/main-conf.c +++ b/src/main-conf.c @@ -302,6 +302,10 @@ masscan_echo(struct Masscan *masscan, FILE *fp) fprintf(fp, "shard = %u/%u\n", masscan->shard.one, masscan->shard.of); if (masscan->is_banners) fprintf(fp, "banners = true\n"); + if (masscan->is_arp) + fprintf(fp, "arp = true\n"); + if (masscan->is_noreset) + fprintf(fp, "noreset = true\n"); fprintf(fp, "# ADAPTER SETTINGS\n"); if (masscan->nic_count == 0) @@ -656,6 +660,41 @@ parseInt(const char *str) return result; } +static unsigned +parseBoolean(const char *str) +{ + if (str == NULL || str[0] == 0) + return 1; + if (isdigit(str[0])) { + if (strtoul(str,0,0) == 0) + return 0; + else + return 1; + } + switch (str[0]) { + case 't': + case 'T': + return 1; + case 'f': + case 'F': + return 0; + case 'o': + case 'O': + if (str[1] == 'f' || str[1] == 'F') + return 0; + else + return 1; + break; + case 'Y': + case 'y': + return 1; + case 'n': + case 'N': + return 0; + } + return 1; +} + /*************************************************************************** * Parses the number of seconds (for rotating files mostly). We do a little * more than just parse an integer. We support strings like: @@ -1058,6 +1097,11 @@ masscan_set_parameter(struct Masscan *masscan, masscan_set_parameter(masscan, "router-mac", "ff-ff-ff-ff-ff-ff"); masscan->is_arp = 1; /* needs additional flag */ LOG(5, "--arpscan\n"); + } else if (EQUALS("noreset", name)) { + if (value && value[0]) + masscan->is_noreset = parseBoolean(value); + else + masscan->is_noreset = 1; } else if (EQUALS("bpf", name)) { size_t len = strlen(value) + 1; if (masscan->bpf_filter) @@ -1700,6 +1744,7 @@ is_singleton(const char *name) "banners", "banner", "nobanners", "nobanner", "offline", "ping", "ping-sweep", "nobacktrace", "backtrace", "arp", "infinite", "nointeractive", "interactive", "status", "nostatus", + "arpscan", "noreset", "read-range", "read-ranges", "readrange", "read-ranges", 0}; size_t i; diff --git a/src/main.c b/src/main.c index 16b8ccc..b899141 100644 --- a/src/main.c +++ b/src/main.c @@ -400,7 +400,7 @@ infinite: port_me = src_port; } cookie = syn_cookie(ip_them, port_them, ip_me, port_me, entropy); -//printf("0x%08x 0x%08x 0x%04x 0x%08x 0x%04x \n", cookie, ip_them, port_them, ip_me, port_me); + /* * SEND THE PROBE * This is sorta the entire point of the program, but little @@ -471,8 +471,6 @@ infinite: * Wait until the receive thread realizes the scan is over */ LOG(1, "THREAD: xmit done, waiting for receive thread to realize this\n"); - /*while (!is_tx_done) - pixie_mssleep(1);*/ /* * We are done transmitting. However, response packets will take several @@ -758,8 +756,6 @@ receive_thread(void *v) /* verify: my IP address */ if (!is_my_ip(&parms->src, ip_me)) continue; -//printf("0x%08x 0x%08x 0x%04x 0x%08x 0x%04x \n", cookie, ip_them, port_them, ip_me, port_me); - /* * Handle non-TCP protocols @@ -943,6 +939,7 @@ receive_thread(void *v) if (dedup_is_duplicate(dedup, ip_them, port_them, ip_me, port_me)) continue; + /* keep statistics on number received */ if (TCP_IS_SYNACK(px, parsed.transport_offset)) (*status_synack_count)++; @@ -965,7 +962,7 @@ receive_thread(void *v) * Send RST so other side isn't left hanging (only doing this in * complete stateless mode where we aren't tracking banners) */ - if (tcpcon == NULL) + if (tcpcon == NULL && !masscan->is_noreset) tcp_send_RST( &parms->tmplset->pkts[Proto_TCP], parms->packet_buffers, diff --git a/src/masscan.h b/src/masscan.h index 4e498a0..038a75f 100644 --- a/src/masscan.h +++ b/src/masscan.h @@ -167,6 +167,7 @@ struct Masscan unsigned is_banners:1; /* --banners */ unsigned is_offline:1; /* --offline */ unsigned is_arp:1; /* --arp */ + unsigned is_noreset:1; /* --noreset */ unsigned is_gmt:1; /* --gmt, all times in GMT */ unsigned is_capture_cert:1; /* --capture cert */ unsigned is_capture_html:1; /* --capture html */ -- GitLab