Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/userguide/rules/differences-from-snort.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions doc/userguide/rules/intro.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 9 additions & 0 deletions etc/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -3980,6 +3980,9 @@
"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"
Expand Down Expand Up @@ -4141,6 +4144,9 @@
"description": "Number of flows for PostgreSQL protocol",
"type": "integer"
},
"pop3": {
"type": "integer"
},
"quic": {
"description": "Number of flows for QUIC protocol",
"type": "integer"
Expand Down Expand Up @@ -4270,6 +4276,9 @@
"pgsql": {
"type": "integer"
},
"pop3": {
"type": "integer"
},
"quic": {
"type": "integer"
},
Expand Down
13 changes: 11 additions & 2 deletions src/app-layer-ftp.c
Original file line number Diff line number Diff line change
Expand Up @@ -951,6 +951,15 @@ static int FTPGetAlstateProgress(void *vtx, uint8_t direction)
return FTP_STATE_FINISHED;
}

static AppProto FTPUserProbingParser(
Flow *f, uint8_t direction, const uint8_t *input, uint32_t len, uint8_t *rdir)
{
if (f->alproto_tc == ALPROTO_POP3) {
// POP traffic begins by same "USER" pattern as FTP
return ALPROTO_FAILED;
}
return ALPROTO_FTP;
}

static int FTPRegisterPatternsForProtocolDetection(void)
{
Expand All @@ -962,8 +971,8 @@ static int FTPRegisterPatternsForProtocolDetection(void)
IPPROTO_TCP, ALPROTO_FTP, "FEAT", 4, 0, STREAM_TOSERVER) < 0) {
return -1;
}
if (AppLayerProtoDetectPMRegisterPatternCI(
IPPROTO_TCP, ALPROTO_FTP, "USER ", 5, 0, STREAM_TOSERVER) < 0) {
if (AppLayerProtoDetectPMRegisterPatternCSwPP(IPPROTO_TCP, ALPROTO_FTP, "USER ", 5, 0,
STREAM_TOSERVER, FTPUserProbingParser, 5, 5) < 0) {
return -1;
}
if (AppLayerProtoDetectPMRegisterPatternCI(
Expand Down
14 changes: 12 additions & 2 deletions src/app-layer-parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions src/app-layer-protos.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/app-layer-protos.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions src/output.c
Original file line number Diff line number Diff line change
Expand Up @@ -1144,6 +1144,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
Expand Down
2 changes: 2 additions & 0 deletions suricata.yaml.in
Original file line number Diff line number Diff line change
Expand Up @@ -985,6 +985,8 @@ app-layer:
content-inspect-window: 4096
imap:
enabled: detection-only
pop3:
enabled: detection-only
smb:
enabled: yes
detection-ports:
Expand Down