frames: add --list-app-layer-frames option

Lists frames per ip proto and app-layer proto.

Ticket: #8174.
pull/14564/head
Victor Julien 7 months ago
parent df812b7a90
commit 7ac5d7428e

@ -47,6 +47,7 @@ typedef enum SCRunModes {
RUNMODE_LIST_APP_LAYERS,
RUNMODE_LIST_RULE_PROTOS,
RUNMODE_LIST_APP_LAYER_HOOKS,
RUNMODE_LIST_APP_LAYER_FRAMES,
RUNMODE_LIST_RUNMODES,
RUNMODE_PRINT_VERSION,
RUNMODE_PRINT_BUILDINFO,

@ -724,6 +724,8 @@ static void PrintUsage(const char *progname)
printf("\t--list-rule-protos : list supported rule protocols\n");
printf("\t--list-app-layer-hooks : list supported app layer hooks for use in "
"rules\n");
printf("\t--list-app-layer-frames : list supported app layer frames for use with "
"'frame' keyword\n");
printf("\t--dump-config : show the running configuration\n");
printf("\t--dump-features : display provided features\n");
printf("\t--build-info : display build information\n");
@ -1381,6 +1383,7 @@ TmEcode SCParseCommandLine(int argc, char **argv)
int list_app_layer_protocols = 0;
int list_rule_protocols = 0;
int list_app_layer_hooks = 0;
int list_app_layer_frames = 0;
int list_unittests = 0;
int list_runmodes = 0;
int list_keywords = 0;
@ -1431,6 +1434,7 @@ TmEcode SCParseCommandLine(int argc, char **argv)
{"list-app-layer-protos", 0, &list_app_layer_protocols, 1},
{"list-rule-protos", 0, &list_rule_protocols, 1},
{"list-app-layer-hooks", 0, &list_app_layer_hooks, 1},
{"list-app-layer-frames", 0, &list_app_layer_frames, 1},
{"list-unittests", 0, &list_unittests, 1},
{"list-runmodes", 0, &list_runmodes, 1},
{"list-keywords", optional_argument, &list_keywords, 1},
@ -2138,6 +2142,8 @@ TmEcode SCParseCommandLine(int argc, char **argv)
suri->run_mode = RUNMODE_LIST_RULE_PROTOS;
if (list_app_layer_hooks)
suri->run_mode = RUNMODE_LIST_APP_LAYER_HOOKS;
if (list_app_layer_frames)
suri->run_mode = RUNMODE_LIST_APP_LAYER_FRAMES;
if (list_keywords)
suri->run_mode = RUNMODE_LIST_KEYWORDS;
if (list_unittests)
@ -2426,6 +2432,12 @@ int SCStartInternalRunMode(int argc, char **argv)
} else {
return ListAppLayerHooks(DEFAULT_CONF_FILE);
}
case RUNMODE_LIST_APP_LAYER_FRAMES:
if (suri->conf_filename != NULL) {
return ListAppLayerFrames(suri->conf_filename);
} else {
return ListAppLayerFrames(DEFAULT_CONF_FILE);
}
case RUNMODE_PRINT_VERSION:
PrintVersion();
return TM_ECODE_DONE;

@ -129,3 +129,46 @@ int ListAppLayerHooks(const char *conf_filename)
}
return TM_ECODE_DONE;
}
int ListAppLayerFrames(const char *conf_filename)
{
EngineModeSetIDS();
if (SCConfYamlLoadFile(conf_filename) != -1)
SCLogLoadConfig(0, 0, 0, 0);
MpmTableSetup();
SpmTableSetup();
AppLayerSetup();
AppProto alprotos[g_alproto_max];
AppLayerProtoDetectSupportedAppProtocols(alprotos);
printf("=========Supported App Layer Frames=========\n");
for (AppProto a = 0; a < g_alproto_max; a++) {
if (alprotos[a] != 1)
continue;
const char *alproto_name = AppProtoToString(a);
if (strcmp(alproto_name, "http") == 0)
alproto_name = "http1";
SCLogDebug("alproto %u/%s", a, alproto_name);
bool tcp_stream_once = false;
for (uint32_t i = 0; i < 255; i++) {
const char *name = AppLayerParserGetFrameNameById(IPPROTO_TCP, a, (uint8_t)i);
if (name == NULL)
break;
if (!tcp_stream_once) {
printf("tcp: %s.stream\n", alproto_name);
tcp_stream_once = true;
}
printf("tcp: %s.%s\n", alproto_name, name);
}
for (uint32_t i = 0; i < 255; i++) {
const char *name = AppLayerParserGetFrameNameById(IPPROTO_UDP, a, (uint8_t)i);
if (name == NULL)
break;
printf("udp: %s.%s\n", alproto_name, name);
}
}
return TM_ECODE_DONE;
}

@ -27,5 +27,6 @@ int ListKeywords(const char *keyword_info);
int ListAppLayerProtocols(const char *conf_filename);
int ListRuleProtocols(const char *conf_filename);
int ListAppLayerHooks(const char *conf_filename);
int ListAppLayerFrames(const char *conf_filename);
#endif /* SURICATA_UTIL_RUNNING_MODES_H */

Loading…
Cancel
Save