PerfctlKiller is a C++ application designed to monitor and perform security actions, including killing malicious processes and removing suspicious directories or files. The program runs on a defined interval and executes a series of actions that are customizable. This tool is useful for preventing or mitigating malicious activities on a Linux system.
- Process Monitoring: Kills malicious processes based on the process name.
- Directory Removal: Removes potentially harmful directories or files.
- Logging: Logs actions and their results to a log file for tracking and auditing.
- Customizable Actions: Easily extendable for other actions (e.g., system checks, cleanup, etc.).
- Interval-based Execution: Actions are executed periodically on a set interval.
- CMake 3.16 or higher
- C++23 Standard
- Linux-based Operating System (tested on Ubuntu)
- A compatible C++ compiler (e.g., GCC, Clang)
git clone https://github.com/thecompez/PerfctlKiller.git
cd PerfctlKillerMake sure you have CMake installed on your system.
mkdir build
cd build
cmake ..
makesudo make installThis will install the executable to the default system directories (/usr/bin, /usr/lib, etc.).
To run the application, execute the compiled binary:
PerfctlKillerThe program will continuously monitor and perform the defined actions at the specified interval (default is every 5 seconds).
You can modify the list of actions inside the main.cpp file to include your own processes or directories to monitor.
- PrintMessageAction: Prints a custom message to the console (useful for logging or monitoring purposes).
- KillProcessAction: Kills a specified process by name. The process is identified using
pgrepand killed withpkill. - RemoveDirectoryAction: Removes a specified directory and its contents using the
rm -rfcommand.
The main.cpp file can be modified to add new actions. Here’s how you might add more actions:
monitor.addAction(std::make_unique<PrintMessageAction>("Custom action running"));
monitor.addAction(std::make_unique<KillProcessAction>("malicious-process"));
monitor.addAction(std::make_unique<RemoveDirectoryAction>("/path/to/suspicious/folder"));All actions are logged in a file named malware_prevent.log in the current directory. The log includes timestamps for when actions are performed, making it easy to track activity.
[Wed Jan 30 13:42:01 2025] Process 'perfctl' found and killed.
[Wed Jan 30 13:42:06 2025] Directory '/root/.config/cron/perfcc' removed.
Contributions are welcome! If you'd like to contribute, please fork the repository, create a new branch, and submit a pull request.
- Fork the repository.
- Create a new branch for your feature or bugfix.
- Commit your changes.
- Push your changes to your fork.
- Submit a pull request.
This project is licensed under the MIT License - see the LICENSE file for details.
- The idea for this project came from a need to improve system security by automating the detection and removal of malicious processes and files.