scapy icon indicating copy to clipboard operation
scapy copied to clipboard

PicklingError when saving a session

Open StragaSevera opened this issue 2 years ago • 0 comments

Brief description

Whenever I try to save a session (either via exiting from scapy started with -s flag, or by using save_session function), I receive error: PicklingError: Can't pickle <function open at 0x7212fd7be680>: it's not the same object as io.open.

Scapy version

2.5.0 (both with pip version and with 277f3 commit)

Python version

3.10

Operating system

Arch Linux

Additional environment information

No response

How to reproduce

Either:

  1. Start a shell without -s flag.
  2. Type: save_session("01")

Or:

  1. Start a shell with -s 01 flag.
  2. Type exit()

Actual result

In first case, the log is:

sudo -E scapy -H
Welcome to Scapy (2.5.0.dev230) using IPython 8.21.0
>>> save_session("01")
INFO: Saving session into [01]
---------------------------------------------------------------------------
PicklingError                             Traceback (most recent call last)
Cell In[1], line 1
----> 1 save_session("01")

File ~/.asdf/installs/python/3.10.13/lib/python3.10/site-packages/scapy/main.py:425, in save_session(fname, session, pickleProto)
    422     pass
    424 f = gzip.open(fname, "wb")
--> 425 pickle.dump(to_be_saved, f, pickleProto)
    426 f.close()

PicklingError: Can't pickle <function open at 0x7ea2845b6680>: it's not the same object as io.open
>>>        

In second case, the log is:

sudo -E scapy -H -s 01
Welcome to Scapy (2.5.0.dev230) using IPython 8.21.0
>>> %config Application.verbose_crash=True
>>> exit
INFO: Saving session into [01]
Error in sys.excepthook:
Traceback (most recent call last):
  File "/home/ought/.asdf/installs/python/3.10.13/lib/python3.10/pathlib.py", line 1305, in is_dir
    return S_ISDIR(self.stat().st_mode)
AttributeError: 'str' object has no attribute 'stat'

Original exception was:
Traceback (most recent call last):
  File "/home/ought/.asdf/installs/python/3.10.13/bin/scapy", line 8, in <module>
    sys.exit(interact())
  File "/home/ought/.asdf/installs/python/3.10.13/lib/python3.10/site-packages/scapy/main.py", line 933, in interact
    save_session(conf.session, SESSION)
  File "/home/ought/.asdf/installs/python/3.10.13/lib/python3.10/site-packages/scapy/main.py", line 425, in save_session
    pickle.dump(to_be_saved, f, pickleProto)
_pickle.PicklingError: Can't pickle <function open at 0x79c2b3f42680>: it's not the same object as io.open

Expected result

No response

Related resources

No response

StragaSevera avatar Feb 01 '24 08:02 StragaSevera