]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
pop3: protocol detection
authorPhilippe Antoine <pantoine@oisf.net>
Thu, 2 Feb 2023 10:12:08 +0000 (11:12 +0100)
committerVictor Julien <victor@inliniac.net>
Thu, 16 May 2024 17:58:33 +0000 (19:58 +0200)
Ticket: #6366

doc/userguide/rules/differences-from-snort.rst
doc/userguide/rules/intro.rst
etc/schema.json
src/app-layer-parser.c
src/app-layer-protos.c
src/app-layer-protos.h
src/output.c
suricata.yaml.in

index 9ca145c5e238ae317ab386ffc9425a2cb53fe382..a32966c4284b7868b9f28ffc8693aa8aacb75fb4 100644 (file)
@@ -19,6 +19,7 @@ Automatic Protocol Detection
    -  dns
    -  http
    -  imap (detection only by default; no parsing)
+   -  pop3 (detection only by default; no parsing)
    -  ftp
    -  modbus (disabled by default; minimalist probe parser; can lead to false positives)
    -  smb
index 41f7fe0b8327ce55b78b0c05b5115546fb079fef..56df9ab494378b09974171ec7df74027fd90a272 100644 (file)
@@ -96,6 +96,7 @@ you can pick from. These are:
 * ssh
 * smtp
 * imap
+* pop3
 * modbus (disabled by default)
 * dnp3 (disabled by default)
 * enip (disabled by default)
index d2af1037ae53864e27616f236b8d493e40458818..77597135ee38702db5ce280e94fd234979124afc 100644 (file)
                                     "description": "Errors encountered parsing PostgreSQL protocol",
                                     "$ref": "#/$defs/stats_applayer_error"
                                 },
+                                "pop3": {
+                                    "$ref": "#/$defs/stats_applayer_error"
+                                },
                                 "quic": {
                                     "description": "Errors encountered parsing QUIC protocol",
                                     "$ref": "#/$defs/stats_applayer_error"
                                     "description": "Number of flows for PostgreSQL protocol",
                                     "type": "integer"
                                 },
+                                "pop3": {
+                                    "type": "integer"
+                                },
                                 "quic": {
                                     "description": "Number of flows for QUIC protocol",
                                     "type": "integer"
                                     "description": "Number of transactions for PostgreSQL protocol",
                                     "type": "integer"
                                 },
+                                "pop3": {
+                                    "type": "integer"
+                                },
                                 "quic": {
                                     "description": "Number of transactions for QUIC protocol",
                                     "type": "integer"
index 895d4355f9202e2ccc2bbe72cbed2a6f901c68dd..90923d0c9d4d904c5e6a0277fb488ab249845964 100644 (file)
@@ -1763,14 +1763,24 @@ void AppLayerParserRegisterProtocolParsers(void)
         if (AppLayerProtoDetectPMRegisterPatternCS(IPPROTO_TCP, ALPROTO_IMAP,
                                   "1|20|capability", 12, 0, STREAM_TOSERVER) < 0)
         {
-            SCLogInfo("imap proto registration failure");
-            exit(EXIT_FAILURE);
+            FatalError("imap proto registration failure");
         }
     } else {
         SCLogInfo("Protocol detection and parser disabled for %s protocol.",
                   "imap");
     }
 
+    /** POP3 */
+    AppLayerProtoDetectRegisterProtocol(ALPROTO_POP3, "pop3");
+    if (AppLayerProtoDetectConfProtoDetectionEnabled("tcp", "pop3")) {
+        if (AppLayerProtoDetectPMRegisterPatternCS(
+                    IPPROTO_TCP, ALPROTO_POP3, "+OK ", 4, 0, STREAM_TOCLIENT) < 0) {
+            FatalError("pop3 proto registration failure");
+        }
+    } else {
+        SCLogInfo("Protocol detection and parser disabled for pop3 protocol.");
+    }
+
     ValidateParsers();
     return;
 }
index b6e1b73d08d4abe4c2d937648efe6bbd5dd012db..babe6ea83adf38dfe75e579e44fc915c83d4e4ad 100644 (file)
@@ -65,6 +65,7 @@ const AppProtoStringTuple AppProtoStrings[ALPROTO_MAX] = {
     { ALPROTO_RDP, "rdp" },
     { ALPROTO_HTTP2, "http2" },
     { ALPROTO_BITTORRENT_DHT, "bittorrent-dht" },
+    { ALPROTO_POP3, "pop3" },
     { ALPROTO_HTTP, "http" },
     { ALPROTO_FAILED, "failed" },
 #ifdef UNITTESTS
index 5c27255a7b46f46590ca2f25af268441aee640ba..00a5a54811e87dee05a6a41c0994ec266ab27c87 100644 (file)
@@ -61,6 +61,7 @@ enum AppProtoEnum {
     ALPROTO_RDP,
     ALPROTO_HTTP2,
     ALPROTO_BITTORRENT_DHT,
+    ALPROTO_POP3,
 
     // signature-only (ie not seen in flow)
     // HTTP for any version (ALPROTO_HTTP1 (version 1) or ALPROTO_HTTP2)
index 0661854d22cd3f413ce0faeef75b255e1bcafd74..22030861386543c3080b258d1574281cc549bdab 100644 (file)
@@ -1147,6 +1147,7 @@ static EveJsonSimpleAppLayerLogger simple_json_applayer_loggers[ALPROTO_MAX] = {
     { ALPROTO_RDP, (EveJsonSimpleTxLogFunc)rs_rdp_to_json },
     { ALPROTO_HTTP2, rs_http2_log_json },
     { ALPROTO_BITTORRENT_DHT, rs_bittorrent_dht_logger_log },
+    { ALPROTO_POP3, NULL }, // protocol detection only
     { ALPROTO_HTTP, NULL }, // signature protocol, not for app-layer logging
     { ALPROTO_FAILED, NULL },
 #ifdef UNITTESTS
index 414f12f7eadaacbbf3e7ed242f138e1542d48e72..6c4fbe38230d62a08bd13563c861a2b7d5e58089 100644 (file)
@@ -987,6 +987,8 @@ app-layer:
         content-inspect-window: 4096
     imap:
       enabled: detection-only
+    pop3:
+      enabled: detection-only
     smb:
       enabled: yes
       detection-ports: