From 04c0b8aab3091633b2b16a454c52b2c8cb351350 Mon Sep 17 00:00:00 2001 From: Carlos Polop Date: Tue, 3 Feb 2026 18:11:07 +0100 Subject: [PATCH] f --- .../11_Systemd.sh | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/linPEAS/builder/linpeas_parts/4_procs_crons_timers_srvcs_sockets/11_Systemd.sh b/linPEAS/builder/linpeas_parts/4_procs_crons_timers_srvcs_sockets/11_Systemd.sh index a717b34..f1922da 100644 --- a/linPEAS/builder/linpeas_parts/4_procs_crons_timers_srvcs_sockets/11_Systemd.sh +++ b/linPEAS/builder/linpeas_parts/4_procs_crons_timers_srvcs_sockets/11_Systemd.sh @@ -116,18 +116,20 @@ if ! [ "$SEARCH_IN_FOLDER" ]; then # Check ExecStart paths grep -E "ExecStart|ExecStartPre|ExecStartPost" "$service_file" 2>/dev/null | while read -r exec_line; do - # Extract the first word after ExecStart* as the command - cmd=$(echo "$exec_line" | awk '{print $2}' | tr -d '"') - # Extract the rest as arguments - args=$(echo "$exec_line" | awk '{$1=$2=""; print $0}' | tr -d '"') + # Extract command from the right side of Exec*=, not from argv + exec_value="${exec_line#*=}" + exec_value=$(echo "$exec_value" | sed 's/^[[:space:]]*//') + cmd=$(echo "$exec_value" | awk '{print $1}' | tr -d '"') + # Strip systemd command prefixes (-, @, :, +, !) before path checks + cmd_path=$(echo "$cmd" | sed -E 's/^[-@:+!]+//') # Only check the command path, not arguments - if [ -n "$cmd" ] && [ -w "$cmd" ]; then - echo "$service: $cmd (from $exec_line)" | sed -${E} "s,.*,${SED_RED},g" + if [ -n "$cmd_path" ] && [ -w "$cmd_path" ]; then + echo "$service: $cmd_path (from $exec_line)" | sed -${E} "s,.*,${SED_RED},g" fi # Check for relative paths only in the command, not arguments - if [ -n "$cmd" ] && [ "${cmd#/}" = "$cmd" ] && ! echo "$cmd" | grep -qE '^-|^--'; then - echo "$service: Uses relative path '$cmd' (from $exec_line)" | sed -${E} "s,.*,${SED_RED},g" + if [ -n "$cmd_path" ] && [ "${cmd_path#/}" = "$cmd_path" ] && [ "${cmd_path#\$}" = "$cmd_path" ]; then + echo "$service: Uses relative path '$cmd_path' (from $exec_line)" | sed -${E} "s,.*,${SED_RED},g" fi done fi @@ -153,4 +155,4 @@ if ! [ "$SEARCH_IN_FOLDER" ]; then fi echo "" -fi \ No newline at end of file +fi