wapiflapi / binexpect

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

Exception with --gdb option AttributeError: 'ttyspawn' object has no attribute 'setecho' #2

Open entropyqueen opened 5 years ago

entropyqueen commented 5 years ago

When using --gdb option with pexpect v4.6.0 (latest to this date) and after craftily patching #1 I got this crash

[ark@underworld] sploit master*$ python sploit4.py  --gdb
New tty spawned at /dev/pts/5
Traceback (most recent call last):
  File "sploit4.py", line 10, in <module>
    target.setecho(False)
AttributeError: 'ttyspawn' object has no attribute 'setecho'

python version is 3.7.2

wapiflapi commented 5 years ago

--gdb implies the creation of a TTY.

When setting up our own TTY we use fdpexpect and pass it our file descriptor. Basically what happened is that upstream dropped support for setecho in fdpexpect which makes sense (no echo on fd anyway). I think when there was support for this it wasn't well defined and probably didn't do anything.

Because in binexpect we like switching between tty / no tty through command line options such as --gdb it's easier to just mock setecho() as a no-op in ttyspawn. I did that in https://github.com/wapiflapi/binexpect/commit/33f37be67c0d34689584fe8d0c93469ea4945543 and added a warning when trying to set echo to false.

What do you think about this?

entropyqueen commented 5 years ago

So yeah it is not a problem for setecho, however many other functions have been removed from fdspawn class, thus leading to other similar issues, the current one I'm having is with sendeof, which I think we can not just mock.

[EDIT] also, we'll have to deal with interact() which have been removed from this class too.