Added fix to harden quic detection and limit it to port 80/443 UDP

This commit is contained in:
Luca Deri
2015-05-20 09:27:04 +02:00
parent fd338a90c2
commit 8f3b8ff4df
3 changed files with 93 additions and 83 deletions
+7
View File
@@ -106,8 +106,14 @@ void ndpi_search_quic(struct ndpi_detection_module_struct *ndpi_struct, struct n
u_int ver_offs; u_int ver_offs;
if(packet->udp != NULL) { if(packet->udp != NULL) {
u_int16_t sport = ntohs(packet->udp->source), dport = ntohs(packet->udp->dest);
NDPI_LOG(NDPI_PROTOCOL_QUIC, ndpi_struct, NDPI_LOG_DEBUG, "calculating quic over udp.\n"); NDPI_LOG(NDPI_PROTOCOL_QUIC, ndpi_struct, NDPI_LOG_DEBUG, "calculating quic over udp.\n");
if(((packet->payload[0] & 0xF0) != 0)
|| (!(sport == 80 || dport == 80 || sport == 443 || dport == 443)))
goto exclude_quic;
// Settings without version. First check if PUBLIC FLAGS & SEQ bytes are 0x0. SEQ must be 1 at least. // Settings without version. First check if PUBLIC FLAGS & SEQ bytes are 0x0. SEQ must be 1 at least.
if ((packet->payload[0] == 0x00 && packet->payload[1] != 0x00) || ((packet->payload[0] & QUIC_NO_V_RES_RSV) == 0)) if ((packet->payload[0] == 0x00 && packet->payload[1] != 0x00) || ((packet->payload[0] & QUIC_NO_V_RES_RSV) == 0))
{ {
@@ -148,6 +154,7 @@ void ndpi_search_quic(struct ndpi_detection_module_struct *ndpi_struct, struct n
} }
} else } else
{ {
exclude_quic:
NDPI_LOG(NDPI_PROTOCOL_QUIC, ndpi_struct, NDPI_LOG_DEBUG, "exclude quic.\n"); NDPI_LOG(NDPI_PROTOCOL_QUIC, ndpi_struct, NDPI_LOG_DEBUG, "exclude quic.\n");
NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_QUIC); NDPI_ADD_PROTOCOL_TO_BITMASK(flow->excluded_protocol_bitmask, NDPI_PROTOCOL_QUIC);
} }
+4 -1
View File
@@ -15,13 +15,16 @@ build_results() {
check_results() { check_results() {
for f in $PCAPS; do for f in $PCAPS; do
if [ -f result/$f.out ]; then if [ -f result/$f.out ]; then
$READER -q -i pcap/$f -w /tmp/reader.out CMD="$READER -q -i pcap/$f -w /tmp/reader.out"
$CMD
NUM_DIFF=`diff result/$f.out /tmp/reader.out | wc -l` NUM_DIFF=`diff result/$f.out /tmp/reader.out | wc -l`
if [ $NUM_DIFF -eq 0 ]; then if [ $NUM_DIFF -eq 0 ]; then
echo "$f\t OK" echo "$f\t OK"
else else
echo "$f\t ERROR" echo "$f\t ERROR"
echo "$CMD"
diff result/$f.out /tmp/reader.out
fi fi
/bin/rm /tmp/reader.out /bin/rm /tmp/reader.out
+1 -1
View File
@@ -1 +1 @@
Unknown 413 254874 1 Quic 413 254874 1