i Linux malware detect (LMD) – All things in moderation

Linux malware detect (LMD)

Description

Linux Malware Detect, also known as maldet or LMD, is one popular option that can be easily installed and configured to scan for known malware signatures. It can be run manually to perform one-off scans and can also be daemonized to run regularly scheduled scans. Reports from these scans can be emailed to the server administrators.

The driving force behind LMD is that there is currently limited availability of open source/restriction free tools for Linux systems that focus on malware detection and more important that get it right. Many of the AV products that perform malware detection on Linux have a very poor track record of detecting threats, especially those targeted at shared hosted environments.

The threat landscape in shared hosted environments is unique from that of the standard AV products detection suite in that they are detecting primarily OS level trojans, rootkits and traditional file-infecting viruses but missing the ever increasing variety of malware on the user account level which serves as an attack platform.

Features

  • MD5 file hash detection for quick threat identification
  • HEX based pattern matching for identifying threat variants
  • Statistical analysis component for detection of obfuscated threats(e.g: base 64)
  • Intergrated detection of ClamAV to use as scanner engine for improved performance
  • Intergrated signature update feature with -u | -update
  • Integrated version update feature with -d | -update-ver
  • scan-recent option to scan only files that have been added/changed in X days
  • scan-all option for full path based scanning
  • checkout option to upload suspected malware to rfxn.com for review/hashing
  • Full reporting system to view current and previous scan results
  • Quarantine queue that stores threats in a safe fashion with no permissions
  • Quarantine batching option to qurantine the results of a current or past scans
  • Quarantine restore option to restore files to original path, owner and perms
  • Quanrantine suspend account option to Cpanel suspend or shell revoke users
  • Cleaner rules to attempt removal of malware injected string
  • Cleaner batching opton to attempt cleaning of previous scan reports
  • Cleaner rules to remove base64 and gzinflate(base64 injected malware)
    daily cron based scanning of all changes in last 24h in user homedirs
  • daily cron script compatible with stock RH style systems, Cpanel & Ensim
  • kernel based inotify real time file scanning of created/modified/moved files
  • kernel inotify monitor that can take path data from STDIN or FILE
  • kernel inotify monitor convenience feature to monitor system users
  • kernel inotify monitor can be restricted to a configurable user html root
  • kernel inotify monitor with dynamic sysctl limits for optimal performance
  • kernel inotify alerting through daily and/or optional weekly reports
  • HTTP upload scanning through mod_security2 inspectFile hook
  • e-mail alert reporting after every scan execution (manual & daily)
  • path, extension and signature based ignore options
  • background scanner option for unattended scan operations
  • verbose logging & output of all actions

Threat source data

The defining difference with LMD is that it doesn’t just detect malware based
on signatures/hashes that someone else generated but rather it is an
encompassing project that actively tracks in the wild threats and generates
signatures based on those real world threats that are currently circulating.

There are four main sources for malware data that is used to generate LMD
signatures:

  • Network Edge IPS: Through networks managed as part of author day-to-day job,
    primarily web hosting related, author’s web servers receive a large amount of daily
    abuse events, all of which is logged by our network edge IPS. The IPS events
    are processed to extract malware url’s, decode POST payload and base64/gzip
    encoded abuse data and ultimately that malware is retrieved, reviewed, classified
    and then signatures generated as appropriate. The vast majority of LMD signatures
    have been derived from IPS extracted data.

  • Community Data: Data is aggregated from multiple community malware websites
    such as clean-mx and malwaredomainlist then processed to retrieve new
    malware, review, classify and then generate signatures.

    • ClamAV: The HEX & MD5 detection signatures from ClamAV are monitored for
      relevant updates that apply to the target user group of LMD and added to the
      project as appropriate. To date there has been roughly 400 signatures ported
      from ClamAV while the LMD project has contributed back to ClamAV by
      submitting over 1,100 signatures and continues to do so on an ongoing basis.
  • User Submission: LMD has a checkout feature that allows users to submit
    suspected malware for review, this has grown into a very popular feature and
    generates on average about 30-50 submissions per week.

Detected threats

LMD 1.5 has a total of 10,822 (8,908 MD5 / 1,914) signatures, before any updates. The top 60 threats by prevalence detected by LMD are as follows:

base64.inject.unclassed     perl.ircbot.xscan
bin.dccserv.irsexxy         perl.mailer.yellsoft
bin.fakeproc.Xnuxer         perl.shell.cbLorD
bin.ircbot.nbot             perl.shell.cgitelnet
bin.ircbot.php3             php.cmdshell.c100
bin.ircbot.unclassed        php.cmdshell.c99
bin.pktflood.ABC123         php.cmdshell.cih
bin.pktflood.osf            php.cmdshell.egyspider
bin.trojan.linuxsmalli      php.cmdshell.fx29
c.ircbot.tsunami            php.cmdshell.ItsmYarD
exp.linux.rstb              php.cmdshell.Ketemu
exp.linux.unclassed         php.cmdshell.N3tshell
exp.setuid0.unclassed       php.cmdshell.r57
gzbase64.inject             php.cmdshell.unclassed
html.phishing.auc61         php.defash.buno
html.phishing.hsbc          php.exe.globals
perl.connback.DataCha0s     php.include.remote
perl.connback.N2            php.ircbot.InsideTeam
perl.cpanel.cpwrap          php.ircbot.lolwut
perl.ircbot.atrixteam       php.ircbot.sniper
perl.ircbot.bRuNo           php.ircbot.vj_denie
perl.ircbot.Clx             php.mailer.10hack
perl.ircbot.devil           php.mailer.bombam
perl.ircbot.fx29            php.mailer.PostMan
perl.ircbot.magnum          php.phishing.AliKay
perl.ircbot.oldwolf         php.phishing.mrbrain
perl.ircbot.putr4XtReme     php.phishing.ReZulT
perl.ircbot.rafflesia       php.pktflood.oey
perl.ircbot.UberCracker     php.shell.rc99
perl.ircbot.xdh             php.shell.shellcomm  

Installation

Download Linux malware detect(LMD)

You can download directly from here
or clone project form github:

git clone https://github.com/rfxn/linux-malware-detect.git  

Install LMD

Inside folder linux-malware-detect
Run install :

sudo ./install.sh  

Usages

sudo maldet -h  
 -b, --background
      Execute operations in the background, ideal for large scans
      e.g: maldet -b -r /home/?/public_html 7

    -u, --update [--force]
       Update malware detection signatures from rfxn.com

    -d, --update-ver [--force]
       Update the installed version from rfxn.com

    -m, --monitor USERS|PATHS|FILE
       Run maldet with inotify kernel level file create/modify monitoring
       If USERS is specified, monitor user homedirs for UIDs > 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

    -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 [email protected]

    -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/maldetect/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 protected],quar_hits=1

    -p, --purge
       Clear logs, quarantine queue, session and temporary data.

Run a sample scan

I have a r57.php shell file in folder samples.

Run scan:

sudo maldet -a /home/osboxes/Downloads/samples/  

LMD detected r57 shell.

lmd

So, it’s can be more useful if you run a cron daily to automatic scan folders you want.

Leave a Reply