Skip to content

Commit

Permalink
unicorn scan win32 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
robertdavidgraham committed Jul 11, 2014
1 parent 93a9c6c commit 1bb39e3
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/out-unicornscan.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@
#include "masscan-status.h"
#include "unusedparm.h"


#ifndef WIN32
#include <netdb.h>
#else
#include <WinSock2.h>
#endif
#include <ctype.h>

static char * tcp_services[65536];
Expand All @@ -21,6 +26,7 @@ static void init_tcp_services()

static char *tcp_service_name(int port)
{
#ifndef WIN32
int r;
struct servent result_buf;
struct servent *result;
Expand All @@ -33,6 +39,16 @@ static char *tcp_service_name(int port)
return "unknown";

return strdup(result_buf.s_name);
#else
struct servent *result;

result = getservbyport(htons((unsigned short)port), "tcp");

if (result == NULL)
return "unknown";

return _strdup(result->s_name);
#endif
}

static void
Expand All @@ -57,6 +73,7 @@ unicornscan_out_status(struct Output *out, FILE *fp, time_t timestamp,
{
UNUSEDPARM(reason);
UNUSEDPARM(out);
UNUSEDPARM(timestamp);

if (ip_proto == 6) {
fprintf(fp,"TCP open\t%16s[%5d]\t\tfrom %u.%u.%u.%u ttl %-3d\n",
Expand Down
1 change: 1 addition & 0 deletions vs10/masscan.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
<ClCompile Include="..\src\out-null.c" />
<ClCompile Include="..\src\out-redis.c" />
<ClCompile Include="..\src\out-text.c" />
<ClCompile Include="..\src\out-unicornscan.c" />
<ClCompile Include="..\src\out-xml.c" />
<ClCompile Include="..\src\pixie-backtrace.c" />
<ClCompile Include="..\src\pixie-file.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 @@ -249,6 +249,9 @@
<ClCompile Include="..\src\out-certs.c">
<Filter>Source Files\output</Filter>
</ClCompile>
<ClCompile Include="..\src\out-unicornscan.c">
<Filter>Source Files\output</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\src\proto-arp.h">
Expand Down

0 comments on commit 1bb39e3

Please sign in to comment.