|
|
|
|
@ -37,7 +37,7 @@
|
|
|
|
|
/**
|
|
|
|
|
* \brief Regex for parsing our keyword options
|
|
|
|
|
*/
|
|
|
|
|
#define PARSE_REGEX "^\\s*(stor|retr|nlst|list|mlsd)\\s*$"
|
|
|
|
|
#define PARSE_REGEX "^\\s*(stor|appe|retr|nlst|list|mlsd)\\s*$"
|
|
|
|
|
static DetectParseRegex parse_regex;
|
|
|
|
|
|
|
|
|
|
/* Prototypes of functions registered in DetectFtpdataRegister below */
|
|
|
|
|
@ -143,6 +143,8 @@ static DetectFtpdataData *DetectFtpdataParse(const char *ftpcommandstr)
|
|
|
|
|
goto error;
|
|
|
|
|
if (!strcmp(arg1, "stor")) {
|
|
|
|
|
ftpcommandd->command = FTP_COMMAND_STOR;
|
|
|
|
|
} else if (!strcmp(arg1, "appe")) {
|
|
|
|
|
ftpcommandd->command = FTP_COMMAND_APPE;
|
|
|
|
|
} else if (!strcmp(arg1, "retr")) {
|
|
|
|
|
ftpcommandd->command = FTP_COMMAND_RETR;
|
|
|
|
|
} else if (!strcmp(arg1, "nlst")) {
|
|
|
|
|
@ -218,6 +220,11 @@ static int DetectFtpdataParseTest01(void)
|
|
|
|
|
FAIL_IF(!(ftpcommandd->command == FTP_COMMAND_STOR));
|
|
|
|
|
DetectFtpdataFree(NULL, ftpcommandd);
|
|
|
|
|
|
|
|
|
|
ftpcommandd = DetectFtpdataParse("appe");
|
|
|
|
|
FAIL_IF_NULL(ftpcommandd);
|
|
|
|
|
FAIL_IF(!(ftpcommandd->command == FTP_COMMAND_APPE));
|
|
|
|
|
DetectFtpdataFree(NULL, ftpcommandd);
|
|
|
|
|
|
|
|
|
|
ftpcommandd = DetectFtpdataParse("list");
|
|
|
|
|
FAIL_IF_NULL(ftpcommandd);
|
|
|
|
|
FAIL_IF(!(ftpcommandd->command == FTP_COMMAND_LIST));
|
|
|
|
|
@ -240,13 +247,16 @@ static int DetectFtpdataSignatureTest01(void)
|
|
|
|
|
sig = DetectEngineAppendSig(de_ctx, "alert ip any any -> any any (ftpdata_command:retr; sid:2; rev:1;)");
|
|
|
|
|
FAIL_IF_NULL(sig);
|
|
|
|
|
sig = DetectEngineAppendSig(
|
|
|
|
|
de_ctx, "alert ip any any -> any any (ftpdata_command:list; sid:3; rev:1;)");
|
|
|
|
|
de_ctx, "alert ip any any -> any any (ftpdata_command:appe; sid:3; rev:1;)");
|
|
|
|
|
FAIL_IF_NULL(sig);
|
|
|
|
|
sig = DetectEngineAppendSig(
|
|
|
|
|
de_ctx, "alert ip any any -> any any (ftpdata_command:list; sid:4; rev:1;)");
|
|
|
|
|
FAIL_IF_NULL(sig);
|
|
|
|
|
sig = DetectEngineAppendSig(
|
|
|
|
|
de_ctx, "alert ip any any -> any any (ftpdata_command:mlsd; sid:4; rev:1;)");
|
|
|
|
|
de_ctx, "alert ip any any -> any any (ftpdata_command:mlsd; sid:5; rev:1;)");
|
|
|
|
|
FAIL_IF_NULL(sig);
|
|
|
|
|
sig = DetectEngineAppendSig(
|
|
|
|
|
de_ctx, "alert ip any any -> any any (ftpdata_command:xxx; sid:5; rev:1;)");
|
|
|
|
|
de_ctx, "alert ip any any -> any any (ftpdata_command:xxx; sid:6; rev:1;)");
|
|
|
|
|
FAIL_IF_NOT_NULL(sig);
|
|
|
|
|
|
|
|
|
|
DetectEngineCtxFree(de_ctx);
|
|
|
|
|
|