]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
protodetect: rerun probing parser if pattern matched
authorPhilippe Antoine <contact@catenacyber.fr>
Fri, 18 Sep 2020 12:44:40 +0000 (14:44 +0200)
committerVictor Julien <victor@inliniac.net>
Wed, 30 Sep 2020 13:02:45 +0000 (15:02 +0200)
If a pattern matches in the other direction, after
probing parser finished without finding a protocol,
we will rerun the probing parser, which will include
the newly protocol found by its pattern

src/app-layer-detect-proto.c

index 0ebaec2d1f23f00d89e2873b8bd4bf90d075727f..9c27e0703a38a9a6ab31141432a718c053e9a756 100644 (file)
@@ -1552,6 +1552,16 @@ AppProto AppLayerProtoDetectGetProto(AppLayerProtoDetectThreadCtx *tctx,
         if (pm_matches > 0) {
             alproto = pm_results[0];
 
+            // rerun probing parser for other direction if it is unknown
+            uint8_t reverse_dir = (direction & STREAM_TOSERVER) ? STREAM_TOCLIENT : STREAM_TOSERVER;
+            if (FLOW_IS_PP_DONE(f, reverse_dir)) {
+                AppProto rev_alproto =
+                        (direction & STREAM_TOSERVER) ? f->alproto_tc : f->alproto_ts;
+                if (rev_alproto == ALPROTO_UNKNOWN) {
+                    FLOW_RESET_PP_DONE(f, reverse_dir);
+                }
+            }
+
             /* HACK: if detected protocol is dcerpc/udp, we run PP as well
              * to avoid misdetecting DNS as DCERPC. */
             if (!(ipproto == IPPROTO_UDP && alproto == ALPROTO_DCERPC))