-
-
Save michaeljclark/441e9096e79bbab75fa1700e33414332 to your computer and use it in GitHub Desktop.
search common directories for Linux ELF executables with executable stack
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 | |
# search common directories for Linux ELF executables with executable stack | |
is_elf() { | |
od -t x4 -N 4 $1 | sed -n 's/.*464c457f.*/YES/ p' | |
} | |
is_exec_stack() { | |
readelf -l $1 2>&1 | sed -n '/GNU_STACK/ {n; s/.*RWE.*$/YES/ p}' | |
} | |
for i in $(find /lib /bin /usr/lib /usr/bin -type f -a -executable); do | |
if [ "$(is_elf ${i})" = "YES" -a "$(is_exec_stack ${i})" = "YES" ]; then | |
echo $i | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment