Skip to content

Instantly share code, notes, and snippets.

@timb-machine
Created July 4, 2022 23:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timb-machine/d624b39a6dc0022882479fb2a3c4fe58 to your computer and use it in GitHub Desktop.
Save timb-machine/d624b39a6dc0022882479fb2a3c4fe58 to your computer and use it in GitHub Desktop.
badrpath.sh
#!/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