Skip to main content

A host-based intrusion detection system.

Project description

pyHIDS

Presentation

pyHIDS is a HIDS (host-based intrusion detection system) for verifying the integrity of a system.

It is recommended to use Python >= 3.11.

Features

  • checks the integrity of system's files with a list of rules;
  • checks the output of commands (iptables, etc.);
  • possibity to use RSA to sign to check the integrity of its database;
  • alerts are written in the logs of the system;
  • alerts can be sent via email to a list of users;
  • alerts can be sent on IRC channels through the irker IRC client (which should be running as a daemon);
  • verify files with Hashlookup, Pandora, MISP and YARA;
  • possibility to export the database in a Bloom or a Cuckoo filter.

You can define rules to specify files to be checked.

Installation

You can use pipx.

$ pipx install pyHIDS
$ export PYHIDS_CONFIG=~/.pyHIDS/conf.cfg

An example of configuration file is available. With this file you can configure:

  • the integration with Hashlookup, Pandora, MISP and YARA;
  • the IRC connection for the notifications;
  • the SMTP connection for the email notifications;
  • the list of files to scan;
  • the regular expressions to specify files to scan in a folder;
  • the command's output to check.

Usage

$ pyhids gen-keys --size 2048
Generating 2048 bits RSA keys…
Dumping Keys
Done.

$ pyhids gen-base --sign
Generating database…
2427 files in the database.

$ pyhids run --check-signature
Verifying the integrity of the base of hashes…
Database integrity verified.
Verifying the integrity of the files…
[12/10/23 21:35:26] Error(s) : 0
[12/10/23 21:35:26] Warning(s) : 0
[12/10/23 21:35:26] HIDS finished.

You can skip the first step (generation of the keys) if you do not want to sign the database with the solution provided with pyHIDS (RSA) or if you do not want to sign the database.

Change a monitored file and relaunch the program:

$ pyhids run
Verifying the integrity of the files…
[12/10/23 14:41:51] [warning] /bin/cifsdd changed.

The program warns that the file has changed. When this happens, a warning is generated in the logs of the system and an email is sent to the administrator. If no change is detected, only the log file is updated.

Log file generated:

$ tail var/log
[09/10/23 14:41:51] [notice] /bin/cifscreds ok
[09/10/23 14:41:51] [notice] /bin/mbim-network ok
[09/10/23 14:41:51] [notice] /bin/xclip ok
[09/10/23 14:41:51] [notice] /bin/preparetips5 ok
[09/10/23 14:41:51] [notice] /bin/pamperspective ok
[12/10/23 14:41:51] [warning] /bin/cifsdd changed.
[09/10/23 14:41:51] [notice] /bin/pod2usage ok
[09/10/23 14:41:51] [notice] /bin/mkzftree ok
[09/10/23 14:41:51] Error(s) : 0
[09/10/23 14:41:51] Warning(s) : 1
[09/10/23 14:41:51] HIDS finished.

If you want to see the logs in syslog you have different options depending on your system:

$ journalctl --follow
Oct 12 22:58:47 debian pyhids[98135]: pyHIDS - [12/10/23 22:58:47] [warning] /etc/resolv.conf changed.
Oct 12 22:58:47 debian pyhids[98135]: pyHIDS - [12/10/23 22:58:47] [warning] /bin/mdsearch changed.
Oct 12 22:58:47 debian pyhids[98135]: pyHIDS - [12/10/23 22:58:47] [warning] /bin/smbcacls changed.
Oct 12 22:58:47 debian pyhids[98135]: pyHIDS - [12/10/23 22:58:47] [warning] /bin/smbspool changed.
Oct 12 22:58:47 debian pyhids[98135]: pyHIDS - [12/10/23 22:58:47] [warning] /bin/smbclient changed.
Oct 12 22:58:47 debian pyhids[98135]: pyHIDS - [12/10/23 22:58:47] [warning] /bin/smbcquotas changed.
Oct 12 22:58:47 debian pyhids[98135]: pyHIDS - [12/10/23 22:58:47] [warning] /bin/smbget changed.
Oct 12 22:58:47 debian pyhids[98135]: pyHIDS - [12/10/23 22:58:47] [warning] /bin/nmblookup changed.
Oct 12 22:58:48 debian pyhids[98135]: pyHIDS - [12/10/23 22:58:47] [warning] /bin/rpcclient changed.
Oct 12 22:58:48 debian pyhids[98135]: pyHIDS - [12/10/23 22:58:48] [warning] /bin/smbpasswd changed.
Oct 12 22:58:48 debian pyhids[98135]: pyHIDS - [12/10/23 22:58:48] [warning] /bin/dbwrap_tool changed.
Oct 12 22:58:48 debian pyhids[98135]: pyHIDS - [12/10/23 22:58:48] [warning] /bin/cifsdd changed.
Oct 12 22:58:48 debian pyhids[98135]: pyHIDS - [12/10/23 22:58:48] [warning] /bin/net changed.
Oct 12 22:58:48 debian pyhids[98135]: pyHIDS - [12/10/23 22:58:48] [warning] /bin/samba-regedit changed.
Oct 12 22:58:48 debian pyhids[98135]: pyHIDS - [12/10/23 22:58:48] [warning] /bin/testparm changed.
Oct 12 22:58:48 debian pyhids[98135]: pyHIDS - [12/10/23 22:58:48] [warning] /bin/smbtree changed.
$ journalctl --since="1 minute ago"
$ tail -f /var/log/syslog

Other features

Checks with external tools

Check for known malicious files with Hashlookup, Pandora, MISP or YARA.

$ pyhids hashlookup
$ pyhids pandora
$ pyhids misp
$ pyhids yara

Export functions

$ pyhids export --bloom-filter
Bloom filter generated and stored: var/bloom/bloomfilter.bf
$ pyhids export --cuckoo-filter
Cuckoo filter generated and stored: var/cuckoo/cuckoofilter.cf

Automatic execution

Use the time-based job scheduler, Cron, in order to schedule system scans. In your shell enter the command:

$ crontab -e

Add the following line to check the integrity of the system every fifty minutes:

*/50 * * * * pyhids run

After each system check, pyHIDS sends a report to the administrators. In the case of an attacker who has deleted the cron line, for example.

License

pyHIDS is under GPLv3 license.

Copyright (C) 2010-2025 Cédric Bonhomme

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyhids-0.9.6.tar.gz (25.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyhids-0.9.6-py3-none-any.whl (25.0 kB view details)

Uploaded Python 3

File details

Details for the file pyhids-0.9.6.tar.gz.

File metadata

  • Download URL: pyhids-0.9.6.tar.gz
  • Upload date:
  • Size: 25.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for pyhids-0.9.6.tar.gz
Algorithm Hash digest
SHA256 884a037de977e08dd02f2e7add4c928160553f2157a0980913cb4f7166fe279c
MD5 455741e89524205d1b4f027f4884768b
BLAKE2b-256 31a19797c46467a83ea72902d9962699bc98b4ef9509e0c126b9be47d990f6ec

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyhids-0.9.6.tar.gz:

Publisher: release.yml on cedricbonhomme/pyHIDS

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyhids-0.9.6-py3-none-any.whl.

File metadata

  • Download URL: pyhids-0.9.6-py3-none-any.whl
  • Upload date:
  • Size: 25.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for pyhids-0.9.6-py3-none-any.whl
Algorithm Hash digest
SHA256 767e0dc9eb5c12d6ab05bb728d2258f54f151a733f2d533ecc148cf0cbd97bb1
MD5 1f3614238c8228e56de1cd9394d00651
BLAKE2b-256 868365f780228828e54e03dc81f93021b4225656df7d997715f466d651e8fb1f

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyhids-0.9.6-py3-none-any.whl:

Publisher: release.yml on cedricbonhomme/pyHIDS

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page