binexpect
binexpect copied to clipboard
Exception with --gdb option AttributeError: 'ttyspawn' object has no attribute 'setecho'
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
--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?
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.