-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Closed
Description
Brief description
From time to time sniff(session=TCPSession)
throws
...
File scapy/scapy/sessions.py:193, in StringBuffer.append(self, data, seq)
188 assert len(self.content) == self.content_len
189 # XXX removes empty space marker.
190 # for ifrag in self.incomplete:
191 # if [???]:
192 # self.incomplete.remove([???])
--> 193 memoryview(self.content)[seq:seq + data_len] = data
ValueError: memoryview assignment: lvalue and rvalue have different structures
(the full backtrace is in the "Actual result" section)
Scapy version
Python version
Python 3.11.3
Operating system
Linux version 6.3.7-100.fc37.x86_64
Additional environment information
No response
How to reproduce
I haven't figured out how to reproduce it reliably. Sorry!
It seems it happens only when session=TCPSession
is passed to sniff
and load_layer('tls')
is called before that somewhere. I'll try to capture packets triggering it and attach a pcap.
Actual result
ValueError Traceback (most recent call last)
Cell In[2], line 1
----> 1 sniff(store=False, prn=lambda p: repr(p), session=TCPSession)
File scapy/scapy/sendrecv.py:1311, in sniff(*args, **kwargs)
1307 @conf.commands.register
1308 def sniff(*args, **kwargs):
1309 # type: (*Any, **Any) -> PacketList
1310 sniffer = AsyncSniffer()
-> 1311 sniffer._run(*args, **kwargs)
1312 return cast(PacketList, sniffer.results)
File scapy/scapy/sendrecv.py:1254, in AsyncSniffer._run(self, count, store, offline, quiet, prn, lfilter, L2socket, timeout, opened_socket, stop_filter, iface, started_callback, session, session_kwargs, **karg)
1252 p.sniffed_on = sniff_sockets[s]
1253 # on_packet_received handles the prn/storage
-> 1254 session.on_packet_received(p)
1255 # check
1256 if (stop_filter and stop_filter(p)) or \
1257 (0 < count <= session.count):
File scapy/scapy/sessions.py:395, in TCPSession.on_packet_received(self, pkt)
393 return None
394 # Now handle TCP reassembly
--> 395 pkt = self._process_packet(pkt)
396 DefaultSession.on_packet_received(self, pkt)
File scapy/scapy/sessions.py:344, in TCPSession._process_packet(self, pkt)
341 seq = seq - relative_seq
342 # Add the data to the buffer
343 # Note that this take care of retransmission packets.
--> 344 data.append(new_data, seq)
345 # Check TCP FIN or TCP RESET
346 if pkt[TCP].flags.F or pkt[TCP].flags.R:
File scapy/scapy/sessions.py:193, in StringBuffer.append(self, data, seq)
188 assert len(self.content) == self.content_len
189 # XXX removes empty space marker.
190 # for ifrag in self.incomplete:
191 # if [???]:
192 # self.incomplete.remove([???])
--> 193 memoryview(self.content)[seq:seq + data_len] = data
ValueError: memoryview assignment: lvalue and rvalue have different structures
Expected result
sniff
shouldn't crash probably.
Related resources
No response
Metadata
Metadata
Assignees
Labels
No labels