pwntools icon indicating copy to clipboard operation
pwntools copied to clipboard

Interactive SSH takes gigabytes of RAM

Open meithecatte opened this issue 6 years ago • 4 comments

I'm using the dev3 branch, and while it mostly works fine, I've tried connecting to an ssh server and calling interactive():

from pwn import *
s = ssh(host='bandit.labs.overthewire.org', port=2220, user='bandit0', password='bandit0')
s.interactive()

When I run this script and issue ls -la, about 70% of the time, the output of the command will not be shown, and then the python process starts allocating a lot of memory. The worst time so far, top was showing 2.7g in the RES column, which made my entire computer thrash for 15 minutes.

While I suspected that it might be related to the formatting used by ls, using ls -la | cat or export TERM=dumb does not change the outcome.

Sometimes the first time you run the command, everything works as expected, but then it still starts eating gigabytes when you repeat the experiment on the same connection and channel, without restarting the script.

Issuing commands with the script directly does not seem to be affected.

meithecatte avatar Apr 11 '19 11:04 meithecatte

Does this happen on the current Python2 stable branch?

zachriggle avatar Apr 11 '19 22:04 zachriggle

The issue does not seem to be reproducible on either the stable or dev branch, only dev3 is affected. While testing, I noticed a curious difference -- the shell prompt is not shown on dev3, while it shows up normally on the other two branches.

meithecatte avatar Apr 12 '19 15:04 meithecatte

You mean the interactive shell works, but the “$ “ prompt is missing?

zachriggle avatar Apr 12 '19 19:04 zachriggle

Yes, the $ is missing on dev3, which is weird but the docs suggest it might be intended?

meithecatte avatar Apr 12 '19 21:04 meithecatte