Created
July 4, 2022 23:29
-
-
Save timb-machine/d624b39a6dc0022882479fb2a3c4fe58 to your computer and use it in GitHub Desktop.
badrpath.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
find / \( \( -perm -u+s \) -o \( -perm -g+s \) \) -a -type f 2>/dev/null | while read SUIDFILE | |
do | |
LSFILE=`ls -la "$SUIDFILE"` | |
objdump -x "$SUIDFILE" 2>&1| egrep 'RPATH|RUNPATH' | while read name paths | |
do | |
if [ -n "$paths" ]; then | |
echo "$paths" | tr ":" "\n" | while read RPATHDIR | |
do | |
if [ "`echo "$RPATHDIR" | cut -c 1`" != "/" ] | |
then | |
echo "SUIDFILE='$SUIDFILE' SUIDFILELS='$LSFILE' RPATH='$RPATHDIR' RPATHRELATIVE=yes RPATHLS=N/A RAPTHEXISTS=N/A ISBAD=yes" | |
else | |
if [ -d "$RPATHDIR" ] | |
then | |
RPATHLS=`ls -ld $RPATHDIR` | |
echo "SUIDFILE='$SUIDFILE' SUIDFILELS='$LSFILE' RPATH='$RPATHDIR' RPATHRELATIVE=no RPATHLS='$RPATHLS' RAPTHEXISTS=yes ISBAD=no" | |
else | |
echo "SUIDFILE='$SUIDFILE' SUIDFILELS='$LSFILE' RPATH='$RPATHDIR' RPATHRELATIVE=no RPATHLS=N/A RAPTHEXISTS=no ISBAD=maybe" | |
fi | |
fi | |
done | |
fi | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment