Improvements for exporting info in MDNS and UBNTAC2 protocols
Added test pcap file for UBNTAC2
This commit is contained in:
@@ -387,7 +387,7 @@ static void printFlow(u_int16_t thread_id, struct ndpi_flow_info *flow) {
|
|||||||
flow->packets, (long long unsigned int) flow->bytes);
|
flow->packets, (long long unsigned int) flow->bytes);
|
||||||
|
|
||||||
if(flow->host_server_name[0] != '\0') fprintf(out, "[Host: %s]", flow->host_server_name);
|
if(flow->host_server_name[0] != '\0') fprintf(out, "[Host: %s]", flow->host_server_name);
|
||||||
|
if(flow->info[0] != '\0') fprintf(out, "[%s]", flow->info);
|
||||||
|
|
||||||
if(flow->ssh_ssl.client_info[0] != '\0') fprintf(out, "[client: %s]", flow->ssh_ssl.client_info);
|
if(flow->ssh_ssl.client_info[0] != '\0') fprintf(out, "[client: %s]", flow->ssh_ssl.client_info);
|
||||||
if(flow->ssh_ssl.server_info[0] != '\0') fprintf(out, "[server: %s]", flow->ssh_ssl.server_info);
|
if(flow->ssh_ssl.server_info[0] != '\0') fprintf(out, "[server: %s]", flow->ssh_ssl.server_info);
|
||||||
|
|||||||
@@ -516,6 +516,10 @@ static unsigned int packet_processing(struct ndpi_workflow * workflow,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(n == 0) flow->bittorent_hash[0] = '\0';
|
if(n == 0) flow->bittorent_hash[0] = '\0';
|
||||||
|
} else if(flow->detected_protocol.protocol == NDPI_PROTOCOL_MDNS) {
|
||||||
|
snprintf(flow->info, sizeof(flow->info), "%s", flow->ndpi_flow->protos.mdns.answer);
|
||||||
|
} else if(flow->detected_protocol.protocol == NDPI_PROTOCOL_UBNTAC2) {
|
||||||
|
snprintf(flow->info, sizeof(flow->info), "%s", flow->ndpi_flow->protos.ubntac2.version);
|
||||||
}
|
}
|
||||||
|
|
||||||
if((proto == IPPROTO_TCP) && (flow->detected_protocol.protocol != NDPI_PROTOCOL_DNS)) {
|
if((proto == IPPROTO_TCP) && (flow->detected_protocol.protocol != NDPI_PROTOCOL_DNS)) {
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ typedef struct ndpi_flow_info {
|
|||||||
// result only, not used for flow identification
|
// result only, not used for flow identification
|
||||||
ndpi_protocol detected_protocol;
|
ndpi_protocol detected_protocol;
|
||||||
|
|
||||||
|
char info[96];
|
||||||
char host_server_name[192];
|
char host_server_name[192];
|
||||||
char bittorent_hash[41];
|
char bittorent_hash[41];
|
||||||
|
|
||||||
|
|||||||
@@ -960,6 +960,14 @@ struct ndpi_flow_struct {
|
|||||||
struct {
|
struct {
|
||||||
char client_signature[48], server_signature[48];
|
char client_signature[48], server_signature[48];
|
||||||
} ssh;
|
} ssh;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
char answer[96];
|
||||||
|
} mdns;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
char version[96];
|
||||||
|
} ubntac2;
|
||||||
} protos;
|
} protos;
|
||||||
|
|
||||||
/*** ALL protocol specific 64 bit variables here ***/
|
/*** ALL protocol specific 64 bit variables here ***/
|
||||||
|
|||||||
@@ -64,12 +64,25 @@ static int ndpi_int_check_mdns_payload(struct ndpi_detection_module_struct
|
|||||||
|
|
||||||
NDPI_LOG(NDPI_PROTOCOL_MDNS, ndpi_struct, NDPI_LOG_DEBUG, "found MDNS with question query.\n");
|
NDPI_LOG(NDPI_PROTOCOL_MDNS, ndpi_struct, NDPI_LOG_DEBUG, "found MDNS with question query.\n");
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
else if((packet->payload[2] & 0x80) != 0 &&
|
else if((packet->payload[2] & 0x80) != 0 &&
|
||||||
ntohs(get_u_int16_t(packet->payload, 4)) == 0 &&
|
ntohs(get_u_int16_t(packet->payload, 4)) == 0 &&
|
||||||
ntohs(get_u_int16_t(packet->payload, 6)) <= NDPI_MAX_MDNS_REQUESTS &&
|
ntohs(get_u_int16_t(packet->payload, 6)) <= NDPI_MAX_MDNS_REQUESTS &&
|
||||||
ntohs(get_u_int16_t(packet->payload, 6)) != 0) {
|
ntohs(get_u_int16_t(packet->payload, 6)) != 0) {
|
||||||
|
char answer[256];
|
||||||
|
int i, j, len;
|
||||||
|
|
||||||
|
for(i=13, j=0; (packet->payload[i] != 0) && (i < packet->payload_packet_len) && (i < (sizeof(answer)-1)); i++)
|
||||||
|
answer[j++] = (packet->payload[i] < 13) ? '.' : packet->payload[i];
|
||||||
|
|
||||||
|
answer[j] = '\0';
|
||||||
|
|
||||||
|
/* printf("==> [%d] %s\n", j, answer); */
|
||||||
|
|
||||||
|
len = ndpi_min(sizeof(flow->protos.mdns.answer)-1, j);
|
||||||
|
strncpy(flow->protos.mdns.answer, (const char *)answer, len);
|
||||||
|
flow->protos.mdns.answer[len] = '\0';
|
||||||
|
|
||||||
NDPI_LOG(NDPI_PROTOCOL_MDNS, ndpi_struct, NDPI_LOG_DEBUG, "found MDNS with answer query.\n");
|
NDPI_LOG(NDPI_PROTOCOL_MDNS, ndpi_struct, NDPI_LOG_DEBUG, "found MDNS with answer query.\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -88,13 +101,11 @@ void ndpi_search_mdns(struct ndpi_detection_module_struct *ndpi_struct, struct n
|
|||||||
|
|
||||||
/* check if UDP packet */
|
/* check if UDP packet */
|
||||||
if(packet->udp != NULL) {
|
if(packet->udp != NULL) {
|
||||||
|
|
||||||
/* read destination port */
|
/* read destination port */
|
||||||
dport = ntohs(packet->udp->dest);
|
dport = ntohs(packet->udp->dest);
|
||||||
|
|
||||||
/* check standard MDNS ON port 5353 */
|
/* check standard MDNS ON port 5353 */
|
||||||
if(dport == 5353 && packet->payload_packet_len >= 12) {
|
if(dport == 5353 && packet->payload_packet_len >= 12) {
|
||||||
|
|
||||||
/* mdns protocol must have destination address 224.0.0.251 */
|
/* mdns protocol must have destination address 224.0.0.251 */
|
||||||
if(packet->iph != NULL && ntohl(packet->iph->daddr) == 0xe00000fb) {
|
if(packet->iph != NULL && ntohl(packet->iph->daddr) == 0xe00000fb) {
|
||||||
|
|
||||||
|
|||||||
@@ -37,12 +37,37 @@ void ndpi_search_ubntac2(struct ndpi_detection_module_struct *ndpi_struct, struc
|
|||||||
|
|
||||||
if(packet->udp) {
|
if(packet->udp) {
|
||||||
if(packet->payload_packet_len >= 135 &&
|
if(packet->payload_packet_len >= 135 &&
|
||||||
(packet->udp->source == htons(10001) || packet->udp->dest == htons(10001)) &&
|
(packet->udp->source == htons(10001) || packet->udp->dest == htons(10001))) {
|
||||||
memcmp(&(packet->payload[36]), "UBNT", 4) == 0) {
|
int found = 0;
|
||||||
|
|
||||||
NDPI_LOG(NDPI_PROTOCOL_UBNTAC2, ndpi_struct, NDPI_LOG_DEBUG, "UBNT AirControl 2 request\n");
|
if(memcmp(&(packet->payload[36]), "UBNT", 4) == 0) {
|
||||||
|
found = 36+5;
|
||||||
|
} else if(memcmp(&(packet->payload[49]), "ubnt", 4) == 0) {
|
||||||
|
found = 49+5;
|
||||||
|
}
|
||||||
|
|
||||||
ndpi_int_ubntac2_add_connection(ndpi_struct, flow);
|
if(found) {
|
||||||
|
char version[256];
|
||||||
|
int i, j, len;
|
||||||
|
|
||||||
|
found += packet->payload[found+1] + 4; /* Skip model name */
|
||||||
|
found++; /* Skip len*/
|
||||||
|
|
||||||
|
if(found < packet->payload_packet_len) {
|
||||||
|
for(i=found, j=0; (packet->payload[i] != 0) && (i < packet->payload_packet_len) && (i < (sizeof(version)-1)); i++)
|
||||||
|
version[j++] = packet->payload[i];
|
||||||
|
|
||||||
|
version[j] = '\0';
|
||||||
|
|
||||||
|
len = ndpi_min(sizeof(flow->protos.ubntac2.version)-1, j);
|
||||||
|
strncpy(flow->protos.ubntac2.version, (const char *)version, len);
|
||||||
|
flow->protos.ubntac2.version[len] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
NDPI_LOG(NDPI_PROTOCOL_UBNTAC2, ndpi_struct, NDPI_LOG_DEBUG, "UBNT AirControl 2 request\n");
|
||||||
|
|
||||||
|
ndpi_int_ubntac2_add_connection(ndpi_struct, flow);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
@@ -239,7 +239,7 @@ MS_OneDrive 348 181687 1
|
|||||||
226 TCP 192.168.1.34:51255 <-> 157.55.130.142:40005 [proto: 125/Skype][17 pkts/1322 bytes]
|
226 TCP 192.168.1.34:51255 <-> 157.55.130.142:40005 [proto: 125/Skype][17 pkts/1322 bytes]
|
||||||
227 UDP 239.255.255.250:1900 <-> 192.168.0.254:1025 [proto: 12/SSDP][36 pkts/13402 bytes]
|
227 UDP 239.255.255.250:1900 <-> 192.168.0.254:1025 [proto: 12/SSDP][36 pkts/13402 bytes]
|
||||||
228 TCP 192.168.1.34:51253 <-> 64.4.23.166:443 [proto: 91/SSL][14 pkts/1432 bytes]
|
228 TCP 192.168.1.34:51253 <-> 64.4.23.166:443 [proto: 91/SSL][14 pkts/1432 bytes]
|
||||||
229 UDP 192.168.1.92:5353 <-> 224.0.0.251:5353 [proto: 8/MDNS][1 pkts/142 bytes]
|
229 UDP 192.168.1.92:5353 <-> 224.0.0.251:5353 [proto: 8/MDNS][1 pkts/142 bytes][Lucas-iMac.local]
|
||||||
230 UDP 192.168.1.34:13021 <-> 64.4.23.145:40027 [proto: 125/Skype][1 pkts/73 bytes]
|
230 UDP 192.168.1.34:13021 <-> 64.4.23.145:40027 [proto: 125/Skype][1 pkts/73 bytes]
|
||||||
231 UDP 192.168.1.34:13021 <-> 64.4.23.142:40023 [proto: 125/Skype][1 pkts/72 bytes]
|
231 UDP 192.168.1.34:13021 <-> 64.4.23.142:40023 [proto: 125/Skype][1 pkts/72 bytes]
|
||||||
232 UDP 192.168.1.34:13021 <-> 64.4.23.140:40003 [proto: 125/Skype][1 pkts/67 bytes]
|
232 UDP 192.168.1.34:13021 <-> 64.4.23.140:40003 [proto: 125/Skype][1 pkts/67 bytes]
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
UBNTAC2 8 1736 8
|
||||||
|
|
||||||
|
1 UDP 192.168.1.1:42838 <-> 255.255.255.255:10001 [proto: 31/UBNTAC2][1 pkts/217 bytes][UniFiSecurityGateway.ER-e120.v4.3.33.4936086.161203.2031]
|
||||||
|
2 UDP 192.168.1.1:47746 <-> 255.255.255.255:10001 [proto: 31/UBNTAC2][1 pkts/217 bytes][UniFiSecurityGateway.ER-e120.v4.3.33.4936086.161203.2031]
|
||||||
|
3 UDP 192.168.1.1:52220 <-> 255.255.255.255:10001 [proto: 31/UBNTAC2][1 pkts/217 bytes][UniFiSecurityGateway.ER-e120.v4.3.33.4936086.161203.2031]
|
||||||
|
4 UDP 192.168.1.1:59772 <-> 255.255.255.255:10001 [proto: 31/UBNTAC2][1 pkts/217 bytes][UniFiSecurityGateway.ER-e120.v4.3.33.4936086.161203.2031]
|
||||||
|
5 UDP 192.168.1.1:34085 <-> 255.255.255.255:10001 [proto: 31/UBNTAC2][1 pkts/217 bytes][UniFiSecurityGateway.ER-e120.v4.3.33.4936086.161203.2031]
|
||||||
|
6 UDP 192.168.1.1:44641 <-> 255.255.255.255:10001 [proto: 31/UBNTAC2][1 pkts/217 bytes][UniFiSecurityGateway.ER-e120.v4.3.33.4936086.161203.2031]
|
||||||
|
7 UDP 192.168.1.1:47871 <-> 255.255.255.255:10001 [proto: 31/UBNTAC2][1 pkts/217 bytes][UniFiSecurityGateway.ER-e120.v4.3.33.4936086.161203.2031]
|
||||||
|
8 UDP 192.168.1.1:55321 <-> 255.255.255.255:10001 [proto: 31/UBNTAC2][1 pkts/217 bytes][UniFiSecurityGateway.ER-e120.v4.3.33.4936086.161203.2031]
|
||||||
Reference in New Issue
Block a user