forked from slimm609/checksec
-
Notifications
You must be signed in to change notification settings - Fork 0
/
checksec_automator.sh
31 lines (23 loc) · 939 Bytes
/
checksec_automator.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env bash
# keep checksec executable and checksec_automation file in same directory.
#sudo find $1 -type f -executable -exec file -i '{}' \; | grep 'x-executable; charset=binary' | cut -c1- | cut -d ':' -f1 > linux_executables.txt
#tree -fi $1 > linux_executables.txt
help() {
echo "Usage: ./checksec_automation.sh [<dir_to_scan>] [<output_file_name>]"
}
#run help if nothing is passed
if [[ "$#" -lt 1 ]]; then
help
exit 1
fi
find "$1" -type f -executable -exec file -i '{}' \; | grep -e 'application/x-sharedlib; charset=binary' -e 'application/x-executable; charset=binary' | cut -c1- | cut -d ':' -f1 > linux_executables.txt
echo "Checksec Output" | tee "$2"
for i in $(cat linux_executables.txt); do
./checksec &> /dev/null
if [ "$?" -eq 127 ]; then
echo "File not Found. Keep checksec in same directory and run the script again."
exit 1
else
./checksec --file="$i" | tee -a "$2"
fi
done