Skip to content

Commit

Permalink
--noreset
Browse files Browse the repository at this point in the history
  • Loading branch information
robertdavidgraham committed Jun 11, 2017
1 parent 2d98c53 commit 6cc83f6
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 6 deletions.
45 changes: 45 additions & 0 deletions src/main-conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down
9 changes: 3 additions & 6 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ transmit_thread(void *v) /*aka. scanning_thread() */
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
Expand Down Expand Up @@ -471,8 +471,6 @@ transmit_thread(void *v) /*aka. scanning_thread() */
* 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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)++;

Expand All @@ -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,
Expand Down
1 change: 1 addition & 0 deletions src/masscan.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down

0 comments on commit 6cc83f6

Please sign in to comment.