Skip to content

Abeera-Mehtab/Firewall-Project-CLI_Semester1

Repository files navigation

Firewall Application in C++

Overview

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.

Features

  • 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 .DAT file 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.

File Descriptions

Input Files

  1. 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.
  2. 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.

Output File

  • Results File (results.dat)
    After processing the traffic against the firewall rules, the results are output in a .DAT file with the following structure:
    SRC: source_IP
    DST: destination_IP
    PRO: protocol
    DECISION: ALLOW/DENY
    RULE_NO: rule_number

Usage

Command-Line Syntax

  1. Place the rules.txt and traffic.txt files in the same directory as the compiled program.
  2. Run the firewall program with the following command:
    ./firewall rules.txt traffic.txt
    • rules.txt: The file containing firewall rules.
    • traffic.txt: The file containing network traffic data.

Result Display

  • 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.

Project Structure

/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)

Dependencies

  • C++11 or later (for the required language features)

Compilation

To compile the program, use any C++ compiler. For example:
g++ -o firewall main.cpp

License

This project is open-source. Feel free to use and modify it according to your needs. Contributions and improvements are welcome!

About

My first C++ CLI project of a Packet Filtering Firewall based on Rules

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages