diff --git a/linPEAS/builder/linpeas_parts/1_system_information/16_Protections.sh b/linPEAS/builder/linpeas_parts/1_system_information/16_Protections.sh index 95a91b5..5d18f26 100644 --- a/linPEAS/builder/linpeas_parts/1_system_information/16_Protections.sh +++ b/linPEAS/builder/linpeas_parts/1_system_information/16_Protections.sh @@ -127,6 +127,22 @@ else if [ "$ptrace_scope" -eq 0 ]; then echo "0" | sed -${E} "s,0,${SED_RED},"; else echo "$ptrace_scope" | sed -${E} "s,.*,${SED_GREEN},g"; fi fi +print_list "protected_symlinks? ............ "$NC +protected_symlinks=$(cat /proc/sys/fs/protected_symlinks 2>/dev/null) +if [ -z "$protected_symlinks" ]; then + echo_not_found "/proc/sys/fs/protected_symlinks" +else + if [ "$protected_symlinks" -eq 0 ]; then echo "0" | sed -${E} "s,0,${SED_RED},"; else echo "$protected_symlinks" | sed -${E} "s,.*,${SED_GREEN},g"; fi +fi + +print_list "protected_hardlinks? ........... "$NC +protected_hardlinks=$(cat /proc/sys/fs/protected_hardlinks 2>/dev/null) +if [ -z "$protected_hardlinks" ]; then + echo_not_found "/proc/sys/fs/protected_hardlinks" +else + if [ "$protected_hardlinks" -eq 0 ]; then echo "0" | sed -${E} "s,0,${SED_RED},"; else echo "$protected_hardlinks" | sed -${E} "s,.*,${SED_GREEN},g"; fi +fi + print_list "perf_event_paranoid? ........... "$NC perf_event_paranoid=$(cat /proc/sys/kernel/perf_event_paranoid 2>/dev/null) if [ -z "$perf_event_paranoid" ]; then diff --git a/linPEAS/builder/linpeas_parts/1_system_information/9_Disks_extra.sh b/linPEAS/builder/linpeas_parts/1_system_information/9_Disks_extra.sh index 5691c7f..22cbbf1 100644 --- a/linPEAS/builder/linpeas_parts/1_system_information/9_Disks_extra.sh +++ b/linPEAS/builder/linpeas_parts/1_system_information/9_Disks_extra.sh @@ -4,6 +4,7 @@ # Last Update: 07-03-2024 # Description: Check for additional disk information and system resources relevant to privilege escalation: # - Disk utilization +# - Inode usage # - System resources # - Storage statistics # - Common vulnerable scenarios: @@ -44,4 +45,8 @@ if [ "$EXTRA_CHECKS" ] || [ "$DEBUG" ]; then (df -h || lsblk) 2>/dev/null || echo_not_found "df and lsblk" warn_exec free 2>/dev/null echo "" -fi \ No newline at end of file + + print_2title "Inode usage" + warn_exec df -i 2>/dev/null + echo "" +fi diff --git a/linPEAS/builder/linpeas_parts/4_procs_crons_timers_srvcs_sockets/17_Deleted_open_files.sh b/linPEAS/builder/linpeas_parts/4_procs_crons_timers_srvcs_sockets/17_Deleted_open_files.sh new file mode 100644 index 0000000..95e6c67 --- /dev/null +++ b/linPEAS/builder/linpeas_parts/4_procs_crons_timers_srvcs_sockets/17_Deleted_open_files.sh @@ -0,0 +1,25 @@ +# Title: Processes & Cron & Services & Timers - Deleted open files +# ID: PR_Deleted_open_files +# Author: Carlos Polop +# Last Update: 2025-01-07 +# Description: Identify deleted files still held open by running processes +# License: GNU GPL +# Version: 1.0 +# Functions Used: print_2title, print_info +# Global Variables: $DEBUG, $EXTRA_CHECKS, $E, $SED_RED +# Initial Functions: +# Generated Global Variables: +# Fat linpeas: 0 +# Small linpeas: 1 + +if [ "$(command -v lsof 2>/dev/null || echo -n '')" ] || [ "$DEBUG" ]; then + print_2title "Deleted files still open" + print_info "Open deleted files can hide tools and still consume disk space" + lsof +L1 2>/dev/null | sed -${E} "s,\\(deleted\\),${SED_RED},g" + echo "" +elif [ "$EXTRA_CHECKS" ] || [ "$DEBUG" ]; then + print_2title "Deleted files still open" + print_info "lsof not found, scanning /proc for deleted file descriptors" + ls -l /proc/[0-9]*/fd 2>/dev/null | grep "(deleted)" | sed -${E} "s,\\(deleted\\),${SED_RED},g" | head -n 200 + echo "" +fi diff --git a/linPEAS/builder/linpeas_parts/4_procs_crons_timers_srvcs_sockets/7_Cron_jobs.sh b/linPEAS/builder/linpeas_parts/4_procs_crons_timers_srvcs_sockets/7_Cron_jobs.sh index 98578e8..a990c5f 100644 --- a/linPEAS/builder/linpeas_parts/4_procs_crons_timers_srvcs_sockets/7_Cron_jobs.sh +++ b/linPEAS/builder/linpeas_parts/4_procs_crons_timers_srvcs_sockets/7_Cron_jobs.sh @@ -23,6 +23,7 @@ if ! [ "$SEARCH_IN_FOLDER" ]; then incrontab -l 2>/dev/null ls -alR /etc/cron* /var/spool/cron/crontabs /var/spool/anacron 2>/dev/null | sed -${E} "s,$cronjobsG,${SED_GREEN},g" | sed "s,$cronjobsB,${SED_RED},g" cat /etc/cron* /etc/at* /etc/anacrontab /var/spool/cron/crontabs/* /etc/incron.d/* /var/spool/incron/* 2>/dev/null | tr -d "\r" | grep -v "^#" | sed -${E} "s,$Wfolders,${SED_RED_YELLOW},g" | sed -${E} "s,$sh_usrs,${SED_LIGHT_CYAN}," | sed "s,$USER,${SED_LIGHT_MAGENTA}," | sed -${E} "s,$nosh_usrs,${SED_BLUE}," | sed "s,root,${SED_RED}," + grep -Hn '^PATH=' /etc/crontab /etc/cron.d/* 2>/dev/null | sed -${E} "s,$Wfolders,${SED_RED_YELLOW},g" crontab -l -u "$USER" 2>/dev/null | tr -d "\r" ls -lR /usr/lib/cron/tabs/ /private/var/at/jobs /var/at/tabs/ /etc/periodic/ 2>/dev/null | sed -${E} "s,$cronjobsG,${SED_GREEN},g" | sed "s,$cronjobsB,${SED_RED},g" #MacOS paths atq 2>/dev/null @@ -247,4 +248,4 @@ else print_info "https://book.hacktricks.wiki/en/linux-hardening/privilege-escalation/index.html#scheduledcron-jobs" find "$SEARCH_IN_FOLDER" '(' -type d -or -type f ')' '(' -name "cron*" -or -name "anacron" -or -name "anacrontab" -or -name "incron.d" -or -name "incron" -or -name "at" -or -name "periodic" ')' -exec echo {} \; -exec ls -lR {} \; fi -echo "" \ No newline at end of file +echo ""