`follow_tcp_stream` (and flow tracing in general) doesn't work
tobyxdd opened this issue · comments
Toby commented
Describe the bug
def main():
try:
streams = follow_tcp_stream(fin="test.pcap")
except Exception as e:
traceback.print_exc()
return
Traceback (most recent call last):
File "c:\Users\tobyx\Desktop\prox\main.py", line 51, in main
streams = follow_tcp_stream(fin="test.pcap")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\tobyx\Desktop\prox\venv\Lib\site-packages\pcapkit\interface\misc.py", line 80, in follow_tcp_stream
extraction = Extractor(fin=fin, fout=None, format=None, auto=True, extension=extension,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\tobyx\Desktop\prox\venv\Lib\site-packages\pcapkit\foundation\extraction.py", line 812, in __init__
self.run() # start extraction
^^^^^^^^^^
File "C:\Users\tobyx\Desktop\prox\venv\Lib\site-packages\pcapkit\foundation\extraction.py", line 448, in run
self.record_frames()
File "C:\Users\tobyx\Desktop\prox\venv\Lib\site-packages\pcapkit\foundation\extraction.py", line 599, in record_frames
self._exeng.read_frame()
File "C:\Users\tobyx\Desktop\prox\venv\Lib\site-packages\pcapkit\foundation\engines\pcap.py", line 175, in read_frame
ext._trace.tcp(data_tf_tcp)
File "C:\Users\tobyx\Desktop\prox\venv\Lib\site-packages\pcapkit\foundation\traceflow\traceflow.py", line 336, in __call__
self.dump(packet)
File "C:\Users\tobyx\Desktop\prox\venv\Lib\site-packages\pcapkit\foundation\traceflow\tcp.py", line 59, in dump
output = self.trace(packet, output=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\tobyx\Desktop\prox\venv\Lib\site-packages\pcapkit\foundation\traceflow\tcp.py", line 112, in trace
fpout=self._foutio(fname=f'{self._fproot}/{label}{self._fdpext or ""}', protocol=packet.protocol,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\tobyx\Desktop\prox\venv\Lib\site-packages\pcapkit\dumpkit\pcap.py", line 70, in __init__
super().__init__(fname, protocol=protocol, byteorder=byteorder, nanosecond=nanosecond, **kwargs)
File "C:\Users\tobyx\Desktop\prox\venv\Lib\site-packages\dictdumper\dumper.py", line 168, in __init__
self._dump_header(**kwargs) # initialise output file
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\tobyx\Desktop\prox\venv\Lib\site-packages\pcapkit\dumpkit\pcap.py", line 103, in _dump_header
packet = Header(
^^^^^^^
File "C:\Users\tobyx\Desktop\prox\venv\Lib\site-packages\pcapkit\protocols\protocol.py", line 520, in __init__
self.__post_init__(file, length, **kwargs) # type: ignore[arg-type]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\tobyx\Desktop\prox\venv\Lib\site-packages\pcapkit\protocols\misc\pcap\header.py", line 261, in __post_init__
_data = self.pack(**kwargs)
^^^^^^^^^^^^^^^^^^^
File "C:\Users\tobyx\Desktop\prox\venv\Lib\site-packages\pcapkit\protocols\protocol.py", line 259, in pack
return self.__header__.pack(packet)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\tobyx\Desktop\prox\venv\Lib\site-packages\pcapkit\protocols\schema\schema.py", line 544, in pack
temp = field.pack(value, packet)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\tobyx\Desktop\prox\venv\Lib\site-packages\pcapkit\corekit\fields\field.py", line 185, in pack
return struct.pack(self.template, pre_processed)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
struct.error: argument for 's' must be a bytes object
System information
A clear and concise description of your system information.
- OS Version: Windows 11
- Python Version: 3.11.6 (tried 3.9, same)
- Python Implementation: CPython
Traceback stack
Already did
Expected behavior
Doesn't crash and performs as expected.
Additional context
N/A
Jarry Shaw commented
Could you please provide the test.pcap
file that you're using?