calebstewart / pwncat

Fancy reverse and bind shell handler
https://pwncat.readthedocs.io
MIT License
2.63k stars 258 forks source link

Unable to connect via SSH #37

Closed EtienneBruines closed 4 years ago

EtienneBruines commented 4 years ago

I honestly have no idea what's wrong. :see_no_evil:

(In the context of https://tryhackme.com/room/wonderland )

Connecting manually using ssh:

➜   ssh alice@$IP
alice@10.10.235.243's password: 
Welcome to Ubuntu 18.04.4 LTS (GNU/Linux 4.15.0-101-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

  System information as of Sun Jul 19 20:53:24 UTC 2020

  System load:  0.0                Processes:           87
  Usage of /:   18.9% of 19.56GB   Users logged in:     0
  Memory usage: 32%                IP address for eth0: 10.10.235.243
  Swap usage:   0%

0 packages can be updated.
0 updates are security updates.

Failed to connect to https://changelogs.ubuntu.com/meta-release-lts. Check your Internet connection or proxy settings

Last login: Sun Jul 19 20:53:15 2020 from 10.8.37.1
alice@wonderland:~$  # success

Connecting using pwncat:

➜   pwncat --ssh --user alice --host $IP --password "enter-pretty-password-here"
Traceback (most recent call last):
  File "/home/ebruines/.local/bin/pwncat", line 33, in <module>
    sys.exit(load_entry_point('pwncat==0.3.1', 'console_scripts', 'pwncat')())
  File "/home/ebruines/.local/lib/python3.8/site-packages/pwncat/__main__.py", line 28, in main
    pwncat.victim.command_parser.dispatch_line(
  File "/home/ebruines/.local/lib/python3.8/site-packages/pwncat/commands/__init__.py", line 290, in dispatch_line
    command.run(args)
  File "/home/ebruines/.local/lib/python3.8/site-packages/pwncat/commands/connect.py", line 229, in run
    pwncat.victim.connect(chan)
  File "/home/ebruines/.local/lib/python3.8/site-packages/pwncat/remote/victim.py", line 279, in connect
    hostname_path = self.run("which hostname").strip().decode("utf-8")
  File "/home/ebruines/.local/lib/python3.8/site-packages/pwncat/remote/victim.py", line 1035, in run
    sdelim, edelim = self.process(cmd, delim=wait, timeout=timeout)
  File "/home/ebruines/.local/lib/python3.8/site-packages/pwncat/remote/victim.py", line 1089, in process
    data = self.client.recv(len(command), socket.MSG_PEEK)
TypeError: recv() takes 2 positional arguments but 3 were given
calebstewart commented 4 years ago

You need to install the fork of paramiko mentioned in requirements.txt and setup.py installed. If you install in a virtual environment, it will work just fine. 👍

EtienneBruines commented 4 years ago

Thank you for your quick reply.

Is that something that should have been automated by the pip install command? (i.e. shouldn't that already resolve dependencies?)

calebstewart commented 4 years ago

You likely already had paramiko installed, so the dependency is "satisfied" in that paramiko is installed. The problem is that the referenced dependency is a fork of paramiko with a small modification. I've submitted a PR for these changes, but they haven't been merged yet. Installing in a virtualenv ensures that any prior-installed packages don't get in the way.