Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rkhunter module #381

Merged
merged 5 commits into from
Sep 7, 2022
Merged

Add rkhunter module #381

merged 5 commits into from
Sep 7, 2022

Conversation

Kovah
Copy link
Contributor

@Kovah Kovah commented Aug 29, 2022

It's me, again. 😄

This PR adds a module for rkhunter / Malware check: #45
Thing that could be improved before merge is to loop through multiple rootkit checks in one task (identifiable by "Performing ....").

Example output:

Running Rootkit Hunter version 3.1.0 on localhost

Info: Start date is Mon 29 Aug 2022 06:56:27 PM UTC

Info: Detected operating system is 'Linux'
Found O/S name: Ubuntu 1.2.15Info: Environment shell is /bin/bash; rkhunter is using dash
Info: Using configuration file '/etc/rkhunter.conf'
Info: Installation directory is '/usr'
Info: Using language 'en'
Info: Using '/var/lib/rkhunter/db' as the database directory
Info: Using '/usr/share/rkhunter/scripts' as the support script directory
Info: Using '/var/lib/rkhunter/db' as the database directory
Info: Using '/usr/share/rkhunter/scripts' as the support script directory
Info: Using '/usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin /usr/games /usr/local/games /snap/bin /usr/libexec' as the command directories
Info: Using '/var/lib/rkhunter/tmp' as the temporary directory
Info: No mail-on-warning address configured

Checking if the O/S has changed since last time...
Info: Nothing seems to have changed.
Info: Locking is not being used

Starting system checks...

Performing check of possible rootkit files and directories
  Checking for TCP port 25000                       [ Not found ]
  Checking for TCP port 31337                       [ Not found ]
  Checking for TCP port 7000                        [ Not found ]
  Checking for directory '/usr/doc/backup'          [ Not found ]
  Checking for file '/etc/rc.d/rc6.d/S55IptabLex'   [ Not found ]
  Checking for file '/tmp/bill.lock'                [ Not found ]
  Checking for file '/usr/lib/elm/arobia/elm/sd.pp' [ Not found ]
  Checking for file '/usr/lib/elm/arobia/elm/sdco'  [ Not found ]
  Checking for string '/lib/.xsyslog'               [ Not found ]
  Checking for string '/usr/bin/rcpc'               [ Not found ]
  Checking for string '/usr/include/gpm2.h'         [ Skipped ]
  Scanning for string /dev/.lib/lib/lib             [ Not found ]
  Scanning for string /usr/include/.../proc.h       [ Not found ]
  Checking /dev for suspicious file types           [ Not found ]
  Running skdet command                             [ Not found ]

Performing additional rootkit checks
  Checking for zaRwT.KiT Rootkit...
    Checking for TCP port 7000                       [ Found ]
    Checking for directory '/usr/doc/backup'         [ Not found ]
    Checking for directory '/xochikit'               [ Not found ]
    Checking for file '/usr/bin/bsd-port/getty.lock' [ Not found ]
    Checking for string '/usr/lib/ldlibdu.so'        [ Not found ]
  zaRwT.KiT Rootkit                                  [ Found ]

Performing system boot checks
  Checking for Tuxtendo Rootkit...
    Checking for directory '/var/lock/subsys/...datafile.../...datafile...' [ Not found ]
    Checking for file '/lib/tls/libkeyutils.so.1'                           [ Not found ]
    Checking for file '/lib64/libns5.so'                                    [ Not found ]
    Checking for kernel symbol 'h4x_open'                                   [ Not found ]
    Checking for string '/dev/ida/.inet'                                    [ Not found ]
  Tuxtendo Rootkit                                                          [ Not found ]

...

Warning
By the way: I had to use the nightly Rust channel, because of this error message:
#![feature] may not be used on the stable release channel in anyhow-1.0.62/src/lib.rs:214:32
Not sure if this is really intended.

Copy link
Owner

@svenstaro svenstaro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good stuff! Just a few notes.

@@ -0,0 +1,239 @@
Checking for directory '/dev/ptyas'
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it perhaps be smarter to have a list of directories and a list of files? These could then also be consumed by other genact modules later on. It's also fine if you want to just play these files from the top for now, your choice.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll have a look tomorrow.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thought about this and having files and directories in one file would be difficult to differentiate. If we decide to have normalized data for the Linux filesystem, I would create one file for directories and one for regular files. Maybe this could be done if another module needs this data?

Comment on lines 8 to 12
use crate::data::RKHUNTER_CHECKS_LIST;
use crate::data::RKHUNTER_CHECKS_SHORT_LIST;
use crate::data::RKHUNTER_INFOS_LIST;
use crate::data::RKHUNTER_ROOTKITS_LIST;
use crate::data::RKHUNTER_TASKS_LIST;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you merge these?

Copy link
Contributor Author

@Kovah Kovah Aug 30, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reduced it to RKHUNTER_CHECKS_LIST, RKHUNTER_ROOTKITS_LIST and RKHUNTER_TASKS_LIST.
I could move the Rootkits into an array in the rkhunter module, but I am not sure if this is fine?

@svenstaro
Copy link
Owner

I like it! Merging as is. Thanks. :)

@svenstaro svenstaro merged commit 15d1d83 into svenstaro:master Sep 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants