51 |
beyerle@PS |
1 |
#!/bin/bash
|
|
|
2 |
#
|
|
|
3 |
################################################################
|
|
|
4 |
#
|
|
|
5 |
# Simple Virus Scanner GUI for
|
|
|
6 |
#
|
|
|
7 |
# - f-prot
|
|
|
8 |
# - uvscan (McAfee)
|
|
|
9 |
# - clamscan
|
|
|
10 |
#
|
|
|
11 |
################################################################
|
|
|
12 |
#
|
|
|
13 |
# Urs Beyerle, PSI
|
|
|
14 |
#
|
|
|
15 |
# (some parts taken from f-prot_gui.sh by Fabian Franz)
|
|
|
16 |
#
|
|
|
17 |
################################################################
|
|
|
18 |
#
|
|
|
19 |
MyVersion=0.3.1
|
|
|
20 |
#
|
|
|
21 |
################################################################
|
|
|
22 |
|
|
|
23 |
clean_exit()
|
|
|
24 |
{
|
|
|
25 |
rm -rf /tmp/virusscan.$$
|
|
|
26 |
}
|
|
|
27 |
|
|
|
28 |
trap "clean_exit" EXIT
|
|
|
29 |
|
|
|
30 |
### ------------------------------------------------------------
|
|
|
31 |
### definitions
|
|
|
32 |
### ------------------------------------------------------------
|
|
|
33 |
|
|
|
34 |
### set path
|
|
|
35 |
PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin"
|
|
|
36 |
|
|
|
37 |
### title
|
|
|
38 |
TITLE="Virus Scanner GUI $MyVersion"
|
|
|
39 |
MENU_TITLE="Virus Scanner GUI $MyVersion"
|
|
|
40 |
|
|
|
41 |
### scan engine list
|
|
|
42 |
ENGINE_LIST=""
|
|
|
43 |
|
|
|
44 |
### fprot
|
|
|
45 |
FPROT=$(which f-prot 2>/dev/null)
|
|
|
46 |
if [ $FPROT ]; then
|
|
|
47 |
FPROT_NAME="F-Prot"
|
|
|
48 |
FPROT_OPT="-all -ai -archive -dumb -packed -list"
|
|
|
49 |
FPROT_CHECKUPDATES=/usr/local/f-prot/tools/check-updates.pl
|
|
|
50 |
FPROT_ON="1"
|
|
|
51 |
ENGINE_LIST="$ENGINE_LIST $FPROT_NAME $FPROT On"
|
|
|
52 |
echo "f-prot found."
|
|
|
53 |
fi
|
|
|
54 |
|
|
|
55 |
### uvscan (McAfee)
|
|
|
56 |
UVSCAN=$(which uvscan 2>/dev/null)
|
|
|
57 |
if [ $UVSCAN ]; then
|
|
|
58 |
UVSCAN_NAME="McAfee"
|
|
|
59 |
UVSCAN_OPT="--secure -v -r --summary"
|
|
|
60 |
UVSCAN_CHECKUPDATES=/usr/local/uvscan/update-dat
|
|
|
61 |
UVSCAN_ON="1"
|
|
|
62 |
ENGINE_LIST="$ENGINE_LIST $UVSCAN_NAME $UVSCAN On"
|
|
|
63 |
echo "uvscan found."
|
|
|
64 |
fi
|
|
|
65 |
|
|
|
66 |
### clamscan (Clam)
|
|
|
67 |
CLAM=$(which clamscan 2>/dev/null)
|
|
|
68 |
if [ $CLAM ]; then
|
|
|
69 |
CLAM_NAME="Clam"
|
|
|
70 |
CLAM_OPT="-r"
|
|
|
71 |
if [ -x /usr/bin/psi-freshclam ]; then
|
|
|
72 |
CLAM_CHECKUPDATES=/usr/bin/psi-freshclam
|
|
|
73 |
else
|
|
|
74 |
CLAM_CHECKUPDATES="/etc/init.d/clamd status || /etc/init.d/clamd start && /usr/bin/freshclam"
|
|
|
75 |
fi
|
|
|
76 |
CLAM_ON="1"
|
|
|
77 |
ENGINE_LIST="$ENGINE_LIST $CLAM_NAME $CLAM On"
|
|
|
78 |
echo "clamscan found."
|
|
|
79 |
fi
|
|
|
80 |
|
|
|
81 |
### tmpdir
|
|
|
82 |
TMPDIR=/tmp/virusscanner.$$
|
|
|
83 |
TMP=$TMPDIR/dialog
|
|
|
84 |
mkdir -p $TMPDIR
|
|
|
85 |
|
|
|
86 |
### report dir
|
|
|
87 |
REPORT_DIR="/var/log/virusscanner"
|
|
|
88 |
mkdir -p /var/log/virusscanner
|
|
|
89 |
|
|
|
90 |
### dialog or xdialog?
|
|
|
91 |
DIALOG="dialog"
|
|
|
92 |
XDIALOG_HIGH_DIALOG_COMPAT=1
|
|
|
93 |
export XDIALOG_HIGH_DIALOG_COMPAT
|
|
|
94 |
[ -n "$DISPLAY" ] && [ -x /usr/bin/Xdialog ] && DIALOG="Xdialog"; XDIALOG="yes"
|
|
|
95 |
|
|
|
96 |
### do we have a virus scanner?
|
|
|
97 |
if [ ! $FPROT ] && [ ! $UVSCAN ] && [ ! $CLAM ]; then
|
|
|
98 |
MESSAGE0="Please install a virus scan engine: F-prot, McAfee or clamav!"
|
|
|
99 |
$DIALOG --title "$TITLE" --msgbox "$MESSAGE0" 0 0
|
|
|
100 |
exit 1
|
|
|
101 |
fi
|
|
|
102 |
|
|
|
103 |
### need root rights!
|
|
|
104 |
if [ "$UID" -ne "0" ]; then
|
|
|
105 |
MESSAGE0="To use this program, you need to be root"
|
|
|
106 |
$DIALOG --title "$TITLE" --msgbox "$MESSAGE0" 0 0
|
|
|
107 |
exit 1
|
|
|
108 |
fi
|
|
|
109 |
|
|
|
110 |
|
|
|
111 |
### ------------------------------------------------------------
|
|
|
112 |
### functions
|
|
|
113 |
### ------------------------------------------------------------
|
|
|
114 |
|
|
|
115 |
|
|
|
116 |
### ------------------------------------------------------------
|
|
|
117 |
welcome_message()
|
|
|
118 |
{
|
|
|
119 |
WELCOME_MESSAGE=$( cat <<EOF
|
|
|
120 |
-------------------------------------------\n
|
|
|
121 |
Welcome to $TITLE\n
|
|
|
122 |
-------------------------------------------\n
|
|
|
123 |
PLEASE NOTE: No files will be delete.\n
|
|
|
124 |
\n
|
|
|
125 |
Press OK to continue\n
|
|
|
126 |
EOF)
|
|
|
127 |
[ $XDIALOG ] && echo $TITLE
|
|
|
128 |
$DIALOG --title "$TITLE" --infobox "$WELCOME_MESSAGE" 0 0 8
|
|
|
129 |
[ $? -ne 0 ] && exit
|
|
|
130 |
}
|
|
|
131 |
|
|
|
132 |
|
|
|
133 |
### ------------------------------------------------------------
|
|
|
134 |
find_partitions()
|
|
|
135 |
{
|
|
|
136 |
PART_ALL=$(LC_ALL=C fdisk -l | sed 's/*//g' | egrep -v "swap|Extended|Ext." | awk '{ print $1 }' | grep "/dev/")
|
|
|
137 |
PART_LIST=$(LC_ALL=C fdisk -l | sed 's/*//g' | egrep -v "swap|Extended|Ext." | awk '{ printf("%s %s-Partition off\n",$1,$6 $7 $8 $9) }' | grep "/dev/")
|
|
|
138 |
# add "Select all"
|
|
|
139 |
PART_LIST="$PART_LIST Select All off"
|
|
|
140 |
}
|
|
|
141 |
|
|
|
142 |
|
|
|
143 |
### ------------------------------------------------------------
|
|
|
144 |
choose_parts()
|
|
|
145 |
{
|
|
|
146 |
MESSAGE2="Found partitions"
|
|
|
147 |
$DIALOG --title "$TITLE" --checklist "$MESSAGE2" 0 0 0 $PART_LIST 2>$TMP
|
|
|
148 |
PARTS=$(sed 's,",,g;s,//, /,g' $TMP)
|
|
|
149 |
# all selected ?
|
|
|
150 |
grep -q "Select" $TMP
|
|
|
151 |
if [ "$?" = "0" ]; then
|
|
|
152 |
PARTS=$PART_ALL
|
|
|
153 |
fi
|
|
|
154 |
[ $XDIALOG ] && echo "Partition(s) selected:"
|
|
|
155 |
[ $XDIALOG ] && echo $PARTS
|
|
|
156 |
[ -n "$PARTS" ] && FILES=""
|
|
|
157 |
}
|
|
|
158 |
|
|
|
159 |
|
|
|
160 |
### ------------------------------------------------------------
|
|
|
161 |
choose_dirfile()
|
|
|
162 |
{
|
|
|
163 |
$DIALOG --title $TITLE --fselect "$(pwd)/" 0 0 2>$TMP
|
|
|
164 |
FILES=$(cat $TMP)
|
|
|
165 |
[ -n "$FILES" ] && PARTS=""
|
|
|
166 |
}
|
|
|
167 |
|
|
|
168 |
|
|
|
169 |
### ------------------------------------------------------------
|
|
|
170 |
choose_engine()
|
|
|
171 |
{
|
|
|
172 |
MESSAGE_ENGINE="Available Virus Scan Engine(s)"
|
|
|
173 |
$DIALOG --title "$TITLE" --checklist "$MESSAGE_ENGINE" 0 0 4 $ENGINE_LIST 2>$TMP
|
|
|
174 |
# create new engine list
|
|
|
175 |
ENGINE_LIST=""
|
|
|
176 |
|
|
|
177 |
# deselect f-prot ?
|
|
|
178 |
if [ $FPROT_NAME ]; then
|
|
|
179 |
grep -q $FPROT_NAME $TMP
|
|
|
180 |
if [ "$?" = "0" ]; then
|
|
|
181 |
ENGINE_LIST="$ENGINE_LIST $FPROT_NAME $FPROT On"; FPROT_ON="1"
|
|
|
182 |
else
|
|
|
183 |
ENGINE_LIST="$ENGINE_LIST $FPROT_NAME $FPROT Off"; FPROT_ON=""
|
|
|
184 |
fi
|
|
|
185 |
fi
|
|
|
186 |
|
|
|
187 |
# deselect uvscan ?
|
|
|
188 |
if [ $UVSCAN_NAME ]; then
|
|
|
189 |
grep -q $UVSCAN_NAME $TMP
|
|
|
190 |
if [ "$?" = "0" ]; then
|
|
|
191 |
ENGINE_LIST="$ENGINE_LIST $UVSCAN_NAME $UVSCAN On"; UVSCAN_ON="1"
|
|
|
192 |
else
|
|
|
193 |
ENGINE_LIST="$ENGINE_LIST $UVSCAN_NAME $UVSCAN Off"; UVSCAN_ON=""
|
|
|
194 |
fi
|
|
|
195 |
fi
|
|
|
196 |
|
|
|
197 |
# deselect clamscan ?
|
|
|
198 |
if [ $CLAM_NAME ]; then
|
|
|
199 |
grep -q $CLAM_NAME $TMP
|
|
|
200 |
if [ "$?" = "0" ]; then
|
|
|
201 |
ENGINE_LIST="$ENGINE_LIST $CLAM_NAME $CLAM On"; CLAM_ON="1"
|
|
|
202 |
else
|
|
|
203 |
ENGINE_LIST="$ENGINE_LIST $CLAM_NAME $CLAM Off"; CLAM_ON=""
|
|
|
204 |
fi
|
|
|
205 |
fi
|
|
|
206 |
}
|
|
|
207 |
|
|
|
208 |
### ------------------------------------------------------------
|
|
|
209 |
define_report()
|
|
|
210 |
{
|
|
|
211 |
DATE=$(date +"%Y-%m-%d")
|
|
|
212 |
DIVIDER="------------------------------------------------------------------------------------------"
|
|
|
213 |
DOTS=".........\n.........\n........."
|
|
|
214 |
|
|
|
215 |
### where to report
|
|
|
216 |
REPORT_TMP=$REPORT_DIR/report.tmp
|
|
|
217 |
rm -rf $REPORT_TMP
|
|
|
218 |
touch $REPORT_TMP
|
|
|
219 |
NR=$(ls $REPORT_DIR/$PREFIX* 2>/dev/null | wc -l | tr -d " ")
|
|
|
220 |
|
|
|
221 |
if [ $FPROT_ON ]; then
|
|
|
222 |
FPROT_REPORT="$REPORT_DIR/report_fprot-$DATE-$NR.txt"
|
|
|
223 |
FPROT_REPORT_MIN="$REPORT_DIR/report_fprot-$DATE-$NR.min.txt"
|
|
|
224 |
echo $DIVIDER > $FPROT_REPORT
|
|
|
225 |
echo "F-Prot Report:" >> $FPROT_REPORT
|
|
|
226 |
cat $FPROT_REPORT > $FPROT_REPORT_MIN
|
|
|
227 |
fi
|
|
|
228 |
|
|
|
229 |
if [ $UVSCAN_ON ]; then
|
|
|
230 |
UVSCAN_REPORT="$REPORT_DIR/report_mcafee-$DATE-$NR.txt"
|
|
|
231 |
UVSCAN_REPORT_MIN="$REPORT_DIR/report_mcafee-$DATE-$NR.min.txt"
|
|
|
232 |
echo $DIVIDER > $UVSCAN_REPORT
|
|
|
233 |
echo "McAfee Report:" >> $UVSCAN_REPORT
|
|
|
234 |
echo $DIVIDER >> $UVSCAN_REPORT
|
|
|
235 |
$UVSCAN --version >> $UVSCAN_REPORT
|
|
|
236 |
cat $UVSCAN_REPORT > $UVSCAN_REPORT_MIN
|
|
|
237 |
fi
|
|
|
238 |
|
|
|
239 |
if [ $CLAM_ON ]; then
|
|
|
240 |
CLAM_REPORT="$REPORT_DIR/report_clam-$DATE-$NR.txt"
|
|
|
241 |
CLAM_REPORT_MIN="$REPORT_DIR/report_clam-$DATE-$NR.min.txt"
|
|
|
242 |
echo $DIVIDER > $CLAM_REPORT
|
|
|
243 |
echo "Clam Report:" >> $CLAM_REPORT
|
|
|
244 |
echo $DIVIDER >> $CLAM_REPORT
|
|
|
245 |
$CLAM --version >> $CLAM_REPORT
|
|
|
246 |
cat $CLAM_REPORT > $CLAM_REPORT_MIN
|
|
|
247 |
fi
|
|
|
248 |
}
|
|
|
249 |
|
|
|
250 |
|
|
|
251 |
### ------------------------------------------------------------
|
|
|
252 |
report_fprot()
|
|
|
253 |
{
|
|
|
254 |
[ $XDIALOG ] && echo -n "Creating F-Prot report... "
|
|
|
255 |
|
|
|
256 |
# create report (normal and min)
|
|
|
257 |
# normal report
|
|
|
258 |
echo $DIVIDER >> $FPROT_REPORT
|
|
|
259 |
echo $PART_TOSCAN >> $FPROT_REPORT
|
|
|
260 |
echo $DIVIDER >> $FPROT_REPORT
|
|
|
261 |
cat $REPORT_TMP >> $FPROT_REPORT
|
|
|
262 |
echo $DIVIDER >> $FPROT_REPORT
|
|
|
263 |
echo >> $FPROT_REPORT
|
|
|
264 |
|
|
|
265 |
# min report
|
|
|
266 |
echo $DIVIDER >> $FPROT_REPORT_MIN
|
|
|
267 |
echo $PART_TOSCAN >> $FPROT_REPORT_MIN
|
|
|
268 |
echo $DIVIDER >> $FPROT_REPORT_MIN
|
|
|
269 |
head -n 25 $REPORT_TMP >> $FPROT_REPORT_MIN
|
|
|
270 |
echo -e $DOTS >> $FPROT_REPORT_MIN
|
|
|
271 |
tail -n 20 $REPORT_TMP >> $FPROT_REPORT_MIN
|
|
|
272 |
echo $DIVIDER >> $FPROT_REPORT_MIN
|
|
|
273 |
grep " Infection: " $REPORT_TMP >> $FPROT_REPORT_MIN
|
|
|
274 |
grep " Infection: " $REPORT_TMP
|
|
|
275 |
if [ "$?" = "0" ]; then
|
|
|
276 |
echo "VIRUS INFECTION FOUND !!!" >> $FPROT_REPORT_MIN
|
|
|
277 |
[ $XDIALOG ] && echo "VIRUS INFECTION FOUND !!!"
|
|
|
278 |
echo $DIVIDER >> $FPROT_REPORT_MIN
|
|
|
279 |
fi
|
|
|
280 |
echo >> $FPROT_REPORT_MIN
|
|
|
281 |
|
|
|
282 |
rm -f $REPORT_TMP
|
|
|
283 |
touch $REPORT_TMP
|
|
|
284 |
|
|
|
285 |
[ $XDIALOG ] && echo " done."
|
|
|
286 |
}
|
|
|
287 |
|
|
|
288 |
|
|
|
289 |
### ------------------------------------------------------------
|
|
|
290 |
report_uvscan()
|
|
|
291 |
{
|
|
|
292 |
[ $XDIALOG ] && echo -n "Creating McAfee report... "
|
|
|
293 |
|
|
|
294 |
# create report (normal and min)
|
|
|
295 |
# normal report
|
|
|
296 |
echo $DIVIDER >> $UVSCAN_REPORT
|
|
|
297 |
echo $PART_TOSCAN >> $UVSCAN_REPORT
|
|
|
298 |
echo $DIVIDER >> $UVSCAN_REPORT
|
|
|
299 |
cat $REPORT_TMP >> $UVSCAN_REPORT
|
|
|
300 |
echo $DIVIDER >> $UVSCAN_REPORT
|
|
|
301 |
echo >> $UVSCAN_REPORT
|
|
|
302 |
|
|
|
303 |
# min report
|
|
|
304 |
echo $DIVIDER >> $UVSCAN_REPORT_MIN
|
|
|
305 |
echo $PART_TOSCAN >> $UVSCAN_REPORT_MIN
|
|
|
306 |
echo $DIVIDER >> $UVSCAN_REPORT_MIN
|
|
|
307 |
head -n 10 $REPORT_TMP >> $UVSCAN_REPORT_MIN
|
|
|
308 |
echo -e $DOTS >> $UVSCAN_REPORT_MIN
|
|
|
309 |
tail -n 12 $REPORT_TMP >> $UVSCAN_REPORT_MIN
|
|
|
310 |
echo $DIVIDER >> $UVSCAN_REPORT_MIN
|
|
|
311 |
grep " Found: " $REPORT_TMP >> $UVSCAN_REPORT_MIN
|
|
|
312 |
grep " Found: " $REPORT_TMP
|
|
|
313 |
if [ "$?" = "0" ]; then
|
|
|
314 |
echo "VIRUS INFECTION FOUND !!!" >> $UVSCAN_REPORT_MIN
|
|
|
315 |
[ $XDIALOG ] && echo "VIRUS INFECTION FOUND !!!"
|
|
|
316 |
echo $DIVIDER >> $UVSCAN_REPORT_MIN
|
|
|
317 |
fi
|
|
|
318 |
echo >> $UVSCAN_REPORT_MIN
|
|
|
319 |
|
|
|
320 |
rm -f $REPORT_TMP
|
|
|
321 |
touch $REPORT_TMP
|
|
|
322 |
|
|
|
323 |
[ $XDIALOG ] && echo " done."
|
|
|
324 |
}
|
|
|
325 |
|
|
|
326 |
|
|
|
327 |
### ------------------------------------------------------------
|
|
|
328 |
report_clam()
|
|
|
329 |
{
|
|
|
330 |
[ $XDIALOG ] && echo -n "Creating Clam report... "
|
|
|
331 |
|
|
|
332 |
# create report (normal and min)
|
|
|
333 |
# normal report
|
|
|
334 |
echo $DIVIDER >> $CLAM_REPORT
|
|
|
335 |
echo $PART_TOSCAN >> $CLAM_REPORT
|
|
|
336 |
echo $DIVIDER >> $CLAM_REPORT
|
|
|
337 |
cat $REPORT_TMP >> $CLAM_REPORT
|
|
|
338 |
echo $DIVIDER >> $CLAM_REPORT
|
|
|
339 |
echo >> $CLAM_REPORT
|
|
|
340 |
|
|
|
341 |
# min report
|
|
|
342 |
echo $DIVIDER >> $CLAM_REPORT_MIN
|
|
|
343 |
echo $PART_TOSCAN >> $CLAM_REPORT_MIN
|
|
|
344 |
echo $DIVIDER >> $CLAM_REPORT_MIN
|
|
|
345 |
head -n 5 $REPORT_TMP >> $CLAM_REPORT_MIN
|
|
|
346 |
echo -e $DOTS >> $CLAM_REPORT_MIN
|
|
|
347 |
tail -n 15 $REPORT_TMP >> $CLAM_REPORT_MIN
|
|
|
348 |
echo $DIVIDER >> $CLAM_REPORT_MIN
|
|
|
349 |
grep " FOUND$" $REPORT_TMP >> $CLAM_REPORT_MIN
|
|
|
350 |
grep " FOUND$" $REPORT_TMP
|
|
|
351 |
if [ "$?" = "0" ]; then
|
|
|
352 |
echo "VIRUS INFECTION FOUND !!!" >> $CLAM_REPORT_MIN
|
|
|
353 |
[ $XDIALOG ] && echo "VIRUS INFECTION FOUND !!!"
|
|
|
354 |
echo $DIVIDER >> $CLAM_REPORT_MIN
|
|
|
355 |
fi
|
|
|
356 |
echo >> $CLAM_REPORT_MIN
|
|
|
357 |
|
|
|
358 |
rm -f $REPORT_TMP
|
|
|
359 |
touch $REPORT_TMP
|
|
|
360 |
|
|
|
361 |
[ $XDIALOG ] && echo " done."
|
|
|
362 |
}
|
|
|
363 |
|
|
|
364 |
|
|
|
365 |
### ------------------------------------------------------------
|
|
|
366 |
show_reports()
|
|
|
367 |
{
|
|
|
368 |
### show report
|
|
|
369 |
[ $FPROT_ON ] && $DIALOG --title "$TITLE: F-Prot Small Report" \
|
|
|
370 |
--textbox $FPROT_REPORT_MIN 0 0
|
|
|
371 |
[ $UVSCAN_ON ] && $DIALOG --title "$TITLE: McAfee Small Report" \
|
|
|
372 |
--textbox $UVSCAN_REPORT_MIN 0 0
|
|
|
373 |
[ $CLAM_ON ] && $DIALOG --title "$TITLE: Clam Small Report" \
|
|
|
374 |
--textbox $CLAM_REPORT_MIN 0 0
|
|
|
375 |
|
|
|
376 |
### info about report files
|
|
|
377 |
REPORT_MESSAGE="\nVirus Scan Reports can be found in $REPORT_DIR\n"
|
|
|
378 |
$DIALOG --title "$TITLE" --no-close --infobox "$REPORT_MESSAGE" 0 0 5
|
|
|
379 |
[ $XDIALOG ] && echo -e "$REPORT_MESSAGE"
|
|
|
380 |
|
|
|
381 |
}
|
|
|
382 |
|
|
|
383 |
|
|
|
384 |
### ------------------------------------------------------------
|
|
|
385 |
scan()
|
|
|
386 |
{
|
|
|
387 |
if [ -z "$PARTS" -a -z "$FILES" ]; then
|
|
|
388 |
MESSAGE3="Please select partition(s) or directory/file first."
|
|
|
389 |
$DIALOG --title "$TITLE" --msgbox "$MESSAGE3" 0 0
|
|
|
390 |
return
|
|
|
391 |
fi
|
|
|
392 |
|
|
|
393 |
if [ -z "$SCAN_WITH" ]; then
|
|
|
394 |
MESSAGE_SORRY="Sorry, either no scan engine selected or available."
|
|
|
395 |
$DIALOG --title "$TITLE" --msgbox "$MESSAGE_SORRY" 0 0
|
|
|
396 |
return
|
|
|
397 |
fi
|
|
|
398 |
|
|
|
399 |
### mount partitions
|
|
|
400 |
TOSCAN=""
|
|
|
401 |
for i in $PARTS; do
|
|
|
402 |
mkdir -p /mnt/${i/\/dev\//}
|
|
|
403 |
# already mounted?
|
|
|
404 |
df $i | cut -d" " -f1 | grep -q "$i"
|
|
|
405 |
if [ $? != "0" ]; then
|
|
|
406 |
mount -o "ro" $i /mnt/${i/\/dev\//}
|
|
|
407 |
if [ "$?" != "0" ]; then
|
|
|
408 |
MESSAGE_UMOUNT="Partiton $i could not be mounted."
|
|
|
409 |
$DIALOG --title "$TITLE" --msgbox "$MESSAGE_UMOUNT" 0 0
|
|
|
410 |
else
|
|
|
411 |
TOSCAN="$TOSCAN /mnt/${i/\/dev\//}"
|
|
|
412 |
fi
|
|
|
413 |
else
|
|
|
414 |
mountpoint=$( df $i | grep "$i" | awk '{ print $6 }' )
|
|
|
415 |
echo "$i is already mounted at $mountpoint"
|
|
|
416 |
TOSCAN="$TOSCAN $mountpoint"
|
|
|
417 |
fi
|
|
|
418 |
done
|
|
|
419 |
TOSCAN="$TOSCAN $FILES"
|
|
|
420 |
|
|
|
421 |
MESSAGE4="Scanning files on"
|
|
|
422 |
MESSAGE5="Searching for files, that will be scanned ..."
|
|
|
423 |
|
|
|
424 |
### define where to report
|
|
|
425 |
define_report
|
|
|
426 |
|
|
|
427 |
### watch $REPORT_TMP
|
|
|
428 |
if [ $XDIALOG ]; then
|
|
|
429 |
# is there already a tail -F running?
|
|
|
430 |
ps wwaux | grep tail | grep "$REPORT_TMP" | grep -q -v grep
|
|
|
431 |
if [ "$?" != "0" ]; then
|
|
|
432 |
xterm -sb -title "tail -F $REPORT_TMP" -e tail -F $REPORT_TMP &
|
|
|
433 |
fi
|
|
|
434 |
fi
|
|
|
435 |
|
|
|
436 |
### scan each partition
|
|
|
437 |
for PART_TOSCAN in $TOSCAN; do
|
|
|
438 |
|
|
|
439 |
[ $XDIALOG ] && echo "Scanning $PART_TOSCAN... "
|
|
|
440 |
|
|
|
441 |
### scan with FPROT
|
|
|
442 |
if [ $FPROT_ON ]; then
|
|
|
443 |
|
|
|
444 |
{ max=$(find $PART_TOSCAN -type f | wc -l )
|
|
|
445 |
echo -e "XXX\nF-Prot: $MESSAGE4: $PART_TOSCAN\nXXX"
|
|
|
446 |
$FPROT $FPROT_OPT -report=$REPORT_TMP $PART_TOSCAN | grep "^$PART_TOSCAN" | sed 's/->.*//g' | uniq | while read a; do count=$[count+1]; echo $[count*100/max]; done
|
|
|
447 |
} | $DIALOG --title "$TITLE" --gauge "$MESSAGE5 $PART_TOSCAN" 10 40
|
|
|
448 |
|
|
|
449 |
report_fprot
|
|
|
450 |
fi
|
|
|
451 |
|
|
|
452 |
### scan with UVSCAN (McAfee)
|
|
|
453 |
if [ $UVSCAN_ON ]; then
|
|
|
454 |
|
|
|
455 |
{ max=$(find $PART_TOSCAN | wc -l )
|
|
|
456 |
echo -e "XXX\nMcAfee: $MESSAGE4: $PART_TOSCAN\nXXX"
|
|
|
457 |
$UVSCAN $UVSCAN_OPT $PART_TOSCAN 2>/dev/null | tee $REPORT_TMP 2>/dev/null | grep "^Scanning" | grep -v "\.zip" | grep -v "\.tar" | grep -v ".\tgz" | while read a; do count=$[count+1]; echo $[count*100/max]; done
|
|
|
458 |
} | $DIALOG --title "$TITLE" --gauge "$MESSAGE5 $PART_TOSCAN" 10 40
|
|
|
459 |
|
|
|
460 |
report_uvscan
|
|
|
461 |
fi
|
|
|
462 |
|
|
|
463 |
### scan clamscan (Clam)
|
|
|
464 |
if [ $CLAM_ON ]; then
|
|
|
465 |
|
|
|
466 |
{ max=$(find $PART_TOSCAN -type f | wc -l )
|
|
|
467 |
echo -e "XXX\nClam: $MESSAGE4: $PART_TOSCAN\nXXX"
|
|
|
468 |
$CLAM $CLAM_OPT $PART_TOSCAN 2>/dev/null | tee $REPORT_TMP 2>/dev/null | grep "^$PART_TOSCAN" | while read a; do count=$[count+1]; echo $[count*100/max]; done
|
|
|
469 |
} | $DIALOG --title "$TITLE" --gauge "$MESSAGE5 $PART_TOSCAN" 10 40
|
|
|
470 |
|
|
|
471 |
report_clam
|
|
|
472 |
fi
|
|
|
473 |
|
|
|
474 |
done
|
|
|
475 |
|
|
|
476 |
### unmount partitions
|
|
|
477 |
for i in $PARTS; do
|
|
|
478 |
umount /mnt/${i/\/dev\//} 2>/dev/null
|
|
|
479 |
done
|
|
|
480 |
|
|
|
481 |
### show reports
|
|
|
482 |
show_reports
|
|
|
483 |
|
|
|
484 |
}
|
|
|
485 |
|
|
|
486 |
|
|
|
487 |
### ------------------------------------------------------------
|
|
|
488 |
shutdown ()
|
|
|
489 |
{
|
|
|
490 |
$DIALOG --title "$TITLE" --radiolist "Reboot or shutdown the PC?" 0 0 3 poweroff "" on reboot "" off 2>$TMP
|
|
|
491 |
ACTION=$(cat $TMP)
|
|
|
492 |
if [ $ACTION ]; then
|
|
|
493 |
$ACTION
|
|
|
494 |
exit 1
|
|
|
495 |
fi
|
|
|
496 |
}
|
|
|
497 |
|
|
|
498 |
|
|
|
499 |
### ------------------------------------------------------------
|
|
|
500 |
quit ()
|
|
|
501 |
{
|
|
|
502 |
|
|
|
503 |
# kill all tails to log files
|
|
|
504 |
ps wwaux | grep tail | grep "$REPORT_TMP" | grep -v grep | awk '{ print $2 }' | while read pid; do
|
|
|
505 |
kill $pid 2>/dev/null
|
|
|
506 |
done
|
|
|
507 |
echo "Exit."
|
|
|
508 |
|
|
|
509 |
}
|
|
|
510 |
|
|
|
511 |
|
|
|
512 |
### ------------------------------------------------------------
|
|
|
513 |
online_update ()
|
|
|
514 |
{
|
|
|
515 |
echo "Run online update "
|
|
|
516 |
# remove old temporary dir
|
|
|
517 |
rm -rf /var/tmp/f-prot
|
|
|
518 |
# clamd running?
|
|
|
519 |
[ -x /etc/init.d/clamd ] && /etc/init.d/clamd status >/dev/null && CALMD_WAS_RUNNING="true"
|
|
|
520 |
# which update commands
|
|
|
521 |
CHECKUPDATES=""
|
|
|
522 |
[ "$FPROT_CHECKUPDATES" ] && CHECKUPDATES="$CHECKUPDATES $FPROT_CHECKUPDATES ;"
|
|
|
523 |
[ "$UVSCAN_CHECKUPDATES" ] && CHECKUPDATES="$CHECKUPDATES $UVSCAN_CHECKUPDATES ;"
|
|
|
524 |
[ "$CLAM_CHECKUPDATES" ] && CHECKUPDATES="$CHECKUPDATES $CLAM_CHECKUPDATES ;"
|
|
|
525 |
|
|
|
526 |
if [ -n "$DISPLAY" ]; then
|
|
|
527 |
xterm -sb -e "$CHECKUPDATES echo 'Press a key to continue ...'; read -n1"
|
|
|
528 |
else
|
|
|
529 |
$CHECKUPDATES echo 'Press a key to continue ...'; read -n1
|
|
|
530 |
fi
|
|
|
531 |
# clean up
|
|
|
532 |
rm -rf /var/tmp/f-prot
|
|
|
533 |
[ -x /etc/init.d/clamd ] && [ ! $CALMD_WAS_RUNNING ] && /etc/init.d/clamd stop >/dev/null
|
|
|
534 |
}
|
|
|
535 |
|
|
|
536 |
### ------------------------------------------------------------
|
|
|
537 |
### Main Program
|
|
|
538 |
### ------------------------------------------------------------
|
|
|
539 |
|
|
|
540 |
### find partitons
|
|
|
541 |
find_partitions
|
|
|
542 |
|
|
|
543 |
### print welcome message
|
|
|
544 |
welcome_message
|
|
|
545 |
|
|
|
546 |
### menu
|
|
|
547 |
### ------------------------------------------------------------
|
|
|
548 |
|
|
|
549 |
MENU_1="Select partition(s)"
|
|
|
550 |
MENU_2="(or: Select a directory/file)"
|
|
|
551 |
MENU_3="Choose Scan Engine(s)"
|
|
|
552 |
MENU_4="Do Online-Update"
|
|
|
553 |
MENU_5="Start Scanning"
|
|
|
554 |
MENU_6="Reboot/Shutdown"
|
|
|
555 |
MENU_7="Quit"
|
|
|
556 |
|
|
|
557 |
while true; do
|
|
|
558 |
|
|
|
559 |
SCAN_WITH=""
|
|
|
560 |
[ $FPROT_ON ] && SCAN_WITH=" $FPROT_NAME"
|
|
|
561 |
[ $UVSCAN_ON ] && SCAN_WITH="$SCAN_WITH $UVSCAN_NAME"
|
|
|
562 |
[ $CLAM_ON ] && SCAN_WITH="$SCAN_WITH $CLAM_NAME"
|
|
|
563 |
|
|
|
564 |
$DIALOG --title "$TITLE" \
|
|
|
565 |
--menu "$MENU_TITLE" 0 0 7\
|
|
|
566 |
1 "$MENU_1"\
|
|
|
567 |
2 "$MENU_2"\
|
|
|
568 |
3 "$MENU_3" \
|
|
|
569 |
4 "$MENU_4" \
|
|
|
570 |
5 "$MENU_5 (with$SCAN_WITH)" \
|
|
|
571 |
6 "$MENU_6" \
|
|
|
572 |
7 "$MENU_7" \
|
|
|
573 |
2> $TMP
|
|
|
574 |
|
|
|
575 |
[ $? -ne 0 ] && break
|
|
|
576 |
|
|
|
577 |
CHOICE=$(cat $TMP)
|
|
|
578 |
|
|
|
579 |
case "$CHOICE" in
|
|
|
580 |
1)
|
|
|
581 |
choose_parts
|
|
|
582 |
;;
|
|
|
583 |
2)
|
|
|
584 |
choose_dirfile
|
|
|
585 |
;;
|
|
|
586 |
3)
|
|
|
587 |
choose_engine
|
|
|
588 |
;;
|
|
|
589 |
4)
|
|
|
590 |
online_update
|
|
|
591 |
;;
|
|
|
592 |
5)
|
|
|
593 |
scan
|
|
|
594 |
;;
|
|
|
595 |
6)
|
|
|
596 |
shutdown || break
|
|
|
597 |
;;
|
|
|
598 |
7)
|
|
|
599 |
break
|
|
|
600 |
;;
|
|
|
601 |
esac
|
|
|
602 |
done
|
|
|
603 |
|
|
|
604 |
# clean up and quit
|
|
|
605 |
quit
|