Skip to content

Commit b58a138

Browse files
--readscan ignores /etc/masscan
1 parent 387771c commit b58a138

File tree

3 files changed

+53
-3
lines changed

3 files changed

+53
-3
lines changed

src/main-conf.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1690,6 +1690,22 @@ masscan_read_config_file(struct Masscan *masscan, const char *filename)
16901690
}
16911691

16921692

1693+
1694+
/***************************************************************************
1695+
***************************************************************************/
1696+
int masscan_conf_contains(const char *x, int argc, char **argv)
1697+
{
1698+
int i;
1699+
1700+
for (i=0; i<argc; i++) {
1701+
if (strcmp(argv[i], x) == 0)
1702+
return 1;
1703+
}
1704+
1705+
return 0;
1706+
}
1707+
1708+
16931709
/***************************************************************************
16941710
***************************************************************************/
16951711
int
@@ -1717,6 +1733,18 @@ mainconf_selftest()
17171733

17181734
}
17191735

1736+
/* */
1737+
{
1738+
int argc = 6;
1739+
char *argv[] = { "foo", "bar", "-ddd", "--readscan", "xxx", "--something" };
1740+
1741+
if (masscan_conf_contains("--nothing", argc, argv))
1742+
return 1;
1743+
1744+
if (!masscan_conf_contains("--readscan", argc, argv))
1745+
return 1;
1746+
}
1747+
17201748
return 0;
17211749
}
17221750

src/main.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1250,7 +1250,7 @@ main_scan(struct Masscan *masscan)
12501250

12511251
status_print(&status, masscan->resume.index, range, rate,
12521252
total_tcbs, total_synacks, total_syns,
1253-
masscan->wait - (time(0) - now));
1253+
masscan->wait + 1 - (time(0) - now));
12541254

12551255
if (time(0) - now >= masscan->wait)
12561256
control_c_pressed_again = 1;
@@ -1315,6 +1315,13 @@ int main(int argc, char *argv[])
13151315
".");
13161316
masscan->is_capture_cert = 1;
13171317

1318+
/*
1319+
* Pre-parse the command-line
1320+
*/
1321+
if (masscan_conf_contains("--readscan", argc, argv)) {
1322+
masscan->is_readscan = 1;
1323+
}
1324+
13181325
/*
13191326
* On non-Windows systems, read the defaults from the file in
13201327
* the /etc directory. These defaults will contain things
@@ -1324,8 +1331,10 @@ int main(int argc, char *argv[])
13241331
* makes a mistake
13251332
*/
13261333
#if !defined(WIN32)
1327-
if (access("/etc/masscan/masscan.conf", 0) == 0) {
1328-
masscan_read_config_file(masscan, "/etc/masscan/masscan.conf");
1334+
if (!masscan->is_readscan) {
1335+
if (access("/etc/masscan/masscan.conf", 0) == 0) {
1336+
masscan_read_config_file(masscan, "/etc/masscan/masscan.conf");
1337+
}
13291338
}
13301339
#endif
13311340

src/masscan.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,11 @@ struct Masscan
193193
* by incrementing the seed
194194
*/
195195
unsigned is_infinite:1;
196+
197+
/**
198+
* --readscan
199+
*/
200+
unsigned is_readscan:1;
196201
};
197202

198203

@@ -203,6 +208,14 @@ void masscan_usage(void);
203208
void masscan_save_state(struct Masscan *masscan);
204209
void main_listscan(struct Masscan *masscan);
205210

211+
/**
212+
* Pre-scan the command-line looking for options that may affect how
213+
* previous options are handled. This is a bit of a kludge, really.
214+
*/
215+
int masscan_conf_contains(const char *x, int argc, char **argv);
216+
217+
218+
206219
int
207220
masscan_initialize_adapter(
208221
struct Masscan *masscan,

0 commit comments

Comments
 (0)