Loading src/in-binary.c +17 −2 Changes for src/in-binary.c: 17 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ struct MasscanRecord { unsigned short port; unsigned char reason; unsigned char ttl; unsigned char mac[6]; enum ApplicationProtocol app_proto; }; Loading @@ -47,6 +48,12 @@ parse_status(struct Output *out, record.reason = buf[10]; record.ttl = buf[11]; /* if ARP, then there will be a MAC address */ if (record.ip == 0 && buf_length >= 12+6) memcpy(record.mac, buf+12, 6); else memset(record.mac, 0, 6); if (out->when_scan_started == 0) out->when_scan_started = record.timestamp; Loading Loading @@ -77,7 +84,8 @@ parse_status(struct Output *out, record.ip_proto, record.port, record.reason, record.ttl); record.ttl, record.mac); } Loading @@ -103,6 +111,12 @@ parse_status2(struct Output *out, record.reason = buf[11]; record.ttl = buf[12]; /* if ARP, then there will be a MAC address */ if (record.ip == 0 && buf_length >= 13+6) memcpy(record.mac, buf+13, 6); else memset(record.mac, 0, 6); if (out->when_scan_started == 0) out->when_scan_started = record.timestamp; Loading @@ -128,7 +142,8 @@ parse_status2(struct Output *out, record.ip_proto, record.port, record.reason, record.ttl); record.ttl, record.mac); } Loading src/main.c +3 −1 Changes for src/main.c: 3 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -912,6 +912,7 @@ receive_thread(void *v) if (TCP_IS_SYNACK(px, parsed.transport_offset) || TCP_IS_RST(px, parsed.transport_offset)) { /* figure out the status */ status = PortStatus_Unknown; if (TCP_IS_SYNACK(px, parsed.transport_offset)) Loading Loading @@ -947,7 +948,8 @@ receive_thread(void *v) 6, /* ip proto = tcp */ port_them, px[parsed.transport_offset + 13], /* tcp flags */ parsed.ip_ttl parsed.ip_ttl, parsed.mac_src ); /* Loading src/output.c +47 −2 Changes for src/output.c: 47 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -651,11 +651,39 @@ is_rotate_time(const struct Output *out, time_t now, FILE *fp) if (now >= out->rotate.next) return 1; if (out->rotate.filesize != 0 && ftell_x(fp) >= out->rotate.filesize) ftell_x(fp) >= (int64_t)out->rotate.filesize) return 1; return 0; } /*************************************************************************** * Return the vendor/OUI string matchng the first three bytes of a * MAC address. * TODO: this should be read in from a file ***************************************************************************/ static const char * oui_from_mac(const unsigned char mac[6]) { unsigned oui = mac[0]<<16 | mac[1]<<8 | mac[2]; switch (oui) { case 0x94dbc9: return "Azurewave"; case 0x404a03: return "Zyxel"; case 0x000c29: return "VMware"; case 0x002590: return "Supermicro"; case 0xc0c1c0: return "Cisco-Linksys"; case 0x2c27d7: return "HP"; case 0x001132: return "Synology"; case 0x0022b0: return "D-Link"; case 0x0001c0: return "Compulab"; case 0x00236c: return "Apple"; case 0x0016cb: return "Apple"; case 0x08cc68: return "Cisco"; case 0x022618: return "Asustek"; /* */ default: return ""; } } /*************************************************************************** * Report simply "open" or "closed", with little additional information. Loading @@ -664,7 +692,8 @@ is_rotate_time(const struct Output *out, time_t now, FILE *fp) ***************************************************************************/ void output_report_status(struct Output *out, time_t timestamp, int status, unsigned ip, unsigned ip_proto, unsigned port, unsigned reason, unsigned ttl) unsigned ip, unsigned ip_proto, unsigned port, unsigned reason, unsigned ttl, const unsigned char mac[6]) { FILE *fp = out->fp; time_t now = time(0); Loading @@ -683,6 +712,21 @@ output_report_status(struct Output *out, time_t timestamp, int status, if (out->is_interactive || out->format == 0 || out->format == Output_Interactive) { unsigned count; switch (ip_proto) { case 0: /* ARP */ count = fprintf(stdout, "Discovered %s port %u/%s on %u.%u.%u.%u (%02x:%02x:%02x:%02x:%02x:%02x) %s", status_string(status), port, name_from_ip_proto(ip_proto), (ip>>24)&0xFF, (ip>>16)&0xFF, (ip>> 8)&0xFF, (ip>> 0)&0xFF, mac[0], mac[1], mac[2], mac[3], mac[4], mac[5], oui_from_mac(mac) ); break; default: count = fprintf(stdout, "Discovered %s port %u/%s on %u.%u.%u.%u", status_string(status), port, Loading @@ -692,6 +736,7 @@ output_report_status(struct Output *out, time_t timestamp, int status, (ip>> 8)&0xFF, (ip>> 0)&0xFF ); } /* Because this line may overwrite the "%done" status line, print * some spaces afterward to completely cover up the line */ Loading src/output.h +2 −1 Changes for src/output.h: 2 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -149,7 +149,8 @@ output_create(const struct Masscan *masscan, unsigned thread_index); void output_destroy(struct Output *output); void output_report_status(struct Output *output, time_t timestamp, int status, unsigned ip, unsigned ip_proto, unsigned port, unsigned reason, unsigned ttl); int status, unsigned ip, unsigned ip_proto, unsigned port, unsigned reason, unsigned ttl, const unsigned char mac[6]); typedef void (*OUTPUT_REPORT_BANNER)( Loading src/proto-arp.c +2 −1 Changes for src/proto-arp.c: 2 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -37,6 +37,7 @@ handle_arp(struct Output *out, time_t timestamp, const unsigned char *px, 0, /* ip proto */ 0, 0, 0); 0, parsed->mac_src); } Loading
src/in-binary.c +17 −2 Changes for src/in-binary.c: 17 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -24,6 +24,7 @@ struct MasscanRecord { unsigned short port; unsigned char reason; unsigned char ttl; unsigned char mac[6]; enum ApplicationProtocol app_proto; }; Loading @@ -47,6 +48,12 @@ parse_status(struct Output *out, record.reason = buf[10]; record.ttl = buf[11]; /* if ARP, then there will be a MAC address */ if (record.ip == 0 && buf_length >= 12+6) memcpy(record.mac, buf+12, 6); else memset(record.mac, 0, 6); if (out->when_scan_started == 0) out->when_scan_started = record.timestamp; Loading Loading @@ -77,7 +84,8 @@ parse_status(struct Output *out, record.ip_proto, record.port, record.reason, record.ttl); record.ttl, record.mac); } Loading @@ -103,6 +111,12 @@ parse_status2(struct Output *out, record.reason = buf[11]; record.ttl = buf[12]; /* if ARP, then there will be a MAC address */ if (record.ip == 0 && buf_length >= 13+6) memcpy(record.mac, buf+13, 6); else memset(record.mac, 0, 6); if (out->when_scan_started == 0) out->when_scan_started = record.timestamp; Loading @@ -128,7 +142,8 @@ parse_status2(struct Output *out, record.ip_proto, record.port, record.reason, record.ttl); record.ttl, record.mac); } Loading
src/main.c +3 −1 Changes for src/main.c: 3 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -912,6 +912,7 @@ receive_thread(void *v) if (TCP_IS_SYNACK(px, parsed.transport_offset) || TCP_IS_RST(px, parsed.transport_offset)) { /* figure out the status */ status = PortStatus_Unknown; if (TCP_IS_SYNACK(px, parsed.transport_offset)) Loading Loading @@ -947,7 +948,8 @@ receive_thread(void *v) 6, /* ip proto = tcp */ port_them, px[parsed.transport_offset + 13], /* tcp flags */ parsed.ip_ttl parsed.ip_ttl, parsed.mac_src ); /* Loading
src/output.c +47 −2 Changes for src/output.c: 47 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -651,11 +651,39 @@ is_rotate_time(const struct Output *out, time_t now, FILE *fp) if (now >= out->rotate.next) return 1; if (out->rotate.filesize != 0 && ftell_x(fp) >= out->rotate.filesize) ftell_x(fp) >= (int64_t)out->rotate.filesize) return 1; return 0; } /*************************************************************************** * Return the vendor/OUI string matchng the first three bytes of a * MAC address. * TODO: this should be read in from a file ***************************************************************************/ static const char * oui_from_mac(const unsigned char mac[6]) { unsigned oui = mac[0]<<16 | mac[1]<<8 | mac[2]; switch (oui) { case 0x94dbc9: return "Azurewave"; case 0x404a03: return "Zyxel"; case 0x000c29: return "VMware"; case 0x002590: return "Supermicro"; case 0xc0c1c0: return "Cisco-Linksys"; case 0x2c27d7: return "HP"; case 0x001132: return "Synology"; case 0x0022b0: return "D-Link"; case 0x0001c0: return "Compulab"; case 0x00236c: return "Apple"; case 0x0016cb: return "Apple"; case 0x08cc68: return "Cisco"; case 0x022618: return "Asustek"; /* */ default: return ""; } } /*************************************************************************** * Report simply "open" or "closed", with little additional information. Loading @@ -664,7 +692,8 @@ is_rotate_time(const struct Output *out, time_t now, FILE *fp) ***************************************************************************/ void output_report_status(struct Output *out, time_t timestamp, int status, unsigned ip, unsigned ip_proto, unsigned port, unsigned reason, unsigned ttl) unsigned ip, unsigned ip_proto, unsigned port, unsigned reason, unsigned ttl, const unsigned char mac[6]) { FILE *fp = out->fp; time_t now = time(0); Loading @@ -683,6 +712,21 @@ output_report_status(struct Output *out, time_t timestamp, int status, if (out->is_interactive || out->format == 0 || out->format == Output_Interactive) { unsigned count; switch (ip_proto) { case 0: /* ARP */ count = fprintf(stdout, "Discovered %s port %u/%s on %u.%u.%u.%u (%02x:%02x:%02x:%02x:%02x:%02x) %s", status_string(status), port, name_from_ip_proto(ip_proto), (ip>>24)&0xFF, (ip>>16)&0xFF, (ip>> 8)&0xFF, (ip>> 0)&0xFF, mac[0], mac[1], mac[2], mac[3], mac[4], mac[5], oui_from_mac(mac) ); break; default: count = fprintf(stdout, "Discovered %s port %u/%s on %u.%u.%u.%u", status_string(status), port, Loading @@ -692,6 +736,7 @@ output_report_status(struct Output *out, time_t timestamp, int status, (ip>> 8)&0xFF, (ip>> 0)&0xFF ); } /* Because this line may overwrite the "%done" status line, print * some spaces afterward to completely cover up the line */ Loading
src/output.h +2 −1 Changes for src/output.h: 2 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -149,7 +149,8 @@ output_create(const struct Masscan *masscan, unsigned thread_index); void output_destroy(struct Output *output); void output_report_status(struct Output *output, time_t timestamp, int status, unsigned ip, unsigned ip_proto, unsigned port, unsigned reason, unsigned ttl); int status, unsigned ip, unsigned ip_proto, unsigned port, unsigned reason, unsigned ttl, const unsigned char mac[6]); typedef void (*OUTPUT_REPORT_BANNER)( Loading
src/proto-arp.c +2 −1 Changes for src/proto-arp.c: 2 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -37,6 +37,7 @@ handle_arp(struct Output *out, time_t timestamp, const unsigned char *px, 0, /* ip proto */ 0, 0, 0); 0, parsed->mac_src); }