A custom Intrusion Detection System (IDS) developed in Python for detecting network intrusions such as port scans, DDoS attacks, brute-force attempts, and DoS attacks. This IDS provides real-time monitoring, alerting, and logging capabilities, allowing administrators to identify and respond to potential threats effectively.
- Real-time Packet Sniffing: Captures network packets using Scapy.
- Custom Rule Engine: Detects suspicious activities based on predefined rules.
- Alerting System: Generates alerts (Notification + Sound + Email) for detected intrusions.
- Menu-Driven Interface: Allows users to interact with the IDS through a console menu.
- Logging: Log all activities inside the ./logs directory.
- Extensibility: Easily add new detection rules and alerting mechanisms (inside ./network_traffic_monitor/traffic_monitor.py).
- Configuration files: located at ./config/config.py
- Python 3.x
- Administrative privileges (for packet sniffing)
- Python packages: loguru, plyer, playsound, & pyshark.
-
Clone the Repository
git clone https://github.com/iamKimlong/intrusion-detection-system-based-on-custom-rules.git
-
Install Required Libraries
Installing pip for python packages on windows
Invoke-WebRequest -Uri https://bootstrap.pypa.io/get-pip.py -OutFile get-pip.py
py, python, python3...etc
py get-pip.py
Installing pip for python packages for linux
sudo pacman -S python-pip for arch linux, other OS' tend to be similar
Run this after
pip install ––upgrade setup-tools wheel pip
pip install loguru plyer playsound pyshark
Note: Depending on your system, you may need to use
pip3instead ofpipor evenpipxfor Linux.
-
Ensure Administrative Privileges
Packet sniffing requires root or administrative privileges. Make sure you run the IDS with the necessary permissions.
Run the IDS using the following command:
sudo python3 main.py # for windows
# for linux (if using a virtual environment for python packages)
sudo Downloads/intrusion-detection-system-based-on-custom-rules/venv/bin/python -u Downloads/intrusion-detection-system-based-on-custom-rules/main.pyNote: Running as root is necessary for packet sniffing.
To ensure the IDS is functioning correctly, you can simulate attacks using tools like nmap bettercap hping3 or macof.
Use nmap to simulate a port scan:
nmap -p 1-1000 <target_ip>- Replace
<target_ip>with the IP address of the machine running the IDS.
Use hping3 to simulate a DDoS attack:
hping3 --flood -p 80 -S <target_ip>- Ensure
hping3is installed on your system (sudo pacman -S hpingon Debian-based systems). - Replace
<target_ip>with the IP address of the machine running the IDS.
- Entry point of the application.
- Handles user interaction through the
MenuHandlerclass.
- Monitor all traffics that goes through the network
- Check each packet's source and destination address frequencies within a certain timeframe
- Alert through notification, sound, and email
This project is licensed under the GNU General Public License v3.0. See the LICENSE file for details.
Disclaimer: This IDS is intended for educational purposes and should be used responsibly. Unauthorized network scanning or intrusion detection on networks without permission is illegal and unethical.