aboutsummaryrefslogtreecommitdiff
path: root/src/lib/ndpi_main.c
diff options
context:
space:
mode:
authorToni Uhlig <matzeton@googlemail.com>2024-04-07 21:50:20 +0200
committerToni Uhlig <matzeton@googlemail.com>2024-04-09 07:47:24 +0200
commitab27b2a1fb786f68397cdcaa2ab37b8495578c1a (patch)
tree9ce872ff8a879e43a2cb4026844a487e8a0f2baf /src/lib/ndpi_main.c
parentf5905a62c7fc1922d0b49e9399d56e8cfee69516 (diff)
Add Shellscript risk detection.add/shellscript-risk-detection
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
Diffstat (limited to 'src/lib/ndpi_main.c')
-rw-r--r--src/lib/ndpi_main.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/lib/ndpi_main.c b/src/lib/ndpi_main.c
index e0150fe6c..acdae12fe 100644
--- a/src/lib/ndpi_main.c
+++ b/src/lib/ndpi_main.c
@@ -8160,6 +8160,29 @@ static int ndpi_is_ntop_protocol(ndpi_protocol *ret) {
/* ********************************************************************************* */
+static void ndpi_search_shellscript(struct ndpi_detection_module_struct *ndpi_struct,
+ struct ndpi_flow_struct *flow)
+{
+ struct ndpi_packet_struct const * const packet = &ndpi_struct->packet;
+
+ NDPI_LOG_DBG(ndpi_struct, "search Shellscript\n");
+
+ if (packet->payload_packet_len < 3)
+ {
+ return;
+ }
+
+ if (packet->payload[0] != '#' ||
+ packet->payload[1] != '!' ||
+ (packet->payload[2] != '/' && packet->payload[2] != ' '))
+ {
+ return;
+ }
+
+ NDPI_LOG_INFO(ndpi_struct, "found Shellscript\n");
+ ndpi_set_risk(flow, NDPI_POSSIBLE_EXPLOIT, "Shellscript found");
+}
+
/* ELF format specs: https://man7.org/linux/man-pages/man5/elf.5.html */
static void ndpi_search_elf(struct ndpi_detection_module_struct *ndpi_struct,
struct ndpi_flow_struct *flow)
@@ -8620,6 +8643,7 @@ static ndpi_protocol ndpi_internal_detection_process_packet(struct ndpi_detectio
{
ndpi_search_portable_executable(ndpi_str, flow);
ndpi_search_elf(ndpi_str, flow);
+ ndpi_search_shellscript(ndpi_str, flow);
}
if(flow->first_pkt_fully_encrypted == 0 &&