Skip to content

Commit

Permalink
fix for robertdavidgraham#526 now supports --output-format hostonly
Browse files Browse the repository at this point in the history
  • Loading branch information
robertdavidgraham committed Jan 14, 2021
1 parent 014dc29 commit 35cdc2a
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/main-conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -1247,6 +1247,7 @@ static int SET_output_format(struct Masscan *masscan, const char *name, const ch
case Output_NDJSON: fprintf(fp, "output-format = ndjson\n"); break;
case Output_Certs: fprintf(fp, "output-format = certs\n"); break;
case Output_None: fprintf(fp, "output-format = none\n"); break;
case Output_Hostonly: fprintf(fp, "output-format = hostonly\n"); break;
case Output_Redis:
fprintf(fp, "output-format = redis\n");
fprintf(fp, "redis = %s %u\n",
Expand All @@ -1273,6 +1274,7 @@ static int SET_output_format(struct Masscan *masscan, const char *name, const ch
else if (EQUALS("certs", value)) x = Output_Certs;
else if (EQUALS("none", value)) x = Output_None;
else if (EQUALS("redis", value)) x = Output_Redis;
else if (EQUALS("hostonly", value)) x = Output_Hostonly;
else {
LOG(0, "FAIL: unknown output-format: %s\n", value);
LOG(0, " hint: 'binary', 'xml', 'grepable', ...\n");
Expand Down Expand Up @@ -2686,6 +2688,9 @@ masscan_command_line(struct Masscan *masscan, int argc, char *argv[])
case 'U':
masscan_set_parameter(masscan, "output-format", "unicornscan");
break;
case 'H':
masscan_set_parameter(masscan, "output-format", "hostonly");
break;
default:
fprintf(stderr, "nmap(%s): unknown output format\n", argv[i]);
exit(1);
Expand Down Expand Up @@ -2864,7 +2869,7 @@ masscan_command_line(struct Masscan *masscan, int argc, char *argv[])
fprintf(stderr, "[-] WARNING: the shard number must be less than the total shard count: %u/%u\n",
masscan->shard.one, masscan->shard.of);
}
if (masscan->shard.of && masscan->seed == 0) {
if (masscan->shard.of > 1 && masscan->seed == 0) {
fprintf(stderr, "[-] WARNING: --seed <num> is not specified\n HINT: all shards must share the same seed\n");
}
}
Expand Down
1 change: 1 addition & 0 deletions src/masscan.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ enum OutputFormat {
Output_Unicornscan = 0x0200, /* -oU, "unicornscan" */
Output_None = 0x0400,
Output_Certs = 0x0800,
Output_Hostonly = 0x1000, /* -oH, "hostonly" */
Output_All = 0xFFBF, /* not supported */
};

Expand Down
3 changes: 3 additions & 0 deletions src/output.c
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,9 @@ output_create(const struct Masscan *masscan, unsigned thread_index)
case Output_Redis:
out->funcs = &redis_output;
break;
case Output_Hostonly:
out->funcs = &hostonly_output;
break;
case Output_None:
out->funcs = &null_output;
break;
Expand Down
1 change: 1 addition & 0 deletions src/output.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ extern const struct OutputType certs_output;
extern const struct OutputType binary_output;
extern const struct OutputType null_output;
extern const struct OutputType redis_output;
extern const struct OutputType hostonly_output;
extern const struct OutputType grepable_output;

/**
Expand Down
1 change: 1 addition & 0 deletions vs10/masscan.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
<ClCompile Include="..\src\out-binary.c" />
<ClCompile Include="..\src\out-certs.c" />
<ClCompile Include="..\src\out-grepable.c" />
<ClCompile Include="..\src\out-hostonly.c" />
<ClCompile Include="..\src\out-json.c" />
<ClCompile Include="..\src\out-ndjson.c" />
<ClCompile Include="..\src\out-null.c" />
Expand Down
3 changes: 3 additions & 0 deletions vs10/masscan.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,9 @@
<ClCompile Include="..\src\massip-addr.c">
<Filter>Source Files\massip</Filter>
</ClCompile>
<ClCompile Include="..\src\out-hostonly.c">
<Filter>Source Files\output</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\src\proto-arp.h">
Expand Down

0 comments on commit 35cdc2a

Please sign in to comment.