-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathfind-legacy
executable file
·114 lines (107 loc) · 2.44 KB
/
find-legacy
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#!/bin/sh
# This program takes directories as input and looks for programs
# that use the crypt function of glibc
if [ -h /lib ] ; then
libdirs="/usr/lib /usr/lib64"
else
libdirs="/lib /lib64 /usr/lib /usr/lib64"
fi
if [ -h /bin ] ; then
progdirs="/usr/bin /usr/sbin /usr/libexec"
else
progdirs="/bin /sbin /usr/bin /usr/sbin /usr/libexec"
fi
FOUND=0
source ./is_elf
check() {
xx=`readelf -sW $1 | awk 'NF>7 { print $8}' 2>/dev/null`
if [ x"$xx" != "x" ] ; then
func=""
echo "$xx" | grep -w 'bcopy@.*GLIBC.*' >/dev/null
if [ x$func = "x" -a $? -eq 0 ] ; then
func="bcopy"
fi
echo "$xx" | grep -w 'bcmp@.*GLIBC.*' >/dev/null
if [ x$func = "x" -a $? -eq 0 ] ; then
func="bcmp"
fi
res=`echo "$xx" | grep -w 'gets@.*GLIBC.*'`
if [ x$func = "x" -a x$res != "x" ] ; then
func="gets"
fi
echo "$xx" | grep -w 'getwd@.*GLIBC.*' >/dev/null
if [ x$func = "x" -a $? -eq 0 ] ; then
func="getwd"
fi
echo "$xx" | grep -w 'mktemp@.*GLIBC.*' >/dev/null
if [ x$func = "x" -a $? -eq 0 ] ; then
func="mktemp"
fi
echo "$xx" | grep -w 'tmpnam@.*GLIBC.*' >/dev/null
if [ x$func = "x" -a $? -eq 0 ] ; then
func="tmpnam"
fi
echo "$xx" | grep -w 'rindex@.*GLIBC.*' >/dev/null
if [ x$func = "x" -a $? -eq 0 ] ; then
func="rindex"
fi
echo "$xx" | grep -w 'index@.*GLIBC.*' >/dev/null
if [ x$func = "x" -a $? -eq 0 ] ; then
func="index"
fi
echo "$xx" | grep -w 'getpass@.*GLIBC.*' >/dev/null
if [ x$func = "x" -a $? -eq 0 ] ; then
func="getpass"
fi
echo "$xx" | grep -w 'valloc@.*GLIBC.*' >/dev/null
if [ x$func = "x" -a $? -eq 0 ] ; then
func="valloc"
fi
if [ x"$func" != "x" ] ; then
FOUND=1
package=`rpm -qf --queryformat "%{NAME}-%{VERSION}" $1 2>/dev/null`
if [ $? -eq 1 ] ; then
package="Not Owned"
fi
ls -l $1 | awk -v f="$func" -v p="$package" '{ printf "%-46s\t%-10s\t%s\n", $9, f, p}'
fi
fi
}
scan () {
if [ "$1" = "1" ] ; then
dirs=$libdirs
elif [ "$1" = "2" ] ; then
dirs=$progdirs
elif [ "$1" = "3" ] ; then
dirs=$3
fi
for d in $dirs ; do
if [ ! -d $d ] ; then
continue
fi
files=`/usr/bin/find $d -name "$2" -type f 2>/dev/null`
for f in $files
do
if is_elf "$f" ; then
check $f
fi
done
done
}
if [ $# -eq 1 ] ; then
if [ -d $1 ] ; then
scan 3 '*' $1
else
echo "Input is not a directory"
exit 1
fi
else
scan 1 '*.so'
scan 2 '*'
fi
if [ $FOUND -eq 0 ] ; then
# Nothing to report, just exit
echo "No problems found" 1>&2
exit 0
fi
exit 1