Skip to content

Commit 4d016b0

Browse files
committedSep 10, 2013
[Change] added scan_ignore_root oprion to exclude root owned files from find results
[Change] corrected persistence of custom signature files across signature updates and version upgrades [Change] various corrections to conf.maldet, reworded some descriptions and modified default hexdepth to 64kb and hexfifodepth to 512kb [Change] performed additional functionality testing of current 1.5 code to ensure LMD works as expected and encountered no issues
1 parent 8787665 commit 4d016b0

File tree

4 files changed

+87
-73
lines changed

4 files changed

+87
-73
lines changed
 

‎CHANGELOG

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
v1.5 | ? ? 2013:
2-
[TODO] pre-release test on varied distros (e.g: RHEL4,5,6, Debian 6,7, Ubuntu 11,12,13 ...)
2+
[TODO] pre-release tests on RHEL4,5,6, Debian 6,7, Ubuntu 11,12,13, FBSD 8,9 etc...
33
[TODO] modify remote dependent URL's to use HTTPS, set wget to ignore cert errors?
44
[TODO] update README file
55
[TODO] scan statistics submissions
@@ -24,15 +24,16 @@ v1.5 | ? ? 2013:
2424
from a which search of $PATH
2525
[TODO] add configuration option that toggles version updates off/on [default on]
2626
[TODO] add configuration option that toggles signature updates off/on [default on]
27-
[TODO] option to exclude root owned files from find results
2827
[TODO] pull email alert body content out of maldet executable and create email alert global template
28+
[TODO] verify md5sum on version update
2929
[TODO] ensure hexfifo is checking runtime hexstrings and/or custom hexstrings
3030
[TODO] more thorough testing of custom cleaner rules
31-
[TODO] option to have scan_find_max_filesize set dynamically based on the largest file size in the md5 signature set
31+
[TODO] option to have scan_max_filesize set dynamically based on the largest file size in the md5 signature set
3232

3333
[New] added -i|--include-regex CLI option for run-time path/file inclusion based on posix-egrep regular expressions
3434
[New] added -x|--exclude-regex CLI option for run-time path/file exclusion based on posix-egrep regular expressions
35-
[New] added scan_nice conf.maldet option to control CPU Nice value of all scan operations (find, clamscan, md5sum etc..)
35+
[New] added scan_ignore_root conf.maldet option to exclude root owned files from find results
36+
[New] added scan_cpunice conf.maldet option to control CPU Nice value of all scan operations (find, clamscan, md5sum etc..)
3637
[New] added support for custom signature files for md5 and hex signatures which will be preserved across signature updates
3738
and installation upgades; files are located at:
3839
sigs/custom.md5.dat

‎CHANGELOG.VARIABLES

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ quar_hits => quarantine_hits
22
quar_clean => quarantine_clean
33
quar_susp => quarantine_suspend_user
44
quar_susp_minuid => quarantine_suspend_user_minuid
5-
maxdepth => scan_find_max_depth
6-
minfilesize => scan_find_min_filesize
7-
maxfilesize => scan_find_max_filesize
5+
maxdepth => scan_max_depth
6+
minfilesize => scan_min_filesize
7+
maxfilesize => scan_max_filesize
88
hexdepth => scan_hexdepth
99
hex_fifo_scan => scan_hexfifo
1010
hex_fifo_depth => scan_hexfifo_depth

‎files/conf.maldet

+70-59
Original file line numberDiff line numberDiff line change
@@ -27,95 +27,92 @@ email_addr="you@domain.com"
2727
email_ignore_clean=0
2828

2929
##
30-
# [ QUARANTINE OPTIONS ]
31-
##
32-
# The default quarantine action for malware hits
33-
# [0 = alert only, 1 = move to quarantine & alert]
34-
quarantine_hits=0
35-
36-
# Try to clean string based malware injections
37-
# [NOTE: quarantine_hits=1 required]
38-
# [0 = disabled, 1 = clean]
39-
quarantine_clean=1
40-
41-
# The default suspend action for users wih hits
42-
# Cpanel suspend or set shell /bin/false on non-Cpanel
43-
# [NOTE: quarantine_hits=1 required]
44-
# [0 = disabled, 1 = suspend account]
45-
quarantine_suspend_user=0
46-
47-
# The minimum userid value that can be suspended
48-
# [ default = 500 ]
49-
quarantine_suspend_user_minuid=500
50-
51-
##
52-
# [ ADVANCED SCAN OPTIONS ]
30+
# [ SCAN OPTIONS ]
5331
##
5432

5533
# The maximum directory depth that the scanner will search
5634
# [ changing this may have an impact on scan performance ]
57-
scan_find_max_depth=15
35+
scan_max_depth=15
5836

59-
# The minimum in bytes for a file to be included in a scan
37+
# The minimum file size in bytes for a file to be included in
38+
# LMD scans. A value of less than 24b is highly discouraged.
6039
# [ changing this may have an impact on scan performance ]
61-
scan_find_min_filesize=32
40+
scan_min_filesize=24
6241

63-
# The maximum file size for a file to be included in scan
64-
# search results; use man find for accepted values
42+
# The maximum file size for a file to be included in scan LMD
43+
# scans. Accepted value formats are b, k, M.
6544
# [ changing this may have an impact on scan performance ]
66-
scan_find_max_filesize="768k"
45+
scan_max_filesize="768k"
46+
47+
# As a design and common use case, LMD typically only scans
48+
# user space paths and as such it makes sense to ignore files
49+
# that are root owned. It is recommended to leave this enabled.
50+
# [ 0 = disabled, 1 = enabled; enabled by default ]
51+
scan_ignore_root="1"
6752

6853
# The maximum byte depth that the scanner will search into
69-
# a files contents; default rules expect a 1024*60 depth
54+
# a files contents; default rules expect a 65536 depth size.
7055
# [ changing this may have an impact on scan performance ]
71-
scan_hexdepth=61440
72-
73-
# Use named pipe (FIFO) for passing file contents hex data
74-
# instead of stdin default; improved performance and greater
75-
# scanning depth
76-
# [ 0 = disabled, 1 = enabled; enabled by default ]
56+
scan_hexdepth=65536
57+
58+
# Use named pipe (FIFO) for passing file contents hex data instead
59+
# of stdin default; improved performance and greater scanning depth.
60+
# This is highly recommended and works on most systems. The hexfifo
61+
# will be disabled automatically if for any reason it can not be
62+
# successfully utilized.
63+
# [ 0 = disabled, 1 = enabled; enabled by default ]
7764
scan_hexfifo=1
7865

79-
# The maximum byte depth that the scanner will search into
80-
# a files contents; default rules expect a 1024*60 depth
66+
# The maximum byte depth that the scanner will search into a files
67+
# contents when using named pipe (FIFO). Improved performance allows
68+
# for greater scan depth over default scan_hexdepth value.
8169
# [ changing this may have an impact on scan performance ]
8270
scan_hexfifo_depth=524288
8371

84-
# If installed, use ClamAV clamscan binary as default scan
85-
# engine which providers a higher degree of performance.
86-
# This option only uses ClamAV as the scanner engine, LMD
87-
# signatures are still the basis for detecting threats.
88-
# [ 0 = disabled, 1 = enabled; enabled by default ]
72+
# If installed, use ClamAV clamscan binary as default scan engine which
73+
# provides improved scan performance on large file sets. The clamscan
74+
# engine is used in conjunction with native ClamAV signatures updated
75+
# through freshclam along with LMD signatures providing additional
76+
# detection capabilities.
77+
# [ 0 = disabled, 1 = enabled; enabled by default ]
8978
scan_clamscan=1
9079

9180
# Include the scanning of known temporary world-writable
9281
# paths for -a|--al and -r|--recent scan types.
9382
scan_tmpdir_paths="/tmp /var/tmp /dev/shm"
9483

95-
# Allow non-root users to perform malware scans. This must be
96-
# enabled when using mod_security2 upload scanning or if you
97-
# want to allow users to perform scans. When enabled, this will
98-
# populate the /usr/local/maldetect/pub/ path with user owned
99-
# quarantine, session and temporary paths to faciliate scans.
100-
# These paths are populated through cron every 10min with the
101-
# /etc/cron.d/maldet_pub cronjob.
102-
# [ 0 = disabled, 1 = enabled, disabled by defaukt ]
84+
# Allows non-root users to perform scans. This must be enabled when
85+
# using mod_security2 upload scanning or if you want to allow users
86+
# to perform scans. When enabled, this will populate 'pub/' with user
87+
# owned quarantine, session and temporary paths to faciliate scans.
88+
# [ 0 = disabled, 1 = enabled, disabled by default ]
10389
scan_user_access=0
10490

10591
# Process CPU scheduling (nice) priority level for scan operations.
10692
# [ -19 = high prio , 19 = low prio, default = 19 ]
10793
scan_cpunice="19"
10894

10995
##
110-
# [ STATISTICAL ANALYSIS ]
96+
# [ QUARANTINE OPTIONS ]
11197
##
112-
# The string length test is used to identify threats based on the
113-
# length of the longest uninterrupted string within a file. This is
114-
# useful as obfuscated code is often stored using encoding methods
115-
# that produce very long strings without spaces (e.g: base64)
116-
# [ string length in characters, default = 150000 ]
117-
string_length_scan="0" # [ 0 = disabled, 1 = enabled ]
118-
string_length="150000" # [ max string length ]
98+
# The default quarantine action for malware hits
99+
# [0 = alert only, 1 = move to quarantine & alert]
100+
quarantine_hits=0
101+
102+
# Try to clean string based malware injections
103+
# [NOTE: quarantine_hits=1 required]
104+
# [0 = disabled, 1 = clean]
105+
quarantine_clean=1
106+
107+
# The default suspend action for users wih hits
108+
# Cpanel suspend or set shell /bin/false on non-Cpanel
109+
# [NOTE: quarantine_hits=1 required]
110+
# [0 = disabled, 1 = suspend account]
111+
quarantine_suspend_user=0
112+
113+
# The minimum userid value that can be suspended
114+
# [ default = 500 ]
115+
quarantine_suspend_user_minuid=500
119116

120117
##
121118
# [ MONITORING OPTIONS ]
@@ -140,3 +137,17 @@ inotify_docroot=public_html
140137
# Process CPU scheduling (nice) priority level for monitoring process.
141138
# [ -19 = high prio , 19 = low prio, default = 15 ]
142139
inotify_cpunice=15
140+
141+
##
142+
# [ STATISTICAL ANALYSIS ]
143+
# This is a beta feature and as such should be used with caution.
144+
# Currently, this feature can have a substantially negative impact
145+
# on scan performance, especially with large file sets.
146+
##
147+
# The string length test is used to identify threats based on the
148+
# length of the longest uninterrupted string within a file. This is
149+
# useful as obfuscated code is often stored using encoding methods
150+
# that produce very long strings without spaces (e.g: base64)
151+
# [ string length in characters, default = 150000 ]
152+
string_length_scan="0" # [ 0 = disabled, 1 = enabled ]
153+
string_length="150000" # [ max string length ]

‎files/maldet

+9-7
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,6 @@ scan() {
627627
if [ -z "$setmodsec" ]; then
628628
eout "{scan} signatures loaded: $tot_sigs ($md5_sigs MD5 / $hex_sigs HEX / $cust_sigs USER)" 1
629629
fi
630-
631630
if [ -f "$ignore_file_ext" ]; then
632631
if [ ! "$(cat $ignore_file_ext)" == "" ]; then
633632
for i in `cat $ignore_file_ext`; do
@@ -639,19 +638,22 @@ scan() {
639638
done
640639
fi
641640
fi
641+
if [ "$scan_ignore_root" == "1" ]; then
642+
ignore_root="! -uid 0"
643+
fi
642644
if [ "$scan_tmpdir_paths" ] && [ -z "$setmodsec" ]; then
643645
spath_tmpdirs="$scan_tmpdir_paths"
644646
fi
645647
if [ "$days" == "all" ]; then
646648
if [ -z "$setmodsec" ]; then
647649
eout "{scan} building file list for $spath, this might take awhile..." 1
648650
fi
649-
$nice -n $scan_cpunice $find $spath $spath_tmpdirs -maxdepth $scan_find_max_depth $find_opts -type f -size +${scan_find_min_filesize}c -size -$scan_find_max_filesize $include_regex -not -regex "$exclude_regex" $ignore_fext | grep -vf $ignore_paths > $find_results
651+
$nice -n $scan_cpunice $find $spath $spath_tmpdirs -maxdepth $scan_max_depth $find_opts -type f -size +${scan_min_filesize}c -size -$scan_max_filesize $include_regex -not -regex "$exclude_regex" $ignore_fext $ignore_root | grep -vf $ignore_paths > $find_results
650652
else
651653
if [ -z "$setmodsec" ]; then
652654
eout "{scan} building file list for $spath of new/modified files from last $days days, this might take awhile..." 1
653655
fi
654-
$nice -n $scan_cpunice $find $spath $spath_tmpdirs -maxdepth $scan_find_max_depth $find_opts -type f -ctime -$days -size +${scan_find_min_filesize}c -size -$scan_find_max_filesize $include_regex -not -regex "$exclude_regex" $ignore_fext | grep -vf $ignore_paths > $find_results
656+
$nice -n $scan_cpunice $find $spath $spath_tmpdirs -maxdepth $scan_max_depth $find_opts -type f -ctime -$days -size +${scan_min_filesize}c -size -$scan_max_filesize $include_regex -not -regex "$exclude_regex" $ignore_fext $ignore_root | grep -vf $ignore_paths > $find_results
655657
fi
656658
if [ ! -f "$find_results" ] || [ -z "$(cat $find_results)" ]; then
657659
if [ -z "$setmodsec" ]; then
@@ -1528,10 +1530,10 @@ else
15281530
fi
15291531

15301532
if [ ! -f "$sig_md5_file" ] || [ ! -f "$sig_hex_file" ]; then
1531-
sig_version=2013041200000
1533+
sig_version=2012010100000
15321534
eout "{sigup} signature files missing or corrupted, forcing update..." 1
15331535
elif [ "$lines_md5" -lt "1000" ] || [ "$lines_hex" -lt "1000" ]; then
1534-
sig_version=2013041200000
1536+
sig_version=2012010100000
15351537
eout "{sigup} signature files corrupted, forcing update..." 1
15361538
fi
15371539

@@ -1610,12 +1612,12 @@ if [ "$nver" != "$sig_version" ]; then
16101612

16111613
hex_sigs=`$wc -l $sig_hex_file | awk '{print$1}'`
16121614
md5_sigs=`$wc -l $sig_md5_file | awk '{print$1}'`
1613-
if [ ! -f "$custhex_sigs" ]; then
1615+
if [ ! -f "$sig_cust_md5_file" ]; then
16141616
custhex_sigs=0
16151617
else
16161618
custhex_sigs=`$wc -l $sig_cust_hex_file | awk '{print$1}'`
16171619
fi
1618-
if [ ! -f "$custmd5_sigs" ]; then
1620+
if [ ! -f "$sig_cust_hex_file" ]; then
16191621
custmd5_sigs=0
16201622
else
16211623
custmd5_sigs=`$wc -l $sig_cust_md5_file | awk '{print$1}'`

0 commit comments

Comments
 (0)
Please sign in to comment.