Subversion Repositories livecd

Rev

Rev 1 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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