-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Cleanup IP fragmentation, TCP session and TLS sessions #4082
Conversation
Codecov Report
@@ Coverage Diff @@
## master #4082 +/- ##
==========================================
- Coverage 81.93% 80.94% -1.00%
==========================================
Files 330 330
Lines 76212 76234 +22
==========================================
- Hits 62448 61710 -738
- Misses 13764 14524 +760
|
f948ab2
to
0afb386
Compare
This comment was marked as resolved.
This comment was marked as resolved.
Hi, Just ran another test with this pcap and from scapy.config import conf
from scapy.main import load_layer
from scapy.sendrecv import sniff
from scapy.sessions import TCPSession
conf.tls_session_enable=True
load_layer("tls")
capture = sniff(offline="test_2.pcap", session=TCPSession)
print("Done") Pyinstrument output: $ pyinstrument test.py -r text --show '*/scapy/*'
_ ._ __/__ _ _ _ _ _/_ Recorded: 11:34:08 Samples: 354062
/_//_/// /_\ / //_// / //_'/ // Duration: 361.988 CPU time: 360.251
/ _/ v4.5.1
Program: test.py
361.987 <module> test.py:1
└─ 359.257 sniff scapy/sendrecv.py:1307
└─ 359.257 AsyncSniffer._run scapy/sendrecv.py:1064
└─ 358.970 TCPSession.on_packet_received scapy/sessions.py:385
└─ 358.947 TCPSession._process_packet scapy/sessions.py:288
└─ 358.330 TLS.tcp_reassemble scapy/layers/tls/session.py:1124
└─ 353.972 [self] scapy/layers/tls/session.py |
Thanks for the report, I'll have a look. |
Hey @gpotter2, Sorry for bothering :-D found another issue when processing this pcap (using the same code from above): WARNING: No IPv4 address found on anpi2 !
WARNING: No IPv4 address found on anpi1 !
WARNING: more No IPv4 address found on anpi0 !
WARNING: Socket <scapy.utils.PcapNgReader object at 0x110de25d0> failed with 'PcapNgReader.recv() got an unexpected keyword argument 'stop_payload_dissection''. It was closed. Cheers |
Thanks. I'm currently rewriting the PR quite a bit. |
9eaff5a
to
0abdc03
Compare
@stulle123 this is fixed thanks. |
regarding the failing test, somehow the behavior of the
This changes make the test work again |
Thanks a lot !!! |
With this PR applied
from time to time. I'll try to collect packets triggering it and attach a pcap. |
Looks like it has nothing to do with this PR. It can be fixed with: diff --git a/scapy/layers/tls/record_sslv2.py b/scapy/layers/tls/record_sslv2.py
index 8d311faa..8e99a352 100644
--- a/scapy/layers/tls/record_sslv2.py
+++ b/scapy/layers/tls/record_sslv2.py
@@ -174,7 +174,7 @@ class SSLv2(TLS):
except KeyboardInterrupt:
raise
except Exception:
- if conf.debug_dissect:
+ if conf.debug_dissector:
raise
p = conf.raw_layer(s, _internal=1, _underlayer=self)
self.add_payload(p) |
Still waiting for more reviews ! Note: this PR should be squashed on merge. |
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.
I don't have enough time for now to do a comprehensive review but overall LGTM, great work!
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.
LGTM I will try to test the code further.
2793f0a
to
0af0f6a
Compare
Sessions
: replaceon_received_packet
by two functions:recv
that is an iterator andprocess
. This makes a cleaner separation, and re-puts the storing/prn/etc; back intosniff
(where it should have been left)TCPSession
:stop_payload_dissection
attribute, which allows the caller to say "Don't parse above TCP". This required changing the layout ofrecv()
in SuperSocket to allow for extra arguments.sniff
seems to crash with "ValueError: memoryview assignment: lvalue and rvalue have different structures" occasionally #4030)fragment()
functionsrepr()
not showing the correct direction in tls sessionsTLSSession
(literally brings nothing. Just useTCPSession
withconf.tls_session_enable=True
). This is now also fixed thanks to the above fix.compute_ms_and_derive_keys
even if nopre_master_secret_key
was computed (i.e. we don't have any private key). This is now fixed, the function is only called whenever thepre_master_secret_key
has been computed.fixes #4030
fixes #3722
closes #3966
closes #3970