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

follow_tcp_stream (and flow tracing in general) doesn't work #180

Open
tobyxdd opened this issue Dec 11, 2023 · 1 comment
Open

follow_tcp_stream (and flow tracing in general) doesn't work #180

tobyxdd opened this issue Dec 11, 2023 · 1 comment

Comments

@tobyxdd
Copy link

tobyxdd commented Dec 11, 2023

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

@JarryShaw
Copy link
Owner

Could you please provide the test.pcap file that you're using?

JarryShaw added a commit that referenced this issue Mar 12, 2024
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

2 participants