Skip to content

Commit

Permalink
ftp: protocol detection avoiding FP on POP3
Browse files Browse the repository at this point in the history
  • Loading branch information
catenacyber committed Apr 18, 2024
1 parent 8985f35 commit 32f10e1
Showing 1 changed file with 11 additions and 2 deletions.
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

0 comments on commit 32f10e1

Please sign in to comment.