From e5aec53af280da953fb974470d89e03ea1e82088 Mon Sep 17 00:00:00 2001 From: Carlos Polop Date: Tue, 20 Jan 2026 18:21:06 +0100 Subject: [PATCH] Avoid hangs when checking users with console --- .../6_users_information/12_Users_with_console.sh | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/linPEAS/builder/linpeas_parts/6_users_information/12_Users_with_console.sh b/linPEAS/builder/linpeas_parts/6_users_information/12_Users_with_console.sh index 753c56f..0702ad7 100644 --- a/linPEAS/builder/linpeas_parts/6_users_information/12_Users_with_console.sh +++ b/linPEAS/builder/linpeas_parts/6_users_information/12_Users_with_console.sh @@ -6,7 +6,7 @@ # License: GNU GPL # Version: 1.0 # Functions Used: print_2title -# Global Variables: $MACPEAS, $sh_usrs, $USER +# Global Variables: $MACPEAS, $sh_usrs, $TIMEOUT, $USER # Initial Functions: # Generated Global Variables: $ushell, $no_shells, $unexpected_shells # Fat linpeas: 0 @@ -26,8 +26,16 @@ else no_shells=$(grep -Ev "sh$" /etc/passwd 2>/dev/null | cut -d ':' -f 7 | sort | uniq) unexpected_shells="" printf "%s\n" "$no_shells" | while read f; do - if $f -c 'whoami' 2>/dev/null | grep -q "$USER"; then - unexpected_shells="$f\n$unexpected_shells" + if [ -x "$f" ]; then + if [ "$TIMEOUT" ]; then + if $TIMEOUT 1 "$f" -c 'whoami' 2>/dev/null | grep -q "$USER"; then + unexpected_shells="$f\n$unexpected_shells" + fi + else + if "$f" -c 'whoami' 2>/dev/null | grep -q "$USER"; then + unexpected_shells="$f\n$unexpected_shells" + fi + fi fi done grep "sh$" /etc/passwd 2>/dev/null | sort | sed -${E} "s,$sh_usrs,${SED_LIGHT_CYAN}," | sed "s,$USER,${SED_LIGHT_MAGENTA}," | sed "s,root,${SED_RED}," @@ -41,4 +49,4 @@ else done fi fi -echo "" \ No newline at end of file +echo ""