2 # Copyright (C) 2003, 2004 Red Hat, Inc.
3 # Written by Ingo Molnar and Ulrich Drepper
4 if [ "$#" != "1" ]; then
5 echo "usage: lsexec [ <PID> | process name | --all ]"
8 if ! test -f /etc/redhat-release; then
9 echo "this script is written for RHEL or Fedora Core"
16 if [ -r $1/maps ]; then
17 echo -n $(basename $(readlink $1/exe))
18 printf ", PID %6d: " $1
19 if [ -r $1/exe ]; then
20 if eu-readelf -h $1/exe|egrep -q 'Type:[[:space:]]*EXEC'; then
21 echo -n -e '\033[31mno PIE\033[m, '
23 if eu-readelf -d $1/exe|egrep -q ' DEBUG[[:space:]]*$'; then
24 echo -n -e '\033[32mPIE\033[m, '
25 if eu-readelf -d $1/exe|fgrep -q TEXTREL; then
26 echo -n -e '\033[31mTEXTREL\033[m, '
29 echo -n -e '\033[33mDSO\033[m, '
32 if eu-readelf -l $1/exe|fgrep -q 'GNU_RELRO'; then
33 if eu-readelf -d $1/exe|fgrep -q 'BIND_NOW'; then
34 if eu-readelf -l $1/exe|fgrep -q ' .got] .data .bss'; then
35 echo -n -e '\033[32mfull RELRO\033[m, '
37 echo -n -e '\033[31mincorrect RELRO\033[m, '
40 echo -n -e '\033[33mpartial RELRO\033[m, '
43 echo -n -e '\033[31mno RELRO\033[m, '
46 lastpg=$(sed -n '/^[[:xdigit:]]*-[[:xdigit:]]* rw.. \([[:xdigit:]]*\) 00:00 0$/p' $1/maps|
48 if echo "$lastpg" | egrep -v -q ' rwx. '; then
51 if [ -z "$lastpg" ] || [ -z "$(echo $lastpg||cut -d ' ' -f3|tr -d 0)" ]; then
52 echo -e '\033[32mExec-Shield enabled\033[m'
54 echo -e '\033[31mExec-Shield disabled\033[m'
55 for N in `awk '{print $6}' $1/maps | egrep '\.so|bin/' | grep '^/' | sort -u`; do
56 NE=$(eu-readelf -l $N | fgrep STACK | fgrep 'RW ')
57 if [ "$NE" = "" ]; then
58 echo " => $N disables Exec-Shield!"
70 if [ "$1" = "--all" ]; then
72 if [ $N != $$ ] && readlink -q $N/exe > /dev/null; then
79 for N in `/sbin/pidof $1`; do