Search code examples
wiresharkscapy

Scapy rdpcap function error "MemoryError"


I want to use rdpcap to open a traffic capture.

cap = rdpcap("Chall_1.pcapng")

but i receive the following error and I don't know how to solve it.

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/scapy/utils.py", line 979, in __call__
    i.__init__(filename, fdesc, magic)
  File "/usr/lib/python3/dist-packages/scapy/utils.py", line 1124, in __init__
    RawPcapReader.__init__(self, filename, fdesc, magic)
  File "/usr/lib/python3/dist-packages/scapy/utils.py", line 1035, in __init__
    raise Scapy_Exception(
scapy.error.Scapy_Exception: Not a pcap capture file (bad magic: b'\n\r\r\n')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/valentin/Desktop/Tema3/ctf1.py", line 29, in <module>
    cap = rdpcap("Chall_1.pcapng")
  File "/usr/lib/python3/dist-packages/scapy/utils.py", line 950, in rdpcap
    with PcapReader(filename) as fdesc:
  File "/usr/lib/python3/dist-packages/scapy/utils.py", line 985, in __call__
    i.__init__(filename, fdesc, magic)
  File "/usr/lib/python3/dist-packages/scapy/utils.py", line 1320, in __init__
    RawPcapNgReader.__init__(self, filename, fdesc, magic)
  File "/usr/lib/python3/dist-packages/scapy/utils.py", line 1209, in __init__
    self.f.read(blocklen - 24)
MemoryError

Solution

  • The problem was that I didn't have enoght RAM on my virtual machine.