-
Notifications
You must be signed in to change notification settings - Fork 0
/
check-struts.sh
59 lines (43 loc) · 1.06 KB
/
check-struts.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
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
#!/bin/bash
#
# Auth: a.pitcher
# check_struts: Struts lib version checker
struts_mlocate_true=struts_mlocate_$(hostname).txt
struts_lsof_true=struts_lsof_$(hostname).txt
print_version(){
#Check if $version is empty: return unknown
if [ ! -z "$2" ]
then
echo "$1: $2"
else
echo "$1: unknown"
fi
}
explode_lib(){
for libs in $(cat $1)
do
version=$(unzip -p $libs META-INF/MANIFEST.MF | grep 'Specification-Version\|Bundle-Version' | awk -F':' '{print $2}' | uniq)
print_version $libs $version
done
}
struts_lsof() {
lsof | grep struts | awk '{print $10}' | sort | uniq | grep 'jar$' > $struts_lsof_true
}
struts_mlocate(){
locate struts | grep 'jar$' > $struts_mlocate_true
}
struts_version () {
if struts_lsof
then
echo -e "Libs path and versions loaded on the system:"
explode_lib $struts_lsof_true
elif struts_mlocate
then
echo -e "Libs path and versions installed on the system:"
explode_lib $struts_mlocate_true
else
echo -e "No struts lib found"
rm -rf $struts_mlocate_true $struts_lsof_true
fi
}
struts_version