Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VLAN Wrapper Not Applied to Pcapy Reader #123

Open
amm3 opened this issue Oct 6, 2020 · 2 comments
Open

VLAN Wrapper Not Applied to Pcapy Reader #123

amm3 opened this issue Oct 6, 2020 · 2 comments

Comments

@amm3
Copy link
Contributor

amm3 commented Oct 6, 2020

The only invocation of setfilter() on the capture device (pcapy.Reader class) is based on the initial_bpf from the first plugin on the chain.

Because of this, any efforts to expand the filter are moot. Narrowing of the filter seems effective through manipulating compiled bpf filters on the plugin objects, but only the packets pulled from the wire or file (governed by the pcapy.Reader filter) are ever passed to the feed_plugin_chain function.

It seems we may need a mechanism to update the Reader filter when bpf filters are changed in the plugin chain. But this is not trivial, because recompiling bpf happens in the plugin object and the instantiated Reader appears only in decode.py.

I initially noticed this because the automatic vlan wrapper wasn't working with any plugin on vlan tagged PCAP files, but it has potential effects also in chained plugins and plugins that dynamically alter their bpf filters.

@jpsnyder
Copy link

From my understanding plugins further down the chain only receive packets that the earlier plugins have not filtered out. This is by design. They are layered.

That's why only the initial bpf filter gets set on the pcapy.Reader. All other bpf filters are manually applied to the packets passed down the chain: https://github.com/USArmyResearchLab/Dshell/blob/master/dshell/core.py#L385

To get what your describing, dshell would need to able to support parallel plugin chains. Although, it would probably be simpler to just do multiple runs of dshell if you are just processing pcap files.

@dev195
Copy link
Contributor

dev195 commented Mar 16, 2022

Much of the reason we have not responded to this issue is because we do not know of a quick way to fix it, or if such a fix is desirable. @amm3 is correct that plugins on the chain cannot expand the filter of what enters the chain.

If, for example, Plugin B decides it needs packets from an ephemeral port, it has no way of telling Plugin A to expand its filter. However, it might not be possible to expand Plugin A's filter, if it was written to expect a static filter.

If anybody has suggestions, we would be happy to hear them!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants