-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Support (BPF) filter in sniff() with offline parameter set #394
Conversation
This works for me! Awesome work. Couldn't handle gzipped pcap, but then that seems tcpdump's limitation. |
).stdout | ||
) | ||
else: | ||
s = PcapReader(offline) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI. Indent level here seems wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch!
59f9674
to
2e1b7c0
Compare
Thanks for the tests and review @nyov! |
Looks perfect ! You could add the following unit tests to import tempfile
fd, filename = tempfile.mkstemp()
wrpcap(filename, Ether(dst="ff:ff:ff:ff:ff")/IP(dst=["1.2.3.4", "5.6.7.8"])/ICMP())
len(sniff(offline=filename, filter="host 5.6.7.8")) == 1 |
as suggested by Guillaume. Also, cleanup regression.uts since it was a pain to find a place to add those tests.
aa0c881
to
77ea31e
Compare
I'm performing some tests to see how you could do that... |
46cce99
to
7b7c3b7
Compare
@p-l-
between in appveyor.yml did the trick... But i'm not sure that it will work on Appveyor... |
For some reason that does not work. @gpotter2 have you been able to use I suspect |
be7974b
to
ed1f4ca
Compare
Investigation is in progress:
|
f26693e
to
9a1932c
Compare
So when I run the tests, the temporary file from which I read contains (base64 encoded here):
According to
But when, in AppVeyor, I run with subprocess |
cdbe101
to
4a5c51a
Compare
I have tried to add an
Maybe Windump is not correctly installed or needs something else? But in that case, wouldn't it produce at least an error? @gpotter2 if you don't mind, can you, using the base64 dump, reproduce the file on your environment and check if |
I've performed some tests on AppVeyor, and windump.exe does exists in the path... I guess we're getting it output badly... |
@gpotter2 I have no doubt it exists in the PATH, I have a clear error when it was not installed. I don't have access to a Windows machine for now, so if you can, can you do that test for me (see my previous comment) |
Sure |
@p-l- File created with linux:
and executed on windows with:
(I share files between linux and windows) |
@gpotter2 thanks a lot. That's weird. Can you try something else for me?
If that also works, the problem is probably that Windump is not correctly installed in AppVeyor (something is missing for example). |
Weirdly, i cannot manage to select the file... I will always have:
|
@gpotter2 can you try |
@p-l- Updated, sorry
|
@p-l- You might be right: Edit: Nah adding double \ doesn't work |
@gpotter2 I think you should double each |
If that's because of Windump install I might just skip Windows tests requiring Windump for now... |
@p-l- Well i've found a fix:
by
(removed It works... https://ci.appveyor.com/project/gpotter2/scapy SideNote: Please kill all of your build in travis... |
@gpotter2 Cool! What is it? |
@p-i- see my comment above. Edit: My bad p-i- 😢 |
Thanks @p-i- and sorry for the notification ;) |
4a5c51a
to
f412bcc
Compare
f412bcc
to
6382507
Compare
Thanks @gpotter2! AppVeyor tests are now OK (and I have canceled the other builds --- it takes a long time to start new MacOS tests on Travis-CI, queue "OSX for open source" has been full for 8 hours, and counting). |
Thanks for the unit tests ! They are really useful. I am glad to see that you find another way to install wpcap.dll. That's something that we might want to document. |
I'm afraid I can't understand it well,can you provide an example of using tcdump to filter captured packets? |
@nohadrweesh Please open a new issue if really needed, you should fix your sample as: Also, |
Fixes #393
Also, fixes #355
filter=
was not documented insniff()
(#355) because it is only passed to the socket. For the same reason, it was not supported withoffline=
, because no socket is used in that case.Since there is no way (apart from writing a BPF filter parser in Scapy) to filter a PCAP, this patch uses
tcpdump
.