Hidden firewall in Kernel
My custom LKM generator for extra protection
Last updated
My custom LKM generator for extra protection
Last updated
The HiddenWall is a Linux kernel module generator for custom rules with Netfilter. (block ports, Hidden mode, firewall functions and soon). So in a bad situation, an attacker can put your iptables/ufw to fall. But if we have HiddenWall, the attacker will not find the hidden kernel module that blocks external access because it has a hook to Netfilter on kernel land(think like a second layer for Firewal.
My beginning purpose in this project is to protect my server, and now it is to protect my friends' machines. When I talk to friends, I say peoples that don't know how to write low-level code. Using HiddenWall, we can generate a custom kernel module for our firewall configuration.
The low-level programmer can write new templates for modules soon.
A hidden firewall in the form of a loadable kernel module (LKM) can offer several advantages over other types of firewalls.
Customization: Because an LKM is a separate piece of code that can be loaded and unloaded from the kernel at runtime, it can be customized and tailored to specific needs. This can be particularly useful for organizations with specific firewall policy requirements, as an LKM can be developed to meet those needs.
Modularity: An LKM is a self-contained unit of code that can be loaded and unloaded from the kernel as needed. This makes it easy to add or remove firewall functionality without affecting the rest of the system.
Performance: An LKM firewall can offer improved performance over other types of firewalls, as it can make filtering decisions directly within the kernel and has direct access to the network stack.
https://github.com/CoolerVoid/HiddenWall
Tool to interpret YAML file and generate a C language file "Linux kernel module".
YAML context is a white screen to create your custom firewall in kernel land. Yes is not hard when you use HiddenWall.
The resource to generate the hidden kernel module, yes, is invisible not even the root user can see it.
The resource to turn the Linux kernel module visible, passing a key to enable the context.
Persistence recipe with scripts to always up HiddenWall when you boot the system.
The resource to hide the LKM password.
Communication by device char (different from other Rootkits that use signal and ioctl)
Static random junk code injection in the generated LKM turns each binary signature unique during the compilation.
Verify if the kernel version is 3.x, 4.x, or 5.x:
Clone the repository
Enter the folder
Edit your firewall rules in the directory rules/server.YAML, the python script, use that file to generate a new firewall module.
If you want to study the static code to generate, look at the content at directory "templates".
If you want to generate a kernel module following your YAML file of rules, follow that command:
This action can generate a generic module with the rules of the server.YAML, if you want to use another template, you can use "wall.c", so the template module "hidden wall" has the option to run on hidden mode(is not visible to "# lsmod" for example).
If you use Fedora Linux, install kernel packages for the developer:
On Ubuntu Linux:
To test the module by root:
YAML's rule to generate a module is simple, drop all out to in packets, accept ports 80,443, and 53. The machine 192*.181 can connect at ports 22 and 21.
If you use Nmap at localhost/127.0.0.1, you can view the ports open because rule liberate_in_2_out is true.
The password to turn Firewall visible is "AbraKadabra".
The password to turn the Firewall invisible is "Shazam".
You need to send the password for your fake device, "usb14".
To exit the module, we need to turn visible at the "lsmod" command ...
It was tested on ubuntu 16 and fedora 29 at kernels "3.x","4.x" and "5.x".
Support to IPV6.
Macro to select the interface(to use multiple modes for each interface).
Option to remove last logs when turn hides mode.
Option to search and remove other toolkits.
Code generator for eBPF.
The purpose of this tool is to use in pentest, and take attention if you have proper authorization before using that. I do not have responsibility for your actions. You can use a hammer to construct a house or destroy it, choose the law path, don't be a bad guy, remember.
Wikipedia Netfilter https://en.wikipedia.org/wiki/Netfilter
Linux Device Drivers http://lwn.net/Kernel/LDD3/
M0nad's Diamorphine https://github.com/m0nad/Diamorphine/
Thank you for reading!
cheers