1075
#########################################
1076
# Check for MSRBL database file updates #
1077
#########################################
1078
if [ -n "$msrbl_dbs" ] ; then
1081
comment "======================================================================"
1082
comment "MSRBL Database File Updates"
1083
comment "======================================================================"
1084
msrbl_mirror_ips=`dig +tcp +short $msrbl_url`
1085
for msrbl_mirror_ip in $msrbl_mirror_ips ; do
1086
msrbl_mirror_name=`host $msrbl_mirror_ip | awk '{print $NF}' | cut -d "(" -f2 | sed 's/\(.*\)./\1/'`
1087
msrbl_mirror_site_info="$msrbl_mirror_name $msrbl_mirror_ip"
1089
comment "MSRBL mirror site used: $msrbl_mirror_site_info"
1090
log "INFO - MSRBL mirror site used: $msrbl_mirror_site_info"
1091
if rsync $rsync_output_level $no_motd --files-from=$msrbl_include_dbs -ctuz --stats \
1092
$contimeout --timeout=30 rsync://$msrbl_mirror_ip/msrbl $msrbl_dir 2>/dev/null
1094
msrbl_rsync_success="1"
1095
for db_file in $msrbl_dbs ; do
1096
if ! cmp -s $msrbl_dir/$db_file $clam_dbs/$db_file ; then
1098
comment "Testing updated MSRBL database file: $db_file"
1099
log "INFO - Testing updated MSRBL database file: $db_file"
1100
if [ "$?" = "0" ] ; then
1101
db_ext=`echo $db_file | cut -d "." -f2`
1102
if [ -z "$ham_dir" -o "$db_ext" != "ndb" ]
1104
if clamscan --quiet -d "$msrbl_dir/$db_file" "$config_dir/scan-test.txt" 2>/dev/null
1106
comment "Clamscan reports Sanesecurity $db_file database integrity tested good"
1107
log "INFO - Clamscan reports Sanesecurity $db_file database integrity tested good" ; true
1109
echo "Clamscan reports Sanesecurity $db_file database integrity tested BAD - SKIPPING"
1110
log "WARNING - Clamscan reports Sanesecurity $db_file database integrity tested BAD - SKIPPING" ; false
1112
(test "$keep_db_backup" = "yes" && cp -f $clam_dbs/$db_file $clam_dbs/$db_file-bak 2>/dev/null ; true) && \
1113
if rsync -cqt $msrbl_dir/$db_file $clam_dbs
1115
perms chown $clam_user:$clam_group $clam_dbs/$db_file
1116
comment "Successfully updated MSRBL production database file: $db_file"
1117
log "INFO - Successfully updated MSRBL production database file: $db_file"
1121
echo "Failed to successfully update MSRBL production database file: $db_file - SKIPPING"
1122
log "WARNING - Failed to successfully update MSRBL production database file: $db_file - SKIPPING"
1125
grep -h -v -f "$config_dir/whitelist.hex" "$msrbl_dir/$db_file" > "$test_dir/$db_file"
1126
clamscan --infected --no-summary -d "$test_dir/$db_file" "$ham_dir"/* | \
1127
sed 's/\.UNOFFICIAL FOUND//' | awk '{print $NF}' > "$config_dir/whitelist.txt"
1128
grep -h -f "$config_dir/whitelist.txt" "$test_dir/$db_file" | \
1129
cut -d "*" -f2 | sort | uniq >> "$config_dir/whitelist.hex"
1130
grep -h -v -f "$config_dir/whitelist.hex" "$test_dir/$db_file" > "$test_dir/$db_file-tmp"
1131
mv -f "$test_dir/$db_file-tmp" "$test_dir/$db_file"
1132
if clamscan --quiet -d "$test_dir/$db_file" "$config_dir/scan-test.txt" 2>/dev/null
1134
comment "Clamscan reports Sanesecurity $db_file database integrity tested good"
1135
log "INFO - Clamscan reports Sanesecurity $db_file database integrity tested good" ; true
1137
echo "Clamscan reports Sanesecurity $db_file database integrity tested BAD - SKIPPING"
1138
log "WARNING - Clamscan reports Sanesecurity $db_file database integrity tested BAD - SKIPPING" ; false
1140
(test "$keep_db_backup" = "yes" && cp -f $clam_dbs/$db_file $clam_dbs/$db_file-bak 2>/dev/null ; true) && \
1141
if rsync -cqt $test_dir/$db_file $clam_dbs
1143
perms chown $clam_user:$clam_group $clam_dbs/$db_file
1144
comment "Successfully updated MSRBL production database file: $db_file"
1145
log "INFO - Successfully updated MSRBL production database file: $db_file"
1149
echo "Failed to successfully update MSRBL production database file: $db_file - SKIPPING"
1150
log "WARNING - Failed to successfully update MSRBL production database file: $db_file - SKIPPING"
1156
if [ "$msrbl_update" != "1" ]
1159
comment "No MSRBL database file updates found"
1160
log "INFO - No MSRBL database file updates found"
1166
comment "Connection to $msrbl_mirror_site_info failed - Trying next mirror site..."
1167
log "WARNING - Connection to $msrbl_mirror_site_info failed - Trying next mirror site..."
1170
if [ "$msrbl_rsync_success" != "1" ] ; then
1172
echo "Access to all MSRBL mirror sites failed - Check for connectivity issues or"
1173
echo "signature database name(s) misspelled in the script's configuration file."
1174
log "WARNING - Access to all MSRBL mirror sites failed - Check for connectivity issues or"
1175
log "WARNING - signature database name(s) misspelled in the script's configuration file."
1179
1064
#######################################################################
1180
1065
# Check for updated SecuriteInfo database files every set number of #
1181
1066
# hours as defined in the "USER CONFIGURATION" section of this script #
1182
1067
#######################################################################
1183
1068
if [ -n "$si_dbs" ] ; then
1069
rm -f "$si_dir/*.gz"
1184
1070
if [ -s "$config_dir/last-si-update.txt" ]
1186
1072
last_si_update=`cat $config_dir/last-si-update.txt`
1212
1096
comment "Checking for updated SecuriteInfo database file: $db_file"
1214
1098
si_db_update="0"
1099
if [ -s "$si_dir/$db_file" ]
1101
z_opt="-z $si_dir/$db_file"
1215
1105
if curl $curl_proxy $curl_output_level --connect-timeout 15 --max-time 60 \
1216
-L -R $z_opt -o $si_dir/$db_file.gz http://$si_url/$db_file.gz
1106
-L -R $z_opt -o $si_dir/$db_file http://$si_url/$db_file
1219
test -s $si_dir/$db_file.gz && DT2=`ls -l $si_dir/$db_file.gz | awk '{print $6,$7}'` && \
1220
test "$DT1" != "$DT2" -o ! -s "$si_dir/$db_file" && gunzip -cdfq $si_dir/$db_file.gz > $si_dir/$db_file
1221
1109
if ! cmp -s $si_dir/$db_file $clam_dbs/$db_file ; then
1223
comment "Testing updated SecuriteInfo database file: $db_file"
1224
log "INFO - Testing updated SecuriteInfo database file: $db_file"
1225
1110
if [ "$?" = "0" ] ; then
1226
1111
db_ext=`echo $db_file | cut -d "." -f2`
1113
comment "Testing updated SecuriteInfo database file: $db_file"
1114
log "INFO - Testing updated SecuriteInfo database file: $db_file"
1227
1115
if [ -z "$ham_dir" -o "$db_ext" != "ndb" ]
1229
1117
if clamscan --quiet -d "$si_dir/$db_file" "$config_dir/scan-test.txt" 2>/dev/null