Custom-Firewall ~  Created a firewall to filter packets based on custom rules.

Custom-Firewall ~ Created a firewall to filter packets based on custom rules.

Backround:
Considering configuration {HOST1,FIREWALL,HOST2}
•HOST1:We have made a raw socket and used this to forward all the traffic generated to firewall.The traffic types can be TCP,UDP or ICMP.I have created custom headers for each of the layers and forwarded this packet to the firewall residing in a different vm.We Used struct to created custom headers of the packet which is unpacked in the firewall.
•FIREWALL:Here,We made a raw socket and kept listening for the frames destined to the mac address of the firewall.Then I unpacked all the layer header and determined whether it is a TCP,UDP or ICMP packet.Extracted data from the frame is forwarded to the client on HOST3 according to the firewall rules.
•HOST2:Here there is a client running on this host which can be configured to receive TCP,UDP or ICMP packets based on the application.

Custom-Firewall

Todo:
Making a Command Line Interface(CLI): We created a custom command line interface to add rules, delete rules and update them.
• Using a dictionary to store the rules: I used a python dictionary to store the rules, for this part I made two major categories:Inbound and Outbound.
• Basic Structure of Dictionary: DICT { InBound {} Outbound {} } , Though for the purpose of this assignment we did not use Outbound Rules but this can be extended to that easily.
• All Rules were added through CLI to the dictionary.
• TCP / UDP Rules: I incorporated <,>,=,a-b(range) rules for the purpose of this assignment, all the ports that are in these rules will be rejected by the firewall all others will be checked for other rules.
• MAC-ADDRESS/IPv4/IPv6: For this I have taken input address(ip/mac) all the addresses in the input will be rejected by the firewall.

Dependencies:
+ Python 2.7.x

Usage:

Source: https://github.com/satishrdd