> For the complete documentation index, see [llms.txt](https://morgan-bin-bash.gitbook.io/scripts-and-codes-pentester/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://morgan-bin-bash.gitbook.io/scripts-and-codes-pentester/suid.sh.md).

# suid.sh

\#!/bin/bash

## Define a function to test SUID files

test\_suid() { local file="$1" local result

## Check if the file exists and is executable

if \[ -x "$file" ]; then # Attempt to execute the file if \[ -n "$(timeout 2 ./"$file" 2>&1)" ]; then result="Vulnerable" else result="Not Vulnerable" fi else result="Not Executable" fi

echo "$file: $result" }

## Find all SUID files on the system

suid\_files=$(find / -type f -perm /4000)

## Loop through each SUID file and test it

for file in $suid\_files; do test\_suid "$file" done
