aboutsummaryrefslogtreecommitdiff
path: root/src/lib/protocols/smb.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/protocols/smb.c')
-rw-r--r--src/lib/protocols/smb.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/lib/protocols/smb.c b/src/lib/protocols/smb.c
index 71305cd13..de83519f7 100644
--- a/src/lib/protocols/smb.c
+++ b/src/lib/protocols/smb.c
@@ -33,18 +33,23 @@ void ndpi_search_smb_tcp(struct ndpi_detection_module_struct *ndpi_struct, struc
/* Check connection over TCP */
if(packet->tcp) {
+ u_int16_t fourfourfive = htons(445);
- if(packet->tcp->dest == htons(445)
+ if(((packet->tcp->dest == fourfourfive) || (packet->tcp->source == fourfourfive))
&& packet->payload_packet_len > (32 + 4 + 4)
&& (packet->payload_packet_len - 4) == ntohl(get_u_int32_t(packet->payload, 0))
- && get_u_int32_t(packet->payload, 4) == htonl(0xff534d42)) {
-
+ ) {
+ u_int8_t smbv1[] = { 0xff, 0x53, 0x4d, 0x42 };
+
NDPI_LOG_INFO(ndpi_struct, "found SMB\n");
- if(packet->payload[8] == 0x72)
- ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_SMBV1, NDPI_PROTOCOL_UNKNOWN);
- else
+ if(memcmp(&packet->payload[4], smbv1, sizeof(smbv1)) == 0) {
+ if(packet->payload[8] != 0x72) /* Skip Negotiate request */ {
+ ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_SMBV1, NDPI_PROTOCOL_UNKNOWN);
+ }
+ } else
ndpi_set_detected_protocol(ndpi_struct, flow, NDPI_PROTOCOL_SMBV23, NDPI_PROTOCOL_UNKNOWN);
+
return;
}
}
@@ -65,4 +70,3 @@ void init_smb_dissector(struct ndpi_detection_module_struct *ndpi_struct, u_int3
*id += 1;
}
-