wapiflapi / binexpect

A python module that monkey patches pexpect mainly for binary transfers.
18 stars 4 forks source link

Pexpect update: AttributeError: type object 'spawn' has no attribute 'crlf' #1

Open entropyqueen opened 8 years ago

entropyqueen commented 8 years ago

Since last pexpect update, I am having a traceback with binexpect

Traceback (most recent call last):
  File "sploit.py", line 19, in <module>
    target.prompt()
  File "/usr/lib/python3.5/binexpect.py", line 200, in prompt
    if binmixin: self.setnlcr()
  File "/usr/lib/python3.5/binexpect.py", line 143, in setnlcr
    mode[TLIST.OFLAG] = mode[TLIST.OFLAG] | termios.ONLCR
  File "/usr/lib/python3.5/contextlib.py", line 66, in __exit__
    next(self.gen)
  File "/usr/lib/python3.5/binexpect.py", line 127, in changemode
    self.setmode(fd, when, mode)
  File "/usr/lib/python3.5/binexpect.py", line 101, in setmode
    self.crlf = pexpect.spawn.crlf
AttributeError: type object 'spawn' has no attribute 'crlf'

My python version is 3.5 And I'm using the latest version of pexpect, which is the 4.0.1

Also, I checked the sources of pexpect version 4.0.1, the spawn class you are using inherits from SpawnBase, which does have a 'crlf' attribute. The 'crlf' attribute is set in SpawnBase's constructor, which is call by spawn using super().

Basically, we just need to instanciate the pexpect.spawn class. That being said, I don't know what command should be given to pexpect in order to make that work properly.

wapiflapi commented 5 years ago

FTR this is probably the commits upstream that introduced this behavior. https://github.com/jeberger/pexpect/commit/ce1e181b4c6fbb88678bfa7da45b8a3da328ba2b

I'm pretty sure we could just drop the monkey patching now that this is "fixed" upstream. We'll only really loose the ability to set it to something different than the default for the OS which shouldn't be done this way anyhow.