Code Monkey home page Code Monkey logo

personal_firewall's Introduction

๐Ÿ”ฅ personal_firewall ๐Ÿ”ฅ

A program that emulates a personal firewall (specific to IPv4 packets), written in Python.

Pre-reqs: Python3

This firewall is capable of filtering both incoming and outgoing packets. For simplicity, there is no networking involved - future versions may include network capabilities. The program simply reads in a specified config file, reads packets from stdin, and outputs the results to stdout.

When the simulator starts, it first reads in the firewall rules via the config file. After reading in the rules, the simulator will then start reading standard input line by line. Each line via standard input will describe a simulated packet. For each packet, the program determines what action to incur on the packet based on the rules in the config file. The resulting actions are sent to stdout.

Configuration file format:

<direction> <action> <ip> <port> [flag]
  • direction: the direction of the traffic, 'in' or 'out'
  • action: what to do with the packet, 'accept', 'drop', and 'deny'
  • ip: defines the IP range, specified by an IP range using CIDR notation, or a wildcard '*'
  • port: a destination port which is an integer between 0-65535, comma delimited, wildcard '*' available
  • flag: (optional) "established" flag which describes whether the rule will be applied only to packets that are part of an established connection or to all packets (if the field is not present, the rule applies to all packets)

Packet file format:

<direction> <ip> <port> <flag>
  • direction: direction of the packet - either 'in' or 'out'
  • ip: for incoming packets this is the source IP address, for outgoing packets this is the destination IP address
  • port: integer between 0-65535
  • flag: boolean 0 (new session) or 1 (established session)

Output:

<action>(<rule number>) <direction> <ip> <port> <flag>

Command & Example Output:

The following output is comparing the program output with a solution file (found in test_files: results1.txt, results2.txt, and results3.txt). Note that the program will output an error and exit if it reads a packet that does not contain a valid IPv4 address.

Personal Firewall Example Output

Originally written for W2017 CPSC 526: Network Security

personal_firewall's People

Contributors

daniellacoste avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.