-
Notifications
You must be signed in to change notification settings - Fork 4
/
PHPSiteScan
203 lines (150 loc) · 5.66 KB
/
PHPSiteScan
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
#!/bin/bash
# PHPSiteScan
# -------------------------------------------------------
# PHPSiteScan: A PHP website hack/exploit-finder utility
# version: .01
# Github: https://github.com/InterGenStudios/exBOMBER/blob/master/PHPSiteScan
# ---------------------------------------------------------------------------
# InterGenStudios: 7-28-15
# Copyright (c) 2015: Christopher 'InterGen' Cork InterGenStudios
# ----------------------------------------------------------------
# License: GPL-2.0+
# URL: http://opensource.org/licenses/gpl-license.php
# ---------------------------------------------------
# PHPSiteScan is free software:
# You may redistribute it and/or modify it under the terms of the
# GNU General Public License as published by the Free Software
# Foundation, either version 2 of the License, or (at your discretion)
# any later version.
# ------------------
###########################################
##---------------------------------------##
## BEGIN - INITIAL VARIABLE DECLARATIONS ##
##---------------------------------------##
###########################################
# Set timestamp
TIMESTAMP="$(date +"%m-%d-%Y:%T")"
#########################################
##-------------------------------------##
## END - INITIAL VARIABLE DECLARATIONS ##
##-------------------------------------##
#########################################
##############################
##--------------------------##
## BEGIN - SCRIPT FUNCTIONS ##
##--------------------------##
##############################
############################
##------------------------##
## END - SCRIPT FUNCTIONS ##
##------------------------##
############################
#############################################
##-----------------------------------------##
## BEGIN - MAKE SURE WE'RE RUNNING AS ROOT ##
##-----------------------------------------##
#############################################
if [ "$(id -u)" != "0" ]; then
echo -e "\n\n--------"
echo -e "WARNING!"
echo -e "--------\n\n"
echo -e "PHPSiteScan must be run as root\n\n"
echo -e "(Exiting now...)\n\n"
exit 1
fi
###########################################
##---------------------------------------##
## END - MAKE SURE WE'RE RUNNING AS ROOT ##
##---------------------------------------##
###########################################
#########################
##---------------------##
## BEGIN - CORE SCRIPT ##
##---------------------##
#########################
# ID any major panels running on system
if [ -d /usr/local/cpanel ]; then
PANEL="WHM"
elif [ -d /usr/local/psa ]; then
PANEL="Plesk"
elif [ -d /usr/local/directadmin ]; then
PANEL="DirectAdmin"
else
PANEL="Unknown"
fi
clear
echo -e "\n\nPHPSiteScan v.01 $TIMESTAMP\n"
echo -e "Copyright (c) 2015: Christopher 'InterGen' Cork InterGenStudios"
echo -e "Github: https://github.com/InterGenStudios/exBOMBER/blob/master/PHPSiteScan\n"
echo -e "---------------------------------------------------------------------------\n"
echo -e "Getting target paths...\n"
sleep 2
if [ -z "$1" ]; then
if [ "$PANEL" = "WHM" ] || [ "$PANEL" = "DirectAdmin" ]; then
TARGET_PATH="/home/*/public_html"
elif [ "$PANEL" = "Plesk" ]; then
TARGET_PATH="/var/www/vhosts"
else
TARGET_PATH="/var/www"
fi
else
echo -e "Validating supplied path..."
sleep 2
tput cuu 1 && tput el
if [ -d "$1" ]; then
TARGET_PATH="$1"
else
echo -e "Invalid Path Supplied"
sleep 2
tput cuu 1 && tput el
echo -e "Loading default server path..."
sleep 2
tput cuu 1 && tput el
if [ "$PANEL" = "WHM" ] || [ "$PANEL" = "DirectAdmin" ]; then
TARGET_PATH="/home/*/public_html"
elif [ "$PANEL" = "Plesk" ]; then
TARGET_PATH="/var/www/vhosts"
else
TARGET_PATH="/var/www"
fi
fi
fi
sleep 1
tput cuu 2 && tput el
echo -e "Server Panel: $PANEL\n"
echo -e "Target Path set to: $TARGET_PATH\n"
echo -e "---------------------------------------------------------------------------\n\n\n\n\n\n"
echo -e " Searching for:\n"
echo -e " ====> 'eval(base64_decode' <====\n"
echo -e "_______________________________\n\n"
mkdir -p /root/support/exBOMBER/tmp
touch /root/support/exBOMBER/tmp/PHPSiteScan_1stSearchHits
find $TARGET_PATH -type f -name '*.php' | xargs grep "eval *(base64_decode *(" /dev/null >> /root/support/exBOMBER/tmp/PHPSiteScan_1stSearchHits
if [ "$(wc -l /root/support/exBOMBER/tmp/PHPSiteScan_1stSearchHits | awk '{print $1}')" = "0" ]; then
echo No Hits Found
else
sed -i 's/:/ HIT: /g' /root/support/exBOMBER/tmp/PHPSiteScan_1stSearchHits
cat /root/support/exBOMBER/tmp/PHPSiteScan_1stSearchHits
fi
rm /root/support/exBOMBER/tmp/PHPSiteScan_1stSearchHits
echo -e "\n_______________________________\n\n\n\n\n\n"
sleep 2
echo -e " Searching for:\n"
echo -e " ====> 'eval(str_rot13(base64_decode' <====\n"
echo -e "_______________________________\n\n"
touch /root/support/exBOMBER/tmp/PHPSiteScan_2ndSearchHits
find $TARGET_PATH -type f -name '*.php' | xargs grep "eval *(str_rot13 *(base64_decode *(" /dev/null >> /root/support/exBOMBER/tmp/PHPSiteScan_2ndSearchHits
if [ "$(wc -l /root/support/exBOMBER/tmp/PHPSiteScan_2ndSearchHits | awk '{print $1}')" = "0" ]; then
echo No Hits Found
else
sed -i 's/:/ HIT: /g' /root/support/exBOMBER/tmp/PHPSiteScan_2ndSearchHits
cat /root/support/exBOMBER/tmp/PHPSiteScan_2ndSearchHits
fi
rm /root/support/exBOMBER/tmp/PHPSiteScan_2ndSearchHits
echo -e "\n_______________________________\n\n\n\n\n\n"
#######################
##-------------------##
## END - CORE SCRIPT ##
##-------------------##
#######################
exit 0