This project implements a basic firewall application in C++. The firewall processes network traffic based on a set of rules provided in a specific format. It evaluates whether the traffic should be allowed or denied, logs the results, and displays them in a command-line interface (CLI). The processed results are also saved in a .DAT file for later review.
- Rule-Based Filtering: Evaluates network traffic against predefined firewall rules.
- Traffic Processing: Supports processing of traffic data from external files.
- Result Logging: Logs results in a
.DATfile for further analysis. - CLI Display: Displays processed results directly in the command-line interface.
- Customizable Rules: Rules can be easily modified by editing the input text file.
-
Rules File
Contains the firewall rules in the following format:
[RULE NO] [FIELD] [VALUE] [DECISION]- RULE NO: Unique identifier for each rule.
- FIELD: The traffic field to match (e.g.,
SRC,DST,PRO). - VALUE: The value or range of values to match (e.g., IP address, protocol).
- DECISION: Specifies whether the traffic should be ALLOW or DENY.
-
Traffic File
Contains traffic data entries formatted as:
[SRC:source_IP;DST:destination_IP;PRO:protocol;DATA_IN_HEX_FORMAT][...]- SRC: Source IP address.
- DST: Destination IP address.
- PRO: Protocol (e.g., TCP, UDP).
- DATA_IN_HEX_FORMAT: Traffic data represented in hexadecimal format.
- Results File (
results.dat)
After processing the traffic against the firewall rules, the results are output in a.DATfile with the following structure:
SRC: source_IP
DST: destination_IP
PRO: protocol
DECISION: ALLOW/DENY
RULE_NO: rule_number
- Place the rules.txt and traffic.txt files in the same directory as the compiled program.
- Run the firewall program with the following command:
./firewall rules.txt traffic.txtrules.txt: The file containing firewall rules.traffic.txt: The file containing network traffic data.
- After running the program, the processed traffic results will be written to
results.dat. - The results will also be displayed directly in the command-line interface for immediate review.
/firewall ├── main.cpp # Main logic of the firewall program ├── rules.txt # Input file with firewall rules ├── traffic.txt # Input file with traffic data ├── results.dat # Output file containing processed results ├── README.md # Project documentation (this file)
- C++11 or later (for the required language features)
To compile the program, use any C++ compiler. For example:
g++ -o firewall main.cpp
This project is open-source. Feel free to use and modify it according to your needs. Contributions and improvements are welcome!