GithubHelp home page GithubHelp logo

tc-ingress's Introduction

Deep packet inspection with tc made easier :)

The test script is intended to make writing tc ingress rules for deep packet inspection easier. Also includes a length check first to help with efficiency.

u32 in iptables and "match u32" in tc both grab 4 bytes at a time by default. If you only want to match 3 bytes change an ff to 00 in the test script.

This script expects 4 arguments:

  1. The interface name you want to make the rule on.

  2. The "Total Length" of the packet you want to do the byte check on. For instance if the packet is 48 bytes then use "48" for this argument

  3. We use iptables u32 default syntax here. So the byte number or offset you want to start the 4 byte check from is on the left side of the "=" and the 4 bytes to match go on the right side. For example "36=0x0103080a" means: starting at byte 36 in the packet look for these 4 bytes: 0103080a.

  4. The action. This will usually just be either "pass" or "drop" but tc does have others.

So an example to generate a tc rule checking for bytes 0103080a starting at byte number 35 in the packet would be:

./test.sh eth0 48 "36=0103080a" drop

In out.txt you will see the rule generated. Keep in mind this script has little testing so out.txt is intentionally not made executable automatically and you should look over and test any rules it generates before relying on them. Be sure to read the script notes too!

Tested in Debian 10 only so far. More tc stuff will probably be added to this repo.

Known bugs

For some reason the u32 match filter in tc seems to have issues with odd number bytes to check for in nexthdr.

For example, a rule ending in nexthdr+35 will not work but nexthdr+36 will execute and actually match the specified packets.

If you generate a rule that won't work tc will simply output: Illegal "match"

Otherwise if you see no output the command was successful and will begin looking for matches.

tc-ingress's People

Contributors

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