diff --git a/linPEAS/builder/linpeas_parts/1_system_information/10_Environment.sh b/linPEAS/builder/linpeas_parts/1_system_information/10_Environment.sh index a4a6200..8ca821b 100644 --- a/linPEAS/builder/linpeas_parts/1_system_information/10_Environment.sh +++ b/linPEAS/builder/linpeas_parts/1_system_information/10_Environment.sh @@ -26,7 +26,7 @@ # License: GNU GPL # Version: 1.0 # Functions Used: echo_not_found, print_2title, print_info -# Global Variables: +# Global Variables: $NoEnvVars, $EnvVarsRed # Initial Functions: # Generated Global Variables: # Fat linpeas: 0 @@ -35,5 +35,5 @@ print_2title "Environment" print_info "Any private information inside environment variables?" -(env || printenv || set) 2>/dev/null | grep -v "RELEVANT*|FIND*|^VERSION=|dbuslistG|mygroups|ldsoconfdG|pwd_inside_history|kernelDCW_Ubuntu_Precise|kernelDCW_Ubuntu_Trusty|kernelDCW_Ubuntu_Xenial|kernelDCW_Rhel|^sudovB=|^rootcommon=|^mounted=|^mountG=|^notmounted=|^mountpermsB=|^mountpermsG=|^kernelB=|^C=|^RED=|^GREEN=|^Y=|^B=|^NC=|TIMEOUT=|groupsB=|groupsVB=|knw_grps=|sidG|sidB=|sidVB=|sidVB2=|sudoB=|sudoG=|sudoVB=|timersG=|capsB=|notExtensions=|Wfolders=|writeB=|writeVB=|_usrs=|compiler=|LS_COLORS=|pathshG=|notBackup=|processesDump|processesB|commonrootdirs|USEFUL_SOFTWARE|PSTORAGE_" | sed -${E} "s,[pP][aA][sS][sS][wW]|[aA][pP][iI][kK][eE][yY]|[aA][pP][iI][_][kK][eE][yY]|KRB5CCNAME,${SED_RED},g" || echo_not_found "env || set" +(env || printenv || set) 2>/dev/null | grep -Eiv "$NoEnvVars" | sed -${E} "s,$EnvVarsRed,${SED_RED},g" || echo_not_found "env || set" echo "" \ No newline at end of file diff --git a/linPEAS/builder/linpeas_parts/9_interesting_files/29_Interesting_environment_variables.sh b/linPEAS/builder/linpeas_parts/9_interesting_files/29_Interesting_environment_variables.sh index 14f4517..e6fef21 100644 --- a/linPEAS/builder/linpeas_parts/9_interesting_files/29_Interesting_environment_variables.sh +++ b/linPEAS/builder/linpeas_parts/9_interesting_files/29_Interesting_environment_variables.sh @@ -6,21 +6,17 @@ # License: GNU GPL # Version: 1.0 # Functions Used: print_2title -# Global Variables: $MACPEAS +# Global Variables: $MACPEAS, $NoEnvVars, $EnvVarsRed # Initial Functions: # Generated Global Variables: # Fat linpeas: 0 # Small linpeas: 1 if [ -z "$MACPEAS" ]; then - print_2title "Searching possible sensitive environment variables inside of /proc/*/environ" - for f in /proc/[0-9]*/environ; do - [ -r "$f" ] || continue - tr '\0' '\n' < "$f" | \ - grep -aEi "(token|password|secret|aws|azure|gcp|api|key|jwt|session|cookie|database|sql|mongo|postgres)" | \ - grep -avEi '(XDG_SESSION|DBUS_SESSION|systemd\/sessions)' | \ - while read -r g; do - echo "$f: $g" - done - done + print_2title "Checking all env variables in /proc/*/environ removing duplicates and filtering out useless env vars" + cat /proc/[0-9]*/environ 2>/dev/null | \ + tr '\0' '\n' | \ + grep -Eiv "$NoEnvVars" | \ + sort -u | \ + sed -${E} "s,$EnvVarsRed,${SED_RED},g" fi diff --git a/linPEAS/builder/linpeas_parts/variables/EnvVarsRed.sh b/linPEAS/builder/linpeas_parts/variables/EnvVarsRed.sh new file mode 100644 index 0000000..0024f68 --- /dev/null +++ b/linPEAS/builder/linpeas_parts/variables/EnvVarsRed.sh @@ -0,0 +1,18 @@ +# Title: Variables - EnvVarsRed +# ID: EnvVarsRed +# Author: Carlos Polop +# Last Update: 26-05-2025 +# Description: Useless env vars +# License: GNU GPL +# Version: 1.0 +# Functions Used: +# Global Variables: +# Initial Functions: +# Generated Global Variables: $EnvVarsRed +# Fat linpeas: 0 +# Small linpeas: 1 + + +EnvVarsRed="[pP][aA][sS][sS][wW]|[aA][pP][iI][kK][eE][yY]|[aA][pP][iI][_][kK][eE][yY]|KRB5CCNAME|[aA][pP][iI][_][kK][eE][yY]|[aA][wW][sS]|[aA][zZ][uU][rR][eE]|[gG][cC][pP]|[aA][pP][iI]|[sS][eE][cC][rR][eE][tT]|[sS][qQ][lL]|[dD][aA][tT][aA][bB][aA][sS][eE]|[tT][oO][kK][eE][nN]" + + diff --git a/linPEAS/builder/linpeas_parts/variables/NoEnvVars.sh b/linPEAS/builder/linpeas_parts/variables/NoEnvVars.sh new file mode 100644 index 0000000..e2737ba --- /dev/null +++ b/linPEAS/builder/linpeas_parts/variables/NoEnvVars.sh @@ -0,0 +1,16 @@ +# Title: Variables - NoEnvVars +# ID: NoEnvVars +# Author: Carlos Polop +# Last Update: 26-05-2025 +# Description: Useless env vars +# License: GNU GPL +# Version: 1.0 +# Functions Used: +# Global Variables: +# Initial Functions: +# Generated Global Variables: $NoEnvVars +# Fat linpeas: 0 +# Small linpeas: 1 + + +NoEnvVars="LESS_TERMCAP|JOURNAL_STREAM|XDG_SESSION|DBUS_SESSION|systemd\/sessions|systemd_exec|MEMORY_PRESSURE_WATCH|RELEVANT*|FIND*|^VERSION=|dbuslistG|mygroups|ldsoconfdG|pwd_inside_history|kernelDCW_Ubuntu_Precise|kernelDCW_Ubuntu_Trusty|kernelDCW_Ubuntu_Xenial|kernelDCW_Rhel|^sudovB=|^rootcommon=|^mounted=|^mountG=|^notmounted=|^mountpermsB=|^mountpermsG=|^kernelB=|^C=|^RED=|^GREEN=|^Y=|^B=|^NC=|TIMEOUT=|groupsB=|groupsVB=|knw_grps=|sidG|sidB=|sidVB=|sidVB2=|sudoB=|sudoG=|sudoVB=|timersG=|capsB=|notExtensions=|Wfolders=|writeB=|writeVB=|_usrs=|compiler=|LS_COLORS=|pathshG=|notBackup=|processesDump|processesB|commonrootdirs|USEFUL_SOFTWARE|PSTORAGE_"