#PEAR_Config 0.9 a:12:{s:7:"php_dir";s:67:"//pear/php";s:8:"data_dir";s:68:"//pear/data";s:7:"www_dir";s:67:"//pear/www";s:7:"cfg_dir";s:67:"//pear/cfg";s:7:"ext_dir";s:67:"//pear/ext";s:7:"doc_dir";s:68:"//pear/docs";s:8:"test_dir";s:69:"//pear/tests";s:9:"cache_dir";s:69:"//pear/cache";s:12:"download_dir";s:72:"//pear/download";s:8:"temp_dir";s:68:"//pear/temp";s:7:"bin_dir";s:63:"//pear";s:7:"man_dir";s:67:"//pear/man";}
|
Server IP : 99.192.176.69 / Your IP : 216.73.217.68 Web Server : Apache System : Linux platinumpuzzy2.eosdns.net 3.10.0-1160.71.1.el7.x86_64 #1 SMP Tue Jun 28 15:37:28 UTC 2022 x86_64 User : bbwcamhouse ( 1000) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0755) : /../etc/python/../python/../python/../python/../python/../pm/../python/../../../usr/local/sbin/ |
| [ Home ] | [ C0mmand ] | [ Upload File ] |
|---|
#!/bin/bash
#
##
# Linux Malware Detect v0.6
# (C) 2002-2011, R-fx Networks <proj@r-fx.org>
# (C) 2011, Ryan MacDonald <ryan@r-fx.org>
# inotifywait (C) 2007, Rohan McGovern <rohan@mcgovern.id.au>
# Mojo Fork (C) 2013, Joseph Laws <jlaws@mojohost.com>
# This program may be freely redistributed under the terms of the GNU GPL v2
##
#
ver=0.6
inspath=/usr/local/mojo/security/maldet
cnf=$inspath/conf.maldet
intcnf=$inspath/internals.conf
datestamp=$(date +"%m%d%y-%H%M")
header() {
echo "Linux Malware Detect v$ver"
echo " (C) 2002-2011, R-fx Networks <proj@r-fx.org>"
echo " (C) 2011, Ryan MacDonald <ryan@r-fx.org>"
echo "inotifywait (C) 2007, Rohan McGovern <rohan@mcgovern.id.au>"
echo "Mojo Fork (C) 2013, Joseph Laws <jlaws@mojohost.com>"
echo "This program may be freely redistributed under the terms of the GNU GPL v2"
}
if [ -f "$cnf" ] && [ ! "$cnf" == "" ]; then
source $cnf
else
header
echo "maldet($$): {glob} $cnf not found, aborting."
exit 1
fi
if [ -f "$intcnf" ] && [ ! "$intcnf" == "" ]; then
source $intcnf
else
header
echo "maldet($$): {glob} $intcnf not found, aborting."
exit 1
fi
#if [ ! "$(whoami)" == "root" ]; then
# if [ -z "$public_scan" ] || [ "$public_scan" == "0" ]; then
# args="$@"
# if [[ "$args" =~ "modsec" ]]; then
# echo "1 maldet: OK"
# exit
# fi
# header
# echo "public scanning is currently disabled, please contact your system administrator to enable public_scan in conf.maldet."
# exit
# fi
# pub=1
# user=$(whoami)
# quardir=$inspath/pub/$user/quar
# sessdir=$inspath/pub/$user/sess
# tmpdir=$inspath/pub/$user/tmp
# logf=$inspath/pub/$user/event_log
# mkdir -p $quardir >> /dev/null 2>&1
# mkdir -p $sessdir >> /dev/null 2>&1
# mkdir -p $tmpdir >> /dev/null 2>&1
# touch $logf
#else
# echo $ver > $lmd_verf
#fi
if [ -z "$wget" ]; then
header
echo "could not find required binary wget, aborting."
exit 1
fi
if [ -z "$md5sum" ]; then
header
echo "could not find required binary md5sum, aborting."
exit 1
fi
if [ -z "$od" ]; then
header
echo "could not find required binary od, aborting."
exit 1
fi
if [ -z "$find" ]; then
header
echo "could not find required binary find, aborting."
exit 1
fi
if [ -z "$perl" ]; then
header
echo "could not find required binary perl, aborting."
exit 1
fi
if [ -z "$clamav" ]; then
header
echo "Could not find required binary clamav, aborting."
exit 1
fi
if [ -z "$clamd" ]; then
header
echo "Could not find required binary clamd, aborting."
exit 1
fi
if [ -z "$curl" ]; then
header
echo "Could not find required binary curl, aborting."
exit
fi
if [ -z "$EDITOR" ]; then
EDITOR=less
# defedit=$(which nano 2> /dev/null)
# if [ -z "$defedit" ]; then
# EDITOR=vi
# else
# EDITOR=nano
# fi
fi
if [[ $(find --version | awk '{print $4}' | head -n 1 | awk -F. '{print $1.$2}') -le 41 ]]; then
FIND=OLD
else
FIND=CURRENT
fi
if [ "$hex_fifo_scan" == "1" ]; then
mkfifo=$(which mkfifo 2> /dev/null)
if [ -f "$mkfifo" ] && [ ! -p "$hex_fifo" ]; then
$mkfifo -m 666 $hex_fifo
fi
fi
usage_short() {
cat <<EOF
usage maldet [-h|--help] [-l|--log] [-e|--report] [-p|--purge] [-c|--checkout]
[-b|--background] [-m|--monitor] [-k|--kill-monitor] [-a|--scan-all] [-r|--scan-recent]
[-q|--quarantine] [-s|--restore] [-n|--clean] [-d|--update-ver] [-f|--force-reinstall]
[--minutes]
EOF
}
usage_long() {
cat<<EOF
usage $0 [ OPTION ]
-b, --background
Execute operations in the background, ideal for large scans
e.g: maldet -b -r /home/?/public_html 7
-d, --update-ver
Update the installed maldet binary from mojohost
-f, --force-reinstall
Force a full reinstall of maldet (configs, crons, etc)
-m, --monitor USERS|PATHS|FILE
Run maldet with inotify kernel level file create/modify monitoring
If USERS is specified, monitor user homedirs for UID's > 500
If FILE is specified, paths will be extracted from file, line spaced
If PATHS are specified, must be comma spaced list, NO WILDCARDS!
e.g: maldet --monitor users
e.g: maldet --monitor /root/monitor_paths
e.g: maldet --monitor /home/mike,/home/ashton
-k, --kill
Terminate inotify monitoring service
-r, --scan-recent PATH DAYS
Scan files created/modified in the last X days (default: 7d, wildcard: ?)
e.g: maldet -r /home/?/public_html 2
--minutes ##
Option to scan given path based on files added within X minutes of present (default: 30m)
e.g: maldet --minutes /home/?/public_html 30
-a, --scan-all PATH
Scan all files in path (default: /home, wildcard: ?)
e.g: maldet -a /home/?/public_html
-c, --checkout FILE
Upload suspected malware to rfxn.com for review & hashing into signatures
-l, --log
View maldet log file events
-e, --report SCANID email
View scan report of most recent scan or of a specific SCANID and optionally
e-mail the report to a supplied e-mail address
e.g: maldet --report
e.g: maldet --report list
e.g: maldet --report 050910-1534.21135
e.g: maldet --report SCANID user@domain.com
-s, --restore FILE|SCANID
Restore file from quarantine queue to orginal path or restore all items from
a specific SCANID
e.g: maldet --restore /usr/local/mojo/security/maldet/quarantine/config.php.23754
e.g: maldet --restore 050910-1534.21135
-q, --quarantine SCANID
Quarantine all malware from report SCANID
e.g: maldet --quarantine 050910-1534.21135
-n, --clean SCANID
Try to clean & restore malware hits from report SCANID
e.g: maldet --clean 050910-1534.21135
-U, --user USER
Set execution under specified user, ideal for restoring from user quarantine or
to view user reports.
e.g: maldet --user nobody --report
e.g: maldet --user nobody --restore 050910-1534.21135
-co, --config-option VAR1=VALUE,VAR2=VALUE,VAR3=VALUE
Set or redefine the value of conf.maldet config options
e.g: maldet --config-option email_addr=you@domain.com,quar_hits=1
-p, --purge
Clear logs, quarantine queue, session and temporary data.
EOF
}
eout() {
arg=$1
stdout=$2
appn=maldet
if [ ! -f "$logf" ]; then
touch $logf
fi
logf_size=$($wc -l $logf | awk '{print$1}')
if [ "$logf_size" -ge "20000" ]; then
trim=1000
printf "%s\n" "$trim,${logf_size}d" w | ed -s $logf
fi
if [ ! "$arg" == "" ]; then
echo "$(date +"%b %d %H:%M:%S") $(hostname -s) $appn($$): $arg" >> $logf
if [ ! -z "$stdout" ]; then
echo "$appn($$): $arg"
fi
fi
}
trap_exit() {
if [ "$svc" == "m" ]; then
echo
eout "{glob} monitor interrupt by user, sending kill." 1
monitor_kill
exit
elif [ "$svc" == "a" ] || [ "$sv" == "r" ]; then
echo
gen_report
if [ ! "$tot_hit" == "0" ]; then
if [ "$suppress_cleanhit" == "1" ] && [ ! "$tot_hit" == "$cl_hit" ]; then
alert file $nsess
elif [ "$suppress_cleanhit" == "0" ]; then
alert file $nsess
fi
fi
mv $scan_session $nsess_hits
rm -f $find_results $scan_session $tmp_ignore_paths
eout "{glob} scan interrupt by user, aborting scan..." 1
eout "{scan} scan report saved, to view run: maldet --report $datestamp.$$" 1
exit
fi
}
clean() {
file="$1"
hitname="$2"
v="$3"
spacecleanup
sh_hitname=$(echo $hitname | sed -e 's/{HEX}//' -e 's/{MD5}//' | tr '.' ' ' | awk '{print$1"."$2"."$3}')
if [ -d "$cldir" ] && [ "$quar_clean" == "1" ] && [ -f "$file" ]; then
if [ -f "$cldir/$sh_hitname" ] && [ -f "$file.info" ]; then
file_path=$(cat $file.info | awk '{print$4}')
eout "{clean} restoring $file for cleaning attempt" $v
restore "$file" >> /dev/null 2>&1
eout "{clean} trying to clean $file_path with $sh_hitname rule" $v
$(cat $cldir/$sh_hitname) $file_path
eout "{clean} rescanning $file_path for malware hits" $v
cleanst="1"
scan_stage1 "$file_path" >> /dev/null 2>&1
unset cleanst
if [ -f "$file_path" ]; then
echo "$file_path" >> $sessdir/clean.$$
echo "$file_path" >> $tmpdir/.clean.alltime
eout "{clean} clean successful on $file_path" $v
else
eout "{clean} clean failed on $file_path and returned to quarantine" $v
fi
elif [ -f "$cldir/$sh_hitname" ] && [ -f "$file" ]; then
file_path="$file"
eout "{clean} trying to clean $file with $sh_hitname rule" $v
$(cat $cldir/$sh_hitname) "$file_path"
eout "{clean} scanning $file for malware hits" $v
cleanst="1"
unset clean_failed
scan_stage1 "$file_path" 1 >> /dev/null 2>&1
unset cleanst
if [ "$clean_failed" == "1" ]; then
eout "{clean} clean failed on $file" $v
else
echo "$file" >> $sessdir/clean.$$
echo "$file_path" >> $tmpdir/.clean.alltime
eout "{clean} clean successful on $file" $v
fi
fi
else
eout "file path error on $file, aborting." $v
exit
fi
}
restore() {
file="$1"
fname=$(basename $file)
if [ -f "$quardir/$file" ] && [ -f "$quardir/$file.info" ]; then
file_owner=$(cat $quardir/$file.info | awk '{print$1}')
file_group=$(cat $quardir/$file.info | awk '{print$2}')
file_mode=$(cat $quardir/$file.info | awk '{print$3}')
file_path=$(cat $quardir/$file.info | awk '{print$4}')
chown $file_owner.$file_group "$quardir/$file" >> /dev/null 2>&1
chmod $file_mode "$quardir/$file" >> /dev/null 2>&1
mv -f "$quardir/$file" "$file_path"
eout "{restore} quarantined file $file restored to $file_path" 1
elif [ -f "$file" ] && [ -f "$file.info" ]; then
file_owner=$(cat $file.info | awk '{print$1}')
file_group=$(cat $file.info | awk '{print$2}')
file_mode=$(cat $file.info | awk '{print$3}')
file_path=$(cat $file.info | awk '{print$4}')
chown $file_owner.$file_group "$file" >> /dev/null 2>&1
chmod $file_mode "$file" >> /dev/null 2>&1
mv -f "$file" "$file_path"
eout "{restore} quarantined file $file restored to $file_path" 1
else
eout "{restore} invalid file or could not be found" 1
fi
}
restore_hitlist() {
hitlist="$sessdir/session.hits.$1"
if [ -f "$hitlist" ]; then
val_aquar=$(tail -n1 $hitlist | awk '{print$5}')
val_mquar=$(tail -n1 $hitlist | awk '{print$3}')
if [ "$val_aquar" ]; then
cat $hitlist | awk '{print$5}' | while read file; do
if [ -f "$file" ]; then
restore $file
fi
done
elif [ "$val_mquar" ]; then
cat $hitlist | awk '{print$3}' | while read file; do
quar_file=$(cat $logf | grep -w "$file" | tail -n1 | awk '{print$12}' | tr -d "'")
restore $quar_file
done
else
eout "{restore} could not find a valid hit list to restore." 1
fi
fi
}
clean_hitlist() {
hitlist="$sessdir/session.hits.$1"
if [ -f "$hitlist" ]; then
cat $hitlist | awk '{print$3}' | while read file; do
if [ -f "$file" ]; then
hitname=$(cat $hitlist | grep $file | awk '{print$1}')
clean "$file" "$hitname" "$1"
else
hitname=$(cat $hitlist | grep $file | awk '{print$1}')
quarfile=$(cat $hitlist | grep $file | awk '{print$5}')
clean "$quarfile" "$hitname" "$1"
fi
done
else
eout "{clean} invalid SCANID, aborting." 1
exit
fi
}
quar_hitlist() {
hitlist="$sessdir/session.hits.$1"
if [ -f "$hitlist" ]; then
cat $hitlist | awk '{print$3}' | while read file; do
if [ -f "$file" ]; then
file_owner=$(stat -c "%U" "$file")
file_group=$(stat -c "%G" "$file")
file_mode=$(stat -c "%a" "$file")
if [ "$pub" == "1" ]; then
chattr -ia "$file" >> /dev/null 2>&1
chmod 400 "$file"
else
chattr -ia "$file"
chmod 000 "$file"
fi
file_name=$(basename "$file")
file_namewc=$(echo $file_name | $wc -m)
rnd="$RANDOM"
mv "$file" "$quardir/$file_name.$rnd"
echo "$file_owner $file_group $file_mode $file" > $quardir/$file_name.$rnd.info
eout "{quar} malware quarantined from '$file' to '$quardir/$file_name.$rnd'" 1
echo "$file => $quardir/$file_name.$rnd" >> $tmpdir/.quar.alltime
if [ "$quar_susp" == "1" ]; then
quar_susp "$file"
fi
if [ "$quar_clean" == "1" ] && [ ! "$cleanst" == "1" ]; then
unset cleanst
hitname=$(cat $hitlist | grep $file | awk '{print$1}')
clean "$quardir/$file_name.$rnd" "$hitname" 1
fi
fi
done
else
echo "{quar} invalid quarantine hit list, aborting."
exit
fi
}
view_report() {
rid="$1"
if [ "$rid" == "list" ]; then
eout "Available Reports:"
ls $sessir/session.[0-9]* 2> /dev/null | while read file; do
SCANID=$(cat $file | grep "SCAN ID")
TIME=$(cat $file | grep "TIME")
if [ ! -z "$SCANID" ] && [ ! -z "$TIME" ]; then
echo "$TIME | $SCANID"
fi
done
exit
fi
if [ -f "$sessdir/session.$rid" ] && [ ! -z "$(echo $2 | grep '\@')" ]; then
cat $sessdir/session.$rid | mail -s "$email_subj" $2
eout "{report} report ID $rid sent to $2" 1
exit
fi
if [ "$rid" == "" ] && [ -f "$sessdir/session.last" ]; then
rid=$(cat $sessdir/session.last)
$EDITOR $sessdir/session.$rid
elif [ -f "$sessdir/session.$rid" ]; then
$EDITOR $sessdir/session.$rid
else
echo "{report} no report found, aborting."
exit
fi
}
view() {
echo "Viewing last 50 lines from $logf:"
tail -n 50 $logf
}
purge() {
:> $logf
rm -f $tmpdir/* $quardir/* $sessdir/*
eout "{glob} logs and quarantine data cleared by user request (-p)" 1
}
quar_susp() {
file="$1"s
user=$(stat -c "%U" "$file")
user_id=$(id -u $user)
if [ ! "$user" == "" ] && [ "$user_id" -ge "$quar_susp_minuid" ]; then
if [ -f "/scripts/suspendacct" ]; then
if [ ! -f "/var/cpanel/suspended/$user" ]; then
/scripts/suspendacct $user "maldet --report $datestamp.$$" >> /dev/null 2>&1
eout "{quar} account $user cpanel suspended" 1
echo "$user" >> $sessdir/suspend.users.$$
echo "$user" >> $tmpdir/.susp.alltime
fi
else
if [ "$(grep $user /etc/passwd | cut -d':' -f7 | grep /bin/false)" == "" ]; then
/usr/sbin/usermod -s /bin/false $user >> /dev/null 2>&1
eout "{quar} account $user suspended; set 'usermod -s /bin/false'"
echo "$user" >> $sessdir/suspend.users.$$
echo "$user" >> $tmpdir/.susp.alltime
fi
fi
fi
}
quar() {
file="$1"
hitname="$2"
spacecleanup
if [[ -f "$file" ]] && [[ -d "$quardir" ]]; then
file_md5sum=$($md5sum "$file" | awk '{print$1}')
file_name=$(basename "$file")
if [ -f "$autoquar_sigs" ] && [[ $(cat "$autoquar_sigs") != "" ]]; then
if [[ $(echo "$hitname" | grep -sif "$autoquar_sigs") == "" ]]; then
QUAR_HIT=0
else
QUAR_HIT=1
fi
fi
if [ "$quar_hits" == "1" ] || [ "$QUAR_HIT" == "1" ]; then
file_owner=$(stat -c "%U" "$file")
file_group=$(stat -c "%G" "$file")
file_mode=$(stat -c "%a" "$file")
eout "MD5SUM: $file_md5sum"
file_namewc=$(echo $file_name | $wc -m)
rnd="$RANDOM"
if [ "$quar_susp" == "1" ]; then
quar_susp "$file"
fi
chattr -ia "$file"
mv "$file" "$quardir/$file_name.$rnd"
if [ "$pub" == "1" ]; then
chmod 400 "$quardir/$file_name.$rnd"
else
chmod 000 "$quardir/$file_name.$rnd"
chown root.root "$quardir/$file_name.$rnd"
fi
echo "$file_owner $file_group $file_mode $file" > $quardir/$file_name.$rnd.info
eout "{quar} malware quarantined from '$file' to '$quardir/$file_name.$rnd'"
echo "$file => $quardir/$file_name.$rnd" >> $tmpdir/.quar.alltime
if [ ! -z "$scan_session" ]; then
if [[ $(grep -sw $file_name $ignore_md5sum | grep -sw $file_md5sum) == "" ]]; then
echo "$hitname : $file : $file_md5sum => $quardir/$file_name.$rnd" >> $scan_session
else
eout "IGNORE_MD5 ==> $hitname : $file : $file_md5sum"
fi
fi
if [ "$quar_clean" == "1" ] && [ ! "$cleanst" == "1" ]; then
unset cleanst
clean "$quardir/$file_name.$rnd" "$hitname"
fi
else
if [ ! -z "$scan_session" ]; then
if [[ $(grep -sw $file_name $ignore_md5sum | grep -sw $file_md5sum) == "" ]] && [[ $(echo "$hitname" | grep -s "Can't") == "" ]]; then
echo "$hitname : $file : $file_md5sum" >> $scan_session
elif [[ $(grep -sw $file_name $ignore_md5sum | grep -sw $file_md5sum) == "" ]] && [[ $(echo "$hitname" | grep -s "Can't") != "" ]]; then
echo "FILE GONE ==> $hitname : $file : $file_md5sum"
else
eout "IGNORE_MD5 ==> $hitname : $file : $file_md5sum"
fi
fi
fi
autoclean $file $hitname
else
eout "{quar} fatal error handling '$file'"
fi
}
scan() {
spath="$1"
spath=$(echo $spath | tr '?' '*')
if [[ ${days} == "" ]]; then
days=""
else
days=$2
fi
if [[ ${minutes} == "" ]]; then
minutes=""
else
minutes=$2
fi
if [ ! -f "$find" ]; then
eout "{scan} could not locate find command" 1
exit
fi
if [ ! -f "$ignore_paths" ]; then
touch $ignore_paths
chmod 640 $ignore_paths
elif [ ! -f "$ignore_sigs" ]; then
touch $ignore_sigs
chmod 640 $ignore_sigs
fi
if [[ "$days" != "" ]]; then
val=$(echo $days | grep "[[:alpha:]]")
if [ ! -z "$val" ]; then
eout "{scan} days value must be numeric value in the range of 1 - 60, reverting to default (7)." 1
days=7
elif [ "$days" -gt "60" ]; then
eout "{scan} days value must be numeric value in the range of 1 - 60, reverting to default (7)." 1
days=7
fi
fi
if [[ "$minutes" != "" ]]; then
val=$(echo $minutes | grep "[[:alpha:]]")
if [ ! -z "$val" ]; then
eout "{scan} minutes value must be numeric value in the range of 1 - 1439, reverting to default (30)." 1
minutes=30
elif [ "$minutes" -gt "1439" ]; then
eout "{scan} minutes value must be numeric value in the range of 1 - 1439, reverting to default (30)." 1
minutes=30
fi
fi
if [[ $(echo "$spath" | grep "*") != "" ]]; then
if [ ! -d $(echo $spath | tr '*' ' ' | awk '{print$1}') ] && [ ! -f $(echo $spath | tr '*' ' ' | awk '{print$1}') ]; then
eout "{scan} invalid path $spath" 1
exit
fi
else
if [ ! -d "$spath" ] && [ ! -f "$spath" ]; then
eout "{scan} invalid path $spath" 1
exit
fi
fi
scan_session=$tmpdir/.sess.$$
find_results=$tmpdir/.find.$$
ignore_paths_tmp=$tmpdir/.tmpignorepaths.$$
touch $find_results
touch $scan_session
touch $ignore_paths_tmp
sigignore
hex_sigs=$($wc -l $dat_hex_cav | awk '{print$1}')
md5_sigs=$($wc -l $dat_md5_cav | awk '{print$1}')
tot_sigs=$[md5_sigs+hex_sigs]
if [ -z "$setmodsec" ]; then
eout "{scan} signatures loaded: $tot_sigs ($md5_sigs MD5 / $hex_sigs HEX)" 1
fi
if [ -f "$ignore_file_ext" ]; then
if [ ! "$(cat $ignore_file_ext)" == "" ]; then
for i in $(cat $ignore_file_ext); do
if [ "$ignore_fext" == "" ]; then
ignore_fext="! -iname *$i"
else
ignore_fext="$ignore_fext ! -iname *$i"
fi
done
fi
fi
if [[ -f "$ignore_paths" ]]; then
if [ ! "$(cat $ignore_paths)" == "" ]; then
if [[ ${FIND} == "OLD" ]]; then
for h in $(cat $ignore_paths); do
echo "-path $h -prune -o " >> $ignore_paths_tmp
done
elif [[ ${FIND} == "CURRENT" ]]; then
for h in $(cat $ignore_paths); do
echo "-wholename $h -prune -o " >> $ignore_paths_tmp
done
fi
ignore_pathsZ=$(cat $ignore_paths_tmp)
fi
fi
if [ "$days" == "" ] && [ "$minutes" == "" ]; then
if [ -z "$setmodsec" ]; then
eout "{scan} building file list for $spath, this might take awhile..." 1
fi
if [[ $(echo "$spath" | grep ' ') != "" ]]; then
$find "$spath" -maxdepth $maxdepth $ignore_pathsZ -type f -size +${minfilesize}c -size -$maxfilesize $ignore_fext -print > $find_results
else
$find $spath -maxdepth $maxdepth $ignore_pathsZ -type f -size +${minfilesize}c -size -$maxfilesize $ignore_fext -print > $find_results
fi
elif [ "$days" != "" ] || [ "$minutes" == "" ]; then
if [ -z "$setmodsec" ]; then
eout "{scan} building file list for $spath of new/modified files from last $days day(s), this might take awhile..." 1
fi
echo "about to scan days"
if [[ $(echo "$spath" | grep ' ') != "" ]]; then
$find "$spath" -maxdepth $maxdepth $ignore_pathsZ -type f -ctime -$days -size +${minfilesize}c -size -$maxfilesize $ignore_fext -print > $find_results
else
$find $spath -maxdepth $maxdepth $ignore_pathsZ -type f -ctime -$days -size +${minfilesize}c -size -$maxfilesize $ignore_fext -print > $find_results
fi
elif [ "$days" != "" ] || [ "$minutes" != "" ]; then
if [ -z "$setmodsec" ]; then
eout "{scan} building file list for $spath of new/modified files from last $minutes minute(s), this might take awhile..." 1
fi
echo "about to scan minutes"
if [[ $(echo "$spath" | grep ' ') != "" ]]; then
$find "$spath" -maxdepth $maxdepth $ignore_pathsZ -type f -cmin -$minutes -size +${minfilesize}c -size -$maxfilesize $ignore_fext -print > $find_results
else
$find $spath -maxdepth $maxdepth $ignore_pathsZ -type f -cmin -$minutes -size +${minfilesize}c -size -$maxfilesize $ignore_fext -print > $find_results
fi
else
echo "Something is wrong with the input of days or minutes...or coder is simply foolish."
exit 1
fi
if [ ! -f "$find_results" ] || [ -z "$(cat $find_results)" ]; then
if [ -z "$setmodsec" ]; then
if [ "$days" == "" ] && [ "$minutes" == "" ]; then
eout "{scan} scan returned zero results, please provide a new path." 1
exit
elif [ "$days" != "" ] && [ "$minutes" == "" ]; then
eout "{scan} scan returned zero results, please increase day(s) range or provide a new path." 1
exit
elif [ "$days" == "" ] && [ "$minutes" != "" ]; then
eout "{scan} scan returned zero results, please increase minute(s) range or provide a new path." 1
exit
fi
fi
fi
res_col="1"
move_to_col="echo -en \\033[${res_col}G"
tot_files=$($wc -l $find_results | awk '{print$1}')
if [ -z "$setmodsec" ]; then
eout "{scan} file list completed, found $tot_files files..." 1
fi
touch $sessdir/clean.$$
if [ ! -f "$scan_session" ]; then
touch $scan_session
fi
if [ ! -z "$setmodsec" ]; then
eout "{scan.modsec} scan of $spath in progress (id: $datestamp.$$)"
fi
cnt=0
if [ -f $(which clamdscan) ]; then
CLAM=$(which clamdscan)
elif [ -f $(which clamscan) ]; then
CLAM=$(which clamscan)
fi
##clamd
if [ -f "$CLAM" ] && [ "$CLAM" == "$(which clamdscan)" ] && [ "$clamav_scan" == "1" ]; then
if [ -z "$setmodsec" ]; then
eout "{scan} found ClamD, using as scanner engine..." 1
fi
if [ "$string_length_scan" == "1" ]; then
if [ -z "$setmodsec" ]; then
eout "{scan} preprocessing file list for string length hits..." 1
scan_strlen list "$find_results" >> /dev/null 2>&1
fi
fi
if [ -z "$setmodsec" ]; then
eout "{scan} scan of $spath ($tot_files files) in progress..." 1
fi
$CLAM --fdpass --infected --no-summary -f $find_results 2> /dev/null | sed 's/.UNOFFICIAL//' | awk -F: '{print$2" : "$1}' | while read hit; do
file=$(echo $hit | awk -F: '{print$2}')
signame=$(echo $hit | awk -F: '{print$1}' | sed 's/ FOUND//')
clamsig=$(echo $signame | grep -iE "HEX|MD5")
if [ -z "$clamsig" ]; then
signame="{CAV}$signame"
fi
if [[ $(echo "$signame" | grep -si "HEX") != "" ]]; then
if [[ "$(echo "${signame}" | grep -sf ${generic_sigs})" != "" ]]; then
eout "{scan} going to investigate $signame on $file against md5 database.." 1
spacecleanup
hitredo=$($clamav -d $dat_md5_cav --infected --no-summary "${file}" 2> /dev/null | sed 's/.UNOFFICIAL//' | awk -F: '{print $2" : "$1}')
if [[ "${hitredo}" != "" ]]; then
unset signame
signame=$(echo "$hitredo" | awk -F: '{print$1}' | sed 's/ FOUND//')
fi
fi
fi
spacecleanup
quar "$file" "$signame"
if [ ! "$set_background" == "1" ]; then
tot_hit=$($wc -l $scan_session | awk '{print$1}')
cl_hit=$($wc -l $sessdir/clean.$$ | awk '{print$1}')
if [ -z "$setmodsec" ]; then
$move_to_col && echo -n "maldet($$): {scan} processing scan results for hits: $tot_hit hits $cl_hit cleaned "
fi
cnt=$tot_files
fi
done
##clamscan
elif [ -f "$CLAM" ] && [ "$CLAM" == "$(which clamscan)" ] && [ "$clamav_scan" == "1" ]; then
if [ -z "$setmodsec" ]; then
eout "{scan} found ClamAV clamscan binary, using as scanner engine..." 1
fi
if [ "$string_length_scan" == "1" ]; then
if [ -z "$setmodsec" ]; then
eout "{scan} preprocessing file list for string length hits..." 1
scan_strlen list "$find_results" >> /dev/null 2>&1
fi
fi
if [ -d "/var/clamav" ]; then
clamav_db="-d /var/clamav"
fi
if [ -z "$setmodsec" ]; then
eout "{scan} scan of $spath ($tot_files files) in progress..." 1
fi
$CLAM -d $clamav_db -r --infected --no-summary -f $find_results 2> /dev/null | sed 's/.UNOFFICIAL//' | awk -F: '{print$2" : "$1}' | while read hit; do
file=$(echo $hit | tr ':' ' ' | awk '{print$2}')
signame=$(echo $hit | tr ':' ' ' | awk '{print$1}')
clamsig=$(echo $signame | grep -iE "HEX|MD5")
if [ -z "$clamsig" ]; then
signame="{CAV}$signame"
fi
quar "$file" "$signame"
if [ ! "$set_background" == "1" ]; then
tot_hit=$($wc -l $scan_session | awk '{print$1}')
cl_hit=$($wc -l $sessdir/clean.$$ | awk '{print$1}')
if [ -z "$setmodsec" ]; then
$move_to_col && echo -n "maldet($$): {scan} processing scan results for hits: $tot_hit hits $cl_hit cleaned "
fi
cnt=$tot_files
fi
done
##NO CLAM
else
cat $find_results | tr ' ' '%' | while read i; do
i=$(echo $i | tr '%' ' ')
cnt=$[cnt+1]
if [ ! -f "$scan_session" ]; then
touch $scan_session
fi
if [ -z "$setmodsec" ]; then
if [ ! "$set_background" == "1" ]; then
tot_hit=$($wc -l $scan_session | awk '{print$1}')
cl_hit=$($wc -l $sessdir/clean.$$ | awk '{print$1}')
$move_to_col && echo -n "maldet($$): {scan} $cnt/$tot_files files scanned: $tot_hit hits $cl_hit cleaned"
fi
fi
if [ -f "$i" ]; then
scan_stage1 "$i" >> /dev/null 2>&1
fi
done
fi
if [ -z "$setmodsec" ]; then
echo
fi
tot_hit=$($wc -l $scan_session | awk '{print$1}')
cl_hit=$($wc -l $sessdir/clean.$$ | awk '{print$1}')
gen_report
if [ ! -z "$setmodsec" ]; then
if [ ! "$tot_hit" == "0" ]; then
echo "0 maldet: $hitname $spath"
eout "{scan.modsec} results returned FAIL hit found on $spath (id: $datestamp.$$)"
else
echo "1 maldet: OK"
eout "{scan.modsec} results returned OK on $spath (id: $datestamp.$$)"
fi
else
eout "{scan} scan completed on $spath: files $tot_files, malware hits $tot_hit, cleaned hits $cl_hit" 1
eout "{scan} scan report saved, to view run: maldet --report $datestamp.$$" 1
fi
if [ ! "$tot_hit" == "0" ]; then
if [ "$suppress_cleanhit" == "1" ] && [ ! "$tot_hit" == "$cl_hit" ]; then
alert file $nsess
elif [ "$suppress_cleanhit" == "0" ]; then
alert file $nsess
fi
fi
mv $scan_session $nsess_hits
rm -f $find_results $scan_session
}
spacecleanup() {
if [[ $(echo "$file" | grep ' ') != "" ]]; then
file=$(echo "$file" | sed -e "s/\\\ / /g" -e 's/^[ \t]*//')
fi
}
scan_strlen() {
type=$1
file=$2
if [ "$string_length_scan" == "1" ] && [ "$type" == "file" ]; then
flen=$($wc -L $file 2> /dev/null | awk '{print$1}')
if [ "$flen" -ge "$string_length" ]; then
eout "{strlen} malware string length hit on $file"
quar "$file" "{SA}stat.strlength"
fi
elif [ "$string_length_scan" == "1" ] && [ "$type" == "list" ]; then
list=$tmpdir/.strlen.flist.$$
cp $file $list
sed -i "s/'/\\\\'/g" $list
cat $list | xargs wc -L 2> /dev/null | grep -vw total >> $list.strlen
awk "{if (\$1>=$string_length) print\$2}" $list.strlen >> $list.hits
for i in $(cat $list.hits); do
if [ -f "$i" ]; then
eout "{strlen} malware string length hit on $i"
quar "$i" "{SA}stat.strlength"
fi
done
rm -f $list.strlen $list.hits $list
fi
}
autoclean() {
file="$1"
hitname="$2"
sh_hitname=$(echo $hitname | sed -e 's/{HEX}//' -e 's/{MD5}//' | tr '.' ' ' | awk '{print$1"."$2"."$3}')
if [ -f "$autoclean_sigs" ] && [[ $(cat "$autoclean_sigs") != "" ]] && [[ $(echo "$hitname" | grep -sif "$autoclean_sigs") != "" ]] && [ -f "$cldir/$sh_hitname" ] && [ -f "$file" ] && [ -d "$quardir" ]; then
spacecleanup
file_path="$file"
file_name=$(basename "$file")
autocleanbak="$quardir/$file_name.autoclean.$$"
file_owner=$(stat -c "%U" "$file_path")
file_group=$(stat -c "%G" "$file_path")
file_mode=$(stat -c "%a" "$file_path")
echo "{clean} cleaning file $file_path"
cp "$file_path" "$autocleanbak"
chmod 000 "$autocleanbak"
chown root:root "$autocleanbak"
chattr +i "$autocleanbak"
touch $quardir/"$autocleanbak".info
echo "$file_owner $file_group $file_mode $file_path" > $quardir/"$autocleanbak".info
$cldir/$sh_hitname "$file_path"
if [[ $(md5sum "$file_path" | awk '{print $1}') != $(md5sum "$autocleanbak" | awk '{print $1}') ]]; then
echo "$file_path" "BACKUP: $autocleanbak" >> $sessdir/clean.$$
echo "$file_path" >> $tmpdir/.clean.alltime
else
echo "{clean} file $file_path has no change, we'll remove the backup"
rm -f "$autocleanbak"
fi
fi
}
scan_stage1() {
file="$1"
clchk="$2"
hash=$($md5sum "$file" | awk '{print$1}')
if [ ! -z "$hash" ]; then
val_hash=$(grep -m1 $hash $dat_md5hash)
if [ ! -z "$val_hash" ]; then
md5_hit=$hash
md5_hitname=$(echo $val_hash | cut -d':' -f2)
eout "{md5hash} malware hit $md5_hitname on $file"
if [ "$clchk" == "1" ]; then
clean_failed=1
else
quar "$file" "$md5_hitname"
fi
unset val_hash md5_hit md5_hitname
else
if [ -f "$file" ]; then
scan_stage2 "$file" $clchk >> /dev/null 2>&1
fi
if [ -f "$file" ]; then
scan_strlen file "$file" >> /dev/null 2>&1
fi
fi
else
eout "{scan} error could not read or hash $file, do we have permission?"
fi
}
scan_stage2() {
file="$1"
clchk="$2"
ftype=$(file -b "$file" | egrep "core file|compressed data|archive data")
if [ -z "$ftype" ]; then
if [ -p "$hex_fifo" ] && [ "$hex_fifo_scan" == "1" ]; then
if [ "$OSTYPE" == "FreeBSD" ]; then
$od -v -N$hex_fifo_depth -tx1 "$file" | cut -c12-256 | tr -d ' \n' > $hex_fifo 2>&1 &
else
$od -v -w64 -N$hex_fifo_depth -tx1 "$file" | cut -c9-256 | tr -d '\n ' > $hex_fifo 2>&1 &
fi
val_hex=$($perl $hexmfifo_pl)
else
if [ "$OSTYPE" == "FreeBSD" ]; then
val_hex=$($perl $hexm_pl $($od -v -N$hexdepth -tx1 "$file" | cut -c12-256 | tr -d ' \n'))
else
val_hex=$($perl $hexm_pl $($od -v -w$hexdepth -N$hexdepth -tx1 "$file" | tr -d '\n '))
fi
fi
if [ ! -z "$val_hex" ]; then
hex_hit=$(echo $val_hex | awk '{print$1}')
hex_hitname=$(echo $val_hex | awk '{print$2}')
eout "{hexstring} malware hit $hex_hitname on $file"
if [ "$clchk" == "1" ]; then
clean_failed=1
else
quar "$file" "$hex_hitname"
fi
unset val_hex hex_hit hex_hitname
fi
fi
}
gen_report() {
if [ -f "$scan_session" ]; then
tot_hit=$($wc -l $scan_session | awk '{print$1}')
nsess_hits=$sessdir/session.hits.$datestamp.$$
echo "$datestamp.$$" > $sessdir/session.last
nsess=$sessdir/session.$datestamp.$$
cat >> $nsess <<EOF
malware detect scan report for $(hostname):
SCAN ID: $datestamp.$$
TIME: $(date +"%b %e %H:%M:%S %z")
PATH: $spath
EOF
if [ "$days" != "" ]; then
cat >> $nsess <<EOF
RANGE: $days day(s)
EOF
fi
if [ "$minutes" != "" ]; then
cat >> $nsess <<EOF
RANGE: $minutes minute(s)
EOF
fi
cat >> $nsess <<EOF
TOTAL FILES: $tot_files
TOTAL HITS: $tot_hit
TOTAL CLEANED: $cl_hit
EOF
if [ "$quar_clean" -ne "0" ]; then
if [ -f "$sessdir/clean.$$" ] && [ ! -z "$(cat $sessdir/clean.$$)" ]; then
cat >> $nsess <<EOF
CLEANED & RESTORED FILES (backups in $quardir=):
$(cat $sessdir/clean.$$)
EOF
fi
fi
if [ "$quar_susp" -ne "0" ]; then
if [ -f "$sessdir/suspend.users.$$" ] && [ ! -z "$(cat $sessdir/suspend.users.$$)" ]; then
cat >> $nsess <<EOF
SUSPENDED ACCOUNTS:
$(cat $sessdir/suspend.users.$$)
EOF
fi
fi
if [ "$tot_hit" -ne "0" ]; then
echo "FILE HIT LIST:" >> $nsess
cat $scan_session >> $nsess
fi
cat >> $nsess <<EOF
=========================================================================================================================
Linux Malware Detect v$ver < secteam@mojohost.com >
EOF
fi
}
trim_log() {
log=$1
logtrim=$2
if [ -f "$log" ]; then
log_size=$($wc -l $log | awk '{print$1}')
if [ "$log_size" -gt "$logtrim" ]; then
trim=$(logtrim/10)
printf "%s\n" "$trim,${log_size}d" w | ed -s $log
fi
fi
}
alert() {
type=$1
file="$2"
if [ "$hit_alert" == "1" ]; then
if [ "$type" == "file" ] && [ -f "$file" ]; then
cat $file | $mail -s "$email_subj" $email_addr
$curl $curl_flags $curl_addr -d HOSTNAME=$(hostname) -d REPORTTEXT=$(cat $file | od -v -A n -t x1 | tr -d ' ' |tr -d '\n')
if [ ! "$(whoami)" == "root" ] && [ -z "$(echo $2 | grep '\@')" ]; then
if [ -z "$setmodsec" ]; then
eout "{alert} sent scan report to config default $email_addr" 1
eout "{alert} send scan report to an alternate address with: maldet --report $datestamp.$$ you@domain.com" 1
else
eout "{alert} sent scan report to config default $email_addr"
fi
else
eout "{alert} sent scan report to $email_addr" 1
fi
elif [ "$type" == "daily" ]; then
rm -f $tmpdir/.daily.alert.hits $tmpdir/.daily.clean.hits $tmpdir/.daily.monitor.alert $tmpdir/.daily.susp.hits
scan_session=$(cat $sessdir/session.monitor.current)
$tlog $scan_session daily.alert > $tmpdir/.daily.alert.hits
$tlog $tmpdir/.clean.alltime daily.clean.alert > $tmpdir/.daily.clean.hits
$tlog $tmpdir/.monitor.scanned.alltime daily.monitor.alert > $tmpdir/.daily.monitor.alert
$tlog $tmpdir/.susp.alltime daily.susp.alert > $tmpdir/.daily.susp.hits
tot_hits=$($wc -l $tmpdir/.daily.alert.hits | awk '{print$1}')
tot_cl=$($wc -l $tmpdir/.daily.clean.hits | awk '{print$1}')
tot_files=$($wc -l $tmpdir/.daily.monitor.alert | awk '{print$1}')
tot_susp=$($wc -l $tmpdir/.daily.susp.hits | awk '{print$1}')
trim_log $tmpdir/.monitor.scanned.alltime 5000
trim_log $tmpdir/.clean.alltime 5000
trim_log $tmpdir/.quar.alltime 5000
trim_log $tmpdir/.susp.alltime 5000
$tlog $sessdir/session.hits.$datestamp.$$ daily.alert >> /dev/null 2>&1
$tlog $tmpdir/.clean.alltime daily.clean.alert >> /dev/null 2>&1
$tlog $tmpdir/.monitor.scanned.alltime daily.monitor.alert >> /dev/null 2>&1
$tlog $tmpdir/.susp.alltime daily.susp.alert >> /dev/null 2>&1
if [ ! -z "$(cat $tmpdir/.daily.alert.hits)" ]; then
tmpf=$tmpdir/.alert
rm -f $tmpf
if [ "$tot_hits" -gt "$tot_files" ]; then
tot_files=$tot_hits
fi
cat >> $tmpf <<EOF
malware detect $type monitor report for $(hostname):
SCAN ID: $datestamp.$$
TIME: $(date +"%b %e %H:%M:%S %z")
TOTAL FILES: $tot_files
TOTAL HITS: $tot_hits
TOTAL CLEANED: $tot_cl
EOF
if [ -f "$tmpdir/.daily.clean.hits" ] && [ ! "$tot_cl" == "0" ]; then
cat >> $tmpf <<EOF
CLEANED & RESTORED FILES:
$(cat $tmpdir/.daily.clean.hits)
EOF
fi
if [ -f "$tmpdir/.daily.susp.hits" ] && [ ! "$tot_susp" == "0" ]; then
cat >> $tmpf <<EOF
SUSPENDED ACCOUNTS:
$(cat $tmpdir/.daily.susp.hits)
EOF
fi
cat >> $tmpf <<EOF
FILE HIT LIST:
$(cat $tmpdir/.daily.alert.hits)
=========================================================================================================================
Linux Malware Detect v$ver < secteam@mojohost.com >
EOF
cp $tmpf $sessdir/session.$datestamp.$$
echo "$datestamp.$$" > $sessdir/session.last
email_subj="$email_subj :: $type"
cat $tmpf | $mail -s "$email_subj" $email_addr
$curl $curl_flags $curl_addr -d HOSTNAME=$(hostname) -d REPORTTEXT=$(cat $file | od -v -A n -t x1 | tr -d ' ' |tr -d '\n')
eout "{alert} sent $type alert to $email_addr"
rm -f $tmpf $tmpdir/.daily.alert.hits $tmpdir/.daily.clean.hits $tmpdir/.daily.monitor.alert $tmpdir/.daily.susp.hits
fi
elif [ "$type" == "weekly" ]; then
rm -f $tmpdir/.weekly.alert.hits $tmpdir/.weekly.clean.hits $tmpdir/.weekly.monitor.alert $tmpdir/.daily.susp.hits
scan_session=$(cat $sessdir/session.monitor.current)
$tlog $scan_session weekly.alert > $tmpdir/.weekly.alert.hits
$tlog $tmpdir/.clean.alltime weekly.clean.alert > $tmpdir/.weekly.clean.hits
$tlog $tmpdir/.monitor.scanned.alltime weekly.monitor.alert > $tmpdir/.weekly.monitor.alert
$tlog $tmpdir/.susp.alltime weekly.susp.alert > $tmpdir/.weekly.susp.hits
tot_hits=$($wc -l $tmpdir/.weekly.alert.hits | awk '{print$1}')
tot_cl=$($wc -l $tmpdir/.weekly.clean.hits | awk '{print$1}')
tot_files=$($wc -l $tmpdir/.weekly.monitor.alert | awk '{print$1}')
tot_susp=$($wc -l $tmpdir/.weekly.susp.hits | awk '{print$1}')
trim_log $tmpdir/.monitor.scanned.alltime 5000
trim_log $tmpdir/.clean.alltime 5000
trim_log $tmpdir/.quar.alltime 5000
trim_log $tmpdir/.susp.alltime 5000
$tlog $sessdir/session.hits.$datestamp.$$ weekly.alert >> /dev/null 2>&1
$tlog $tmpdir/.clean.alltime weekly.clean.alert >> /dev/null 2>&1
$tlog $tmpdir/.monitor.scanned.alltime weekly.monitor.alert >> /dev/null 2>&1
$tlog $tmpdir/.susp.alltime weekly.susp.alert >> /dev/null 2>&1
if [ ! -z "$(cat $tmpdir/.weekly.alert.hits)" ]; then
tmpf=$tmpdir/.alert
rm -f $tmpf
if [ "$tot_hits" -gt "$tot_files" ]; then
tot_files=$tot_hits
fi
cat >> $tmpf <<EOF
malware detect $type monitor report for $(hostname):
SCAN ID: $datestamp.$$
TIME: $(date +"%b %e %H:%M:%S %z")
TOTAL FILES: $tot_files
TOTAL HITS: $tot_hits
TOTAL CLEANED: $tot_cl
EOF
if [ -f "$tmpdir/.weekly.clean.hits" ] && [ ! "$tot_cl" == "0" ]; then
cat >> $tmpf <<EOF
CLEANED & RESTORED FILES:
$(cat $tmpdir/.weekly.clean.hits)
EOF
fi
if [ -f "$tmpdir/.weekly.susp.hits" ] && [ ! "$tot_susp" == "0" ]; then
cat >> $tmpf <<EOF
SUSPENDED ACCOUNTS:
$(cat $tmpdir/.weekly.susp.hits)
EOF
fi
cat >> $tmpf <<EOF
FILE HIT LIST:
$(cat $tmpdir/.weekly.alert.hits)
=========================================================================================================================
Linux Malware Detect v$ver < secteam@mojohost.com >
EOF
echo "$datestamp.$$" > $sessdir/session.last
cp $tmpf $sessdir/session.$datestamp.$$
email_subj="$email_subj :: $type"
cat $tmpf | $mail -s "$email_subj" $email_addr
$curl $curl_flags $curl_addr -d HOSTNAME=$(hostname) -d REPORTTEXT=$(cat $file | od -v -A n -t x1 | tr -d ' ' |tr -d '\n')
eout "{alert} sent $type alert to $email_addr"
rm -f $tmpf $tmpdir/.weekly.alert.hits $tmpdir/.weekly.clean.hits $tmpdir/.weekly.monitor.alert $tmpdir/.weekly.susp.hits
fi
else
eout "{alert} file input error, alert discarded."
fi
fi
}
monitor_kill() {
touch $tmpdir/stop_monitor
inotify_pid=$(pidof inotifywait)
if [ -f "$tmpdir/monitor.pid" ]; then
monitor_pid=$(cat $tmpdir/monitor.pid)
fi
kill -9 $inotify_pid $monitor_pid >> /dev/null 2>&1
killall -9 inotifywait >> /dev/null 2>&1
exit
}
monitor_cycle() {
echo $$ > $tmpdir/monitor.pid
if [ ! -f "$tmpdir/stop_monitor" ]; then
inotify_pid=$(pidof inotifywait)
if [ -z "$inotify_pid" ]; then
eout "{mon} no inotify process found, exiting (are we a zombie process?)" 1
exit
fi
log_size=$($wc -l $inotify_log | awk '{print$1}')
if [ "$log_size" -ge "$inotify_trim" ]; then
trim=1000
printf "%s\n" "$trim,${log_size}d" w | ed -s $inotify_log
eout "{mon} inotify log file trimmed"
fi
sleep $inotify_stime
monitor_check
else
rm -f $tmpdir/stop_monitor
eout "{mon} monitoring terminated by user, inotify killed."
exit
fi
}
monitor_check() {
for file in $($tlog $inotify_log inotify | grep -E "CREATE|MODIFY|MOVED_FROM|MOVED_TO" | awk '{print$1}' | sort | uniq | tr ' ' '%'); do
file=$(echo $file | tr '%' ' ')
if [ -f "$file" ]; then
sigignore 1
echo "$file" >> $tmpdir/.monitor.scanned.alltime
eout "{mon} inotify file scan $file"
scan_stage1 "$file" >> /dev/null 2>&1
fi
done
monitor_cycle
}
monitor_init() {
inopt="$1"
scan_session=$sessdir/session.hits.$datestamp.$$
touch $scan_session
echo "$scan_session" > $sessdir/session.monitor.current
if [ "$inopt" == "" ]; then
eout "invalid usage of -m|--monitor, aborting." 1
exit
fi
if [ ! -f "$inotify" ]; then
eout "{mon} could not find inotify command" 1
exit
fi
if [ -f "/boot/System.map-$(uname -r)" ]; then
ksup=$(grep -i inotify_ /boot/System.map-$(uname -r))
if [ -z "$ksup" ]; then
eout "{mon} kernel does not support inotify(), aborting." 1
exit
fi
elif [ -f "/boot/config-$(uname -r)" ]; then
ksup=$(grep -m1 CONFIG_INOTIFY /boot/config-$(uname -r))
if [ -z "$ksup" ]; then
eout "{mon} kernel does not support inotify(), aborting." 1
exit
fi
fi
inotify_pid=$(pidof inotifywait)
if [ ! -z "$inotify_pid" ]; then
eout "{mon} existing inotify process detected (try -k): $inotify_pid" 1
exit
fi
rm -f $tmpdir/stop_monitor $tmpdir/inotifywait.pid
procs=$(cat /proc/cpuinfo | grep -c processor)
users_tot=$(cat /etc/passwd | grep -ic home)
inotify_user_watches=$[inotify_base_watches*users_tot]
eout "{mon} set inotify max_user_instances to 128" 1
echo 128 > /proc/sys/fs/inotify/max_user_instances
eout "{mon} set inotify max_user_watches to $inotify_user_watches" 1
echo $inotify_user_watches > /proc/sys/fs/inotify/max_user_watches
icnt=0
inotify_fpaths=$sessdir/inotify.paths.$$
rm -f $inotify_fpaths
touch $inotify_log
chmod 640 $inotify_log
if [ "$(echo $inopt | grep -E "users|user|USERS|USER")" ]; then
for i in $(cat /etc/passwd | cut -d':' -f1,3,6); do
user=$(echo $i | cut -d':' -f1)
user_id=$(echo $i | cut -d':' -f2)
user_home=$(echo $i | cut -d':' -f3)
icnt=$[icnt+1]
if [ "$user_id" -ge "$inotify_minuid" ]; then
if [ ! -z "$inotify_webdir" ] && [ -d "$user_home/$inotify_webdir" ]; then
echo "$user_home/$inotify_webdir" >> $inotify_fpaths
eout "{mon} added $user_home/$inotify_webdir to inotify monitoring array" 1
elif [ -d "$user_home" ]; then
echo "$user_home" >> $inotify_fpaths
eout "{mon} added $user_home to inotify monitoring array" 1
else
eout "{mon} could not find any suitable user home paths"
fi
fi
done
if [ -d "/dev/shm" ]; then
echo "/dev/shm" >> $inotify_fpaths
eout "{mon} added /dev/shm to inotify monitoring array" 1
fi
if [ -d "/var/tmp" ]; then
echo "/var/tmp" >> $inotify_fpaths
eout "{mon} added /var/tmp to inotify monitoring array" 1
fi
if [ -d "/tmp" ]; then
echo "/tmp" >> $inotify_fpaths
eout "{mon} added /tmp to inotify monitoring array" 1
fi
elif [ -f "$inopt" ]; then
tot_paths=$($wc -l $inotify_fpaths | awk '{print$1}')
if [ "$tot_paths" == "0" ]; then
eout "{mon} no paths specified in $inopt, aborting." 1
exit
fi
for i in $(cat $inopt); do
if [ -d "$i" ]; then
eout "{mon} added $i to inotify monitoring array" 1
echo "$i" >> $inotify_fpaths
else
eout "{mon} ignored invalid path $i" 1
fi
done
elif [ -d "$inopt" ] || [ "$(echo $inopt | grep -E ".*,.*")" ]; then
for i in $(echo $inopt | tr ',' '\n'); do
if [ -d "$i" ]; then
eout "{mon} added $i to inotify monitoring array" 1
echo "$i" >> $inotify_fpaths
else
eout "{mon} invalid path $i specified, ignoring." 1
fi
done
else
eout "{mon} no valid option or invalid file/path provided, aborting." 1
exit
fi
if [ -f "$ignore_inotify" ]; then
cnt=$($wc -l $ignore_inotify | awk '{print$1}')
if [ "$cnt" > "0" ]; then
for igfile in $(cat $ignore_inotify); do
if [ "$igregexp" ]; then
igregexp="$igregexp|$igfile"
else
igregexp="($igfile"
fi
done
igregexp="$igregexp)"
exclude="--exclude $igregexp"
fi
fi
tot_paths=$($wc -l $inotify_fpaths | awk '{print$1}')
eout "{mon} starting inotify process on $tot_paths paths, this might take awhile..." 1
$nice -n $inotify_nice $inotify -d -r -o $inotify_log --fromfile $inotify_fpaths $exclude --timefmt "%d %b %H:%M:%S" --format "%w%f %e %T" -m -e create,move,modify >> /dev/null 2>&1 &
sleep 2
inotify_pid=$(pidof inotifywait)
if [ -z "$inotify_pid" ]; then
eout "{mon} no inotify process found, check $inotify_log for errors." 1
exit
else
eout "{mon} inotify startup successful (pid: $inotify_pid)" 1
eout "{mon} inotify monitoring log: $inotify_log" 1
echo "$inotify_pid" > $tmpdir/inotifywait.pid
fi
monitor_cycle >> /dev/null 2>&1 &
}
checkout() {
file="$1"
host=secrepo.mojohost.com
user=anonymous
passwd=anonymous
upath=incoming
cfile="$(pwd)/$file"
if [ -f "$cfile" ]; then
file=$cfile
fi
if [ -f "$file" ]; then
eout "{checkout} uploading $file to $host" 1
ftp -v -n -i $host << EOT
user $user $passwd
prompt
cd $upath
lcd $lcd
binary
put "$file" "$RANDOM.$$.bin"
ascii
put "$file" "$RANDOM.$$.ascii"
bye
EOT
elif [ -d "$file" ]; then
for i in $(find $file -type f); do
ftp -v -n -i $host << EOT
user $user $passwd
prompt
cd $upath
lcd $lcd
binary
put "$i" "$RANDOM.$$.bin"
ascii
put "$i" "$RANDOM.$$.ascii"
bye
EOT
done
fi
}
sigignore() {
sil=$1
chk=$($wc -l $ignore_sigs | awk '{print$1}')
if [ ! "$chk" == "0" ]; then
grep -vf $ignore_sigs $dat_hex_cav > $date_hex_cav.new
mv $dat_hex_cav.new $dat_hex_cav
grep -vf $ignore_sigs $dat_md5_cav > $date_md5_cav.new
mv $dat_md5_cav.new $dat_md5_cav
chmod 640 $dat_hex_cav $dat_md5_cav
if [ "$sil" == "1" ]; then
eout "{glob} processed $chk signature ignore entries"
else
eout "{glob} processed $chk signature ignore entries" 1
fi
fi
}
confup() {
ofile=$tmpdir/.conf.maldet_check.$$
tmp_inspath=/usr/local/lmdup
rm -fr $tmp_inspath
rm -f $ofile
mkdir -p $tmp_inspath
chmod 750 $tmp_inspath
eout "{update} checking for available conf.maldet updates..." 1
$wget --referer="$wget_refer" -q -t5 -T5 "$lmdurl_path/maldet-latest/files/conf.maldet" -O $ofile >> /dev/null 2>&1
if [ -s "$ofile" ]; then
confmaldetsum=$($md5sum $inspath/conf.maldet | awk '{print $1}')
checkconfmaldetsum=$($md5sum $ofile | awk '{print $1}')
if [[ ${confmaldetsum} == ${checkconfmaldetsum} ]]; then
eout "{update} latest conf.maldet already in place..." 1
else
eout "{update} update available for conf.maldet. Updating now..." 1
if [ -f "$inspath/conf.maldet_rollback" ]; then
rm -f $inspath/conf.maldet_rollback
fi
mv $inspath/conf.maldet $inspath/conf.maldet_rollback
mv $ofile $inspath/conf.maldet
eout "{update} of conf.maldet completed..." 1
fi
else
eout "{update} could not download latest conf.maldet from repository, please try again later." 1
fi
rm -fr $tmp_inspath rm -f $ofile
ofile=$tmpdir/.internals.conf_check.$$
tmp_inspath=/usr/local/lmdup
rm -fr $tmp_inspath
rm -f $ofile
mkdir -p $tmp_inspath
chmod 750 $tmp_inspath
eout "{update} checking for available internals.conf updates..." 1
$wget --referer="$wget_refer" -q -t5 -T5 "$lmdurl_path/maldet-latest/files/internals.conf" -O $ofile >> /dev/null 2>&1
if [ -s "$ofile" ]; then
internalssum=$($md5sum $inspath/internals.conf | awk '{print $1}')
checkinternalssum=$($md5sum $ofile | awk '{print $1}')
if [[ ${internalssum} == ${checkinternalssum} ]]; then
eout "{update} latest internals.conf already in place..." 1
else
eout "{update} update available for internals.conf. Updating now..." 1
if [ -f "$inspath/internals.conf_rollback" ]; then
rm -f $inspath/internals.conf_rollback
fi
mv $inspath/internals.conf $inspath/internals.conf_rollback
mv $ofile $inspath/internals.conf
eout "{update} of internals.conf completed..." 1
fi
else
eout "{update} could not download latest internals.conf from repository, please try again later." 1
fi
rm -fr $tmp_inspath
rm -f $ofile
ofile=$tmpdir/.internals.conf_check.$$
tmp_inspath=/usr/local/lmdup
rm -fr $tmp_inspath
rm -f $ofile
mkdir -p $tmp_inspath
chmod 750 $tmp_inspath
eout "{update} checking for available autoquarantine_sigs updates..." 1
$wget --referer="$wget_refer" -q -t5 -T5 "$lmdurl_path/maldet.current.autoquarantine_sigs" -O $ofile >> /dev/null 2>&1
if [ -s "$ofile" ]; then
autoquarmaldetsum=$($md5sum $inspath/autoquarantine_sigs | awk '{print $1}')
checkautoquarmaldetsum=$($md5sum $ofile | awk '{print $1}')
if [[ ${autoquarmaldetsum} == ${checkautoquarmaldetsum} ]]; then
eout "{update} latest autoquarantine_sigs already in place..." 1
else
eout "{update} update available for autoquarantine_sigs. Updating now..." 1
if [ -f "$inspath/autoquarantine_sigs_rollback" ]; then
rm -f $inspath/autoquarantine_sigs_rollback
fi
mv $inspath/autoquarantine_sigs $inspath/autoquarantine_sigs_rollback
mv $ofile $inspath/autoquarantine_sigs
eout "{update} of autoquarantine_sigs completed..." 1
fi
else
eout "{update} could not download latest autoquarantine_sigs from repository, please try again later." 1
fi
rm -fr $tmp_inspath
rm -f $ofile
mkdir -p $tmp_inspath
chmod 750 $tmp_inspath
eout "{update} checking for available autoclean_sigs updates..." 1
$wget --referer="$wget_refer" -q -t5 -T5 "$lmdurl_path/maldet-latest/files/autoclean_sigs" -O $ofile >> /dev/null 2>&1
if [ -s "$ofile" ]; then
autocleanmaldetsum=$($md5sum $inspath/autoclean_sigs | awk '{print $1}')
checkautocleanmaldetsum=$($md5sum $ofile | awk '{print $1}')
if [[ ${autocleanmaldetsum} == ${checkautocleanmaldetsum} ]]; then
eout "{update} latest autoclean_sigs already in place..." 1
else
eout "{update} update available for autoclean_sigs. Updating now..." 1
if [ -f "$inspath/autoclean_sigs_rollback" ]; then
rm -f $inspath/autoclean_sigs_rollback
fi
mv $inspath/autoclean_sigs $inspath/autoclean_sigs_rollback
mv $ofile $inspath/autoclean_sigs
eout "{update} of autoclean_sigs completed..." 1
fi
else
eout "{update} could not download latest autoclean_sigs from repository, please try again later." 1
fi
rm -fr $tmp_inspath
rm -f $ofile
eout "{update} checking for available generic_sigs updates..." 1
$wget --referer="$wget_refer" -q -t5 -T5 "$lmdurl_path/maldet-latest/files/generic_sigs" -O $ofile >> /dev/null 2>&1
if [ -s "$ofile" ]; then
genericsigsmaldetsum=$($md5sum $generic_sigs | awk '{print $1}')
checkgenericsigsmaldetsum=$($md5sum $ofile | awk '{print $1}')
if [[ ! -f $generic_sigs ]]; then
mv "$ofile" "$generic_sigs"
else
if [[ ${genericsigsmaldetsum} == ${checkgenericsigsmaldetsum} ]]; then
eout "{update} latest generic_sigs already in place..." 1
rm -f $ofile
else
eout "{update} update available for generic_sigs. Updating now..." 1
if [ -f "$inspath/generic_sigs_rollback" ]; then
rm -f $inspath/generic_sigs_rollback
fi
mv $generic_sigs $inspath/generic_sigs_rollback
mv $ofile $generic_sigs
eout "{update} of generic_sigs completed..." 1
fi
fi
else
eout "{update} could not download latest generic_sigs from repository, please try again later." 1
fi
rm -fr $tmp_inspath
tmp_inspath=/usr/local/lmdup
mkdir -p $tmp_inspath
chmod 750 $tmp_inspath
eout "{update} checking for available clean signature updates..." 1
ofile=$tmpdir/.maldet.cleanfiles_check.$$
$wget --referer="$wget_refer" -q -t5 -T5 "$lmdurl_path/maldet.cleanfiles" -O $ofile >> /dev/null 2>&1
if [ -s "$ofile" ]; then
cat $ofile | while read cleanmd5sum cleanname; do
chkfile=$tmpdir/.maldet.cleanfiles_check_$cleanname.$$
if [[ -f $inspath/clean/$cleanname ]]; then
if [[ $(md5sum $inspath/clean/$cleanname | awk '{print $1}') != $cleanmd5sum ]]; then
eout "{update} $cleanname signature out of date, updating..." 1
$wget --referer="$wget_refer" -q -t5 -T5 "$lmdurl_path/clean/$cleanname" -O $chkfile
if [ $(stat -c %s $chkfile) -ne 0 ] && [ -f $chkfile ]; then
if [ -f $inspath/clean/$cleanname.OLD ]; then
rm -f $inspath/clean/$cleanname.OLD
fi
mv $inspath/clean/$cleanname $inspath/clean/$cleanname.OLD
mv $chkfile $inspath/clean/$cleanname
chmod 700 $inspath/clean/$cleanname
fi
fi
else
$wget --referer="$wget_refer" -q -t5 -T5 "$lmdurl_path/clean/$cleanname" -O $inspath/clean/$cleanname
if [ -f $inspath/clean/$cleanname ] && [ $(stat -c %s $inspath/clean/$cleanname) -ne 0 ]; then
chmod 700 $inspath/clean/$cleanname
else
eout "{update} $cleanname signature download failed, check out download from $lmdurl_path/clean/$cleanname" 1
fi
fi
rm -f $chkfile
done
fi
rm -fr $tmp_inspath
rm -f $ofile
}
lmdup() {
ofile=$tmpdir/.lmdup_vercheck.$$
tmp_inspath=/usr/local/lmdup
rm -rf $tmp_inspath
rm -f $ofile
mkdir -p $tmp_inspath
chmod 750 $tmp_inspath
eout "{update} checking for available updates..." 1
$wget --referer="$wget_refer" -q -t5 -T5 "$lmdurl_ver" -O $ofile >> /dev/null 2>&1
if [ -s "$ofile" ]; then
installed_ver=$(echo $ver | tr -d '.')
current_ver=$(cat $ofile | tr -d '.')
current_hver=$(cat $ofile)
if [ "$current_ver" -gt "$installed_ver" ]; then
eout "{update} new version $current_hver found, updating..." 1
$wget --referer="$wget_refer" -q -t5 -T5 "$lmdurl_path/maldet-latest/files/maldet" -O "$tmp_inspath/maldet"
if [ -f "$tmp_inspath/maldet" ]; then
if [ -f "$inspath/maldet_rollback" ]; then
rm -f $inspath/maldet_rollback
fi
mv $inspath/maldet $inspath/maldet_rollback
mv $tmp_inspath/maldet $inspath/maldet
chmod 755 $inspath/maldet
echo "$ofile" > $inspath/VERSION
eout "{update} of maldet binary completed. v$ver => v$current_hver..." 1
else
eout "{update} could not download maldet binary, please try again later." 1
exit
fi
else
eout "{update} hashing latest maldet file and checking against server..." 1
$md5sum $inspath/maldet | awk '{print $1}' > $lmd_hashf
ofile_hash=$tmp_inspath/.lmdup_hashcheck
$wget --referer="$wget_refer" -q -t5 -T5 "$lmdurl_hash" -O $ofile_hash >> /dev/null 2>&1
if [ -f "$ofile_hash" ]; then
installed_hash=$(cat $lmd_hashf)
current_hash=$(cat $ofile_hash)
if [ ! "$installed_hash" == "$current_hash" ]; then
eout "{update} version check shows latest but hash check failed, forcing update..." 1
echo "INSTALLED_HASH - $installed_hash"
echo "CURRENT_HASH - $current_hash"
$wget --referer="$wget_refer" -q -t5 -T5 "$lmdurl_path/maldet-latest/files/maldet" -O "$tmp_inspath/maldet"
if [ -f "$tmp_inspath/maldet" ] && [ ! $(stat -c %s $tmp_inspath) == "0" ]; then
if [ -f "$inspath/maldet_outofdate" ]; then
rm -f $inspath/maldet_outofdate
fi
mv $inspath/maldet{,_outofdate}
mv $tmp_inspath/maldet $inspath/maldet
chmod 755 $inspath/maldet
$md5sum $inspath/maldet | awk '{print$1}' > $lmd_hashf
eout "{update} update of maldet binary completed." 1
else
eout "{update} could not download latest maldet, please try again later." 1
exit
fi
else
eout "{update} latest version already installed." 1
fi
else
eout "{update} latest version already installed." 1
fi
fi
else
eout "{update} could not download version file from server, please try again later." 1
exit
fi
rm -rf $tmp_inspath $ofile $ofile_hash
}
md5update ()
{
ofile=$tmpdir/.lmdup_md5check.$$
rm -f $ofile
eout "{update} checking for available ignore_md5sum updates..." 1
$wget --referer="$wget_refer" -q -t5 -T5 "$lmdurl_path/current.ignore_md5sum" -O $ofile >> /dev/null 2>&1
if [ -s $ofile ]; then
CURMD5=$($md5sum $inspath/ignore_md5sum | awk '{print$1}')
RELMD5=$($md5sum $ofile | awk '{print$1}')
if [[ ${CURMD5} == ${RELMD5} ]]; then
eout "{update} no updates for current ignore_md5sum." 1
else
mv $inspath/ignore_md5sum{,.OUT_OF_DATE}
mv $ofile $inspath/ignore_md5sum
eout "{update} ignore_md5 has been updated with latest release version." 1
fi
else
eout "{update} could not download release version of ignore_md5sum from server, please try again later." 1
exit
fi
rm -rf $ofile
}
lmdreinstall ()
{
tmp_inspath=/usr/local/lmdup
rm -rf $tmp_inspath
mkdir -p $tmp_inspath
chmod 750 $tmp_inspath
eout "{update} forcing reinstall of maldet package now..." 1
$wget --referer="$wget_refer" -q -t5 -T5 "$lmdurl_path/maldet-latest.tar.gz" -O "$tmp_inspath/maldet-latest.tar.gz"
if [ -f "$tmp_inspath/maldet-latest.tar.gz" ]; then
cd $tmp_inspath/
tar xfz maldet-latest.tar.gz
cd maldet-latest
chmod 750 install.sh
sh -c './install.sh --reinstall' >> /dev/null 2>&1
eout "{update} completed reinstall of maldet from latest release" 1
else
eout "{update} could not download maldet-latest.tar.gz, please try again later." 1
exit
fi
}
if [ -z "$1" ]; then
header
usage_short
else
while [ -n "$1" ]; do
case "$1" in
--mkpubpaths)
if [ "$public_scan" == "1" ]; then
chmod 711 $inspath/pub
for user in $(cat /etc/passwd | cut -d ':' -f1); do
uid=$(id --user $user)
if [ -z "$uid" ]; then
uid=9
fi
if [ -z "$pubuser_minuid" ]; then
pubuser_minuid=10
fi
if [ "$uid" -ge "$pubuser_minuid" ] && [ ! -d "$inspath/pub/$user" ]; then
mkdir -p $inspath/pub/$user/quar $inspath/pub/$user/sess $inspath/pub/$user/tmp >> /dev/null 2>&1
touch $inspath/pub/$user/event_log >> /dev/null 2>&1
chown -R $user.$user $inspath/pub/$user >> /dev/null 2>&1
chmod 750 $inspath/pub/$user $inspath/pub/$user/quar $inspath/pub/$user/sess $inspath/pub/$user/tmp >> /dev/null 2>&1
chmod 640 $inspath/pub/$user/event_log >> /dev/null 2>&1
eout "{glob} created public scanning paths for user $user"
fi
unset uid user
done
exit
else
header
echo "public scanning support not enabled in conf.maldet, aborting."
exit
fi
;;
--modsec)
setmodsec=1
;;
-U|--user)
shift
user="$1"
quardir=$inspath/pub/$user/quar
sessdir=$inspath/pub/$user/sess
tmpdir=$inspath/pub/$user/tmp
logf=$inspath/pub/$user/event_log
;;
-co|--config-option)
shift
user=$(whoami)
if [ ! "$user" == "root" ]; then
tmpdir=$inspath/pub/$user/tmp
fi
tmpco=$tmpdir/config.cli
rm -f $tmpco
touch $tmpco
echo $1 | sed -e 's/--config-option //' -e 's/-co //' | tr -d ' ' | tr ',' '\n' > $tmpco
. $tmpco
rm -f $tmpco
;;
-qd)
shift
if [ -d "$1" ]; then
eout "{scan} set quarantine path: $1" 1
quardir="$1"
fi
;;
-b|--background)
set_background=1
;;
-c|--checkout)
shift
header
checkout "$1"
;;
--alert-daily)
alert daily
;;
--alert-weekly)
alert weekly
;;
-m|--monitor)
header
shift
if [ "$OSTYPE" == "FreeBSD" ]; then
eout "{mon} not currently supported under FreeBSD" 1
else
svc=m
trap trap_exit 2
monitor_init "$1"
fi
;;
-k|--kill-monitor)
header
if [ "$OSTYPE" == "FreeBSD" ]; then
eout "{mon} not currently supported under FreeBSD" 1
else
eout "{mon} sent kill to monitor service" 1
monitor_kill
fi
;;
-a|--scan-all)
shift
if [ -z "$setmodsec" ]; then
header
fi
svc=a
trap trap_exit 2
spath="$1"
if [ "$spath" == "" ]; then
spath=/home
fi
if [ "$set_background" == "1" ]; then
eout "{scan} launching scan of $spath to background, see $inspath/event_log for progress" 1
scan "$spath" all >> /dev/null 2>&1 &
else
scan "$spath" all
fi
;;
-r|--scan-recent)
header
svc=r
trap trap_exit 2
shift
spath="$1"
shift
days="$1"
if [ -z "$spath" ]; then
eout "{scan} no path defined" 1
exit
fi
if [ -z "$days" ]; then
days=7
fi
if [ "$set_background" == "1" ]; then
eout "{scan} launching scan of $spath changes in last ${days}d to background, see $inspath/event_log for progress" 1
scan "$spath" "$days" >> /dev/null 2>&1 &
else
scan "$spath" "$days"
fi
;;
--minutes)
header
svc=r
trap trap_exit 2
shift
spath="$1"
shift
minutes="$1"
if [ -z "$spath" ]; then
eout "{scan} no path defined" 1
exit
fi
if [ -z "$minutes" ]; then
minutes=30
fi
if [ "$set_background" == "1" ]; then
eout "{scan} launching scan of $spath changes in last ${minutes} minute(s) to background, see $inspath/event_log for progress" 1
scan "$spath" "$minutes" >> /dev/null 2>&1 &
else
scan "$spath" "$minutes"
fi
;;
-l|--log)
header
view
;;
-e|--report)
header
shift
view_report "$1" "$2"
;;
-p|--purge)
header
purge
;;
-d|--update-daemon)
header
#lmdup
confup
md5update
;;
-f|--force-reinstall)
header
lmdreinstall
;;
-s|--restore)
header
shift
if [ -f "$sessdir/session.hits.$1" ]; then
restore_hitlist "$1"
else
restore "$1"
fi
;;
-q|--quarantine)
header
shift
quar_hitlist "$1"
;;
-n|--clean)
header
shift
clean_hitlist "$1"
;;
-h|--help)
header
usage_long
;;
*)
header
usage_short
esac
shift
done
fi