bin sh CHK ROOT if CHK then CHK fi if CHK then find ROOT -perm -755 -t

 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/sh
CHK="$2"
ROOT="$1"
if [[ ! $CHK ]]
then CHK=3
fi
if (( CHK == 3 ))
then
find $ROOT \
! -perm -755 -type d \
-exec chmod 755 {} \; \
-exec echo \; \
-o -type f \
\( \
! -perm -644 ! \( -iname '*.php' -o -iname '*.pl' -o -iname '*.cgi' -o -iname '*.py' \) \
-exec chmod 644 {} \; \
-exec echo \; \
\) , \( \
\( -iname '*.php' -o -iname '*.pl' -o -iname '*.cgi' -o -iname '*.py' \) \
\( \
\( ! -perm -755 -exec chmod 755 {} \; \) , \
\( \
-exec sed -i "s|\(\$SERVER\[[:space:]*'\)\(HTTP_HOST\)\('[:space:]*\]\)|\\1HTTP_X_HOST\\3|" {} \; \
-exec echo 'file' \; \
\) \
\) \
\) , \
-name '.htaccess' \
-exec sed -i "s|\HTTP_HOST|HTTP_X_HOST|" {} \; \
-exec echo 'file' \; \
| wc -l -w
elif (( CHK == 2 )); then
find $ROOT \
-type f \( \
\( -iname '*.php' -o -iname '*.pl' -o -iname '*.cgi' -o -iname '*.py' \) \
-exec sed -i "s|\(\$SERVER\[[:space:]*'\)\(HTTP_HOST\)\('[:space:]*\]\)|\\1HTTP_X_HOST\\3|" {} \; \
-exec echo 'file' \; \
\) , \
-name '.htaccess' \
-exec sed -i "s|\HTTP_HOST|HTTP_X_HOST|" {} \; \
-exec echo 'file' \; \
| wc -l -w
else
find $ROOT \
! -perm -755 -type d -exec chmod 755 {} \; -exec echo \; \
-o -type f \
\( \
! -perm -644 ! \( -iname '*.php' -o -iname '*.pl' -o -iname '*.cgi' -o -iname '*.py' \) \
-exec chmod 644 {} \; -exec echo \; \
\) , ! -perm -755 \( -iname '*.php' -o -iname '*.pl' -o -iname '*.cgi' -o -iname '*.py' \) -exec chmod 755 {} \; \
| wc -l -w
fi