Code Monkey home page Code Monkey logo

parse_pfsense_rules_for_logstash's Introduction

Parsing pfSense 2.1 rules for logstash

This script parses the firewall rules from pfSense and emits them in a format suitable for logstash translate plugin.

Installing

  • From GitHub: pip install https://github.com/neuhalje/parse_pfsense_rules_for_logstash/zipball/master
  • local installation: python setup.py install
  • directly call ./pfSense2Logstash

Usage

  1. Export the rulesets on pfSense with pfctl -vvvsr. This can be done via SSH, or in the "Diagnostics/Command Prompt" part of the WebUI.
  2. Run pfSense2Logstash rules.txt > rule_id_to_tag.dict
  3. Include the file in the logstash PLUGIN rule

Example Result

Input file

@0 scrub on vr2 all fragment reassemble
 [ Evaluations: 12882073  Packets: 5093291   Bytes: 1673472449  States: 0     ]
 [ Inserted: uid 0 pid 51319 ]
@0 anchor "relayd/*" all
 [ Evaluations: 120503    Packets: 0         Bytes: 0           States: 0     ]
 [ Inserted: uid 0 pid 51319 ]
@1 anchor "openvpn/*" all
 [ Evaluations: 120503    Packets: 0         Bytes: 0           States: 0     ]
 [ Inserted: uid 0 pid 51319 ]
@3 block drop in log quick inet6 all label "Block all IPv6"
 [ Evaluations: 120503    Packets: 1170      Bytes: 84240       States: 0     ]
 [ Inserted: uid 0 pid 51319 ]
@120 block return in quick on vr1 all label "USER_RULE"
 [ Evaluations: 29        Packets: 29        Bytes: 1273        States: 0     ]
 [ Inserted: uid 0 pid 51319 ]
@121 anchor "tftp-proxy/*" all
 [ Evaluations: 27765     Packets: 0         Bytes: 0           States: 0     ]
 [ Inserted: uid 0 pid 51319 ]

Output

'0':'"relayd/*" all'
'1':'"openvpn/*" all'
'3':'Block all IPv6drop in log quick inet6 all'
'120':'USER_RULEreturn in quick on vr1 all'
'121':'"tftp-proxy/*" all'

Example Logstash Config

TODO

Development

Test

nosetests

Building the package

  • local installation: python setup.py install
  • Build .egg: python setup.py bdist

License

BSD 3-Clause

parse_pfsense_rules_for_logstash's People

Contributors

neuhalje avatar

Watchers

James Cloos avatar  avatar  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.