Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

module 'paramiko.pkey' has no attribute 'load_private_key_file' #273

Open
Randark-JMT opened this issue Oct 5, 2023 · 2 comments
Open
Labels
bug Something isn't working

Comments

@Randark-JMT
Copy link

Randark-JMT commented Oct 5, 2023

Bug Description

When I try to log into ssh with my private key, the following error occurs

AttributeError: module 'paramiko.pkey' has no attribute 'load_private_key_file'

pwncat version

Provide the output of pwncat --version or a commit hash if working from
a development branch.

$pwncat-cs --version
0.5.4

Target System (aka "victim")

Linux Hackthebox Clicker

Steps to Reproduce

└──╼ $pwncat-cs 
[12:34:56] Welcome to pwncat 🐈!                                                                                                                                                                                            __main__.py:164
(local) pwncat$ connect -i id_rsa
[12:35:01] connection failed: no port specified                                                                                                                                                                              manager.py:957
(local) pwncat$ connect -i id_rsa jack@10.10.11.232
╭─────────────────────────────────────────────────────────────────────────────────────────────────── Traceback (most recent call last) ───────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                                                                                                                         │
│ /usr/local/lib/python3.9/dist-packages/pwncat/commands/__init__.py:591 in run                                                                                                                                                           │
│                                                                                                                                                                                                                                         │
│    588 │   │   │   │   if line == "":                                                                                                                                                                                                   │
│    589 │   │   │   │   │   continue                                                                                                                                                                                                     │
│    590 │   │   │   │                                                                                                                                                                                                                    │
│ ❱  591 │   │   │   │   self.dispatch_line(line)                                                                                                                                                                                         │
│    592 │   │   │   # We used to catch only KeyboardException, but this prevents a                                                                                                                                                       │
│    593 │   │   │   # badly written command from completely killing our remote                                                                                                                                                           │
│    594 │   │   │   # connection.                                                                                                                                                                                                        │
│ /usr/local/lib/python3.9/dist-packages/pwncat/commands/__init__.py:672 in dispatch_line                                                                                                                                                 │
│                                                                                                                                                                                                                                         │
│    669 │   │   │   │   args = line                                                                                                                                                                                                      │
│    670 │   │   │                                                                                                                                                                                                                        │
│    671 │   │   │   # Run the command                                                                                                                                                                                                    │
│ ❱  672 │   │   │   command.run(self.manager, args)                                                                                                                                                                                      │
│    673 │   │   │                                                                                                                                                                                                                        │
│    674 │   │   │   if prog_name:                                                                                                                                                                                                        │
│    675 │   │   │   │   command.parser.prog = prog_name                                                                                                                                                                                  │
│                                                                                                                                                                                                                                         │
│ /usr/local/lib/python3.9/dist-packages/pwncat/commands/connect.py:295 in run                                                                                                                                                            │
│                                                                                                                                                                                                                                         │
│   292 │   │   │   manager.target.log(f"connected via {used_implant.title(manager.target)}")                                                                                                                                             │
│   293 │   │   else:                                                                                                                                                                                                                     │
│   294 │   │   │   try:                                                                                                                                                                                                                  │
│ ❱ 295 │   │   │   │   manager.create_session(**query_args)                                                                                                                                                                              │
│   296 │   │   │   except (ChannelError, PlatformError) as exc:                                                                                                                                                                          │
│   297 │   │   │   │   manager.log(f"connection failed: {exc}")                                                                                                                                                                          │
│   298 │   │   │   except KeyboardInterrupt:                                                                                                                                                                                             │
│                                                                                                                                                                                                                                         │
│ /usr/local/lib/python3.9/dist-packages/pwncat/manager.py:1192 in create_session                                                                                                                                                         │
│                                                                                                                                                                                                                                         │
│   1189 │   │   │   PlatformError: construction of a platform around the channel failed                                                                                                                                                  │
│   1190 │   │   """                                                                                                                                                                                                                      │
│   1191 │   │                                                                                                                                                                                                                            │
│ ❱ 1192 │   │   session = Session(self, platform, channel, **kwargs)                                                                                                                                                                     │
│   1193 │   │                                                                                                                                                                                                                            │
│   1194 │   │   # Increment the ``session_id`` variable upon adding a new session                                                                                                                                                        │
│   1195 │   │   # Session constructor will automatically grab the current                                                                                                                                                                │
│                                                                                                                                                                                                                                         │
│ /usr/local/lib/python3.9/dist-packages/pwncat/manager.py:518 in __init__                                                                                                                                                                │
│                                                                                                                                                                                                                                         │
│    515 │   │   else:                                                                                                                                                                                                                    │
│    516 │   │   │   # If necessary, build a new channel                                                                                                                                                                                  │
│    517 │   │   │   if channel is None:                                                                                                                                                                                                  │
│ ❱  518 │   │   │   │   channel = pwncat.channel.create(**kwargs)                                                                                                                                                                        │
│    519 │   │   │                                                                                                                                                                                                                        │
│    520 │   │   │   # This makes logging work during the constructor                                                                                                                                                                     │
│    521 │   │   │   self.platform = str(channel)                                                                                                                                                                                         │
│                                                                                                                                                                                                                                         │
│ /usr/local/lib/python3.9/dist-packages/pwncat/channel/__init__.py:602 in create                                                                                                                                                         │
│                                                                                                                                                                                                                                         │
│   599 │                                                                                                                                                                                                                                 │
│   600 │   for prot in protocols:                                                                                                                                                                                                        │
│   601 │   │   try:                                                                                                                                                                                                                      │
│ ❱ 602 │   │   │   channel = find(prot)(**kwargs)                                                                                                                                                                                        │
│   603 │   │   │   return channel                                                                                                                                                                                                        │
│   604 │   │   except ChannelError:                                                                                                                                                                                                      │
│   605 │   │   │   if len(protocols) == 1 or prot != "reconnect":                                                                                                                                                                        │
│                                                                                                                                                                                                                                         │
│ /usr/local/lib/python3.9/dist-packages/pwncat/channel/ssh.py:57 in __init__                                                                                                                                                             │
│                                                                                                                                                                                                                                         │
│    54 │   │   │   │   port=port,                                                                                                                                                                                                        │
│    55 │   │   │   │   username=user,                                                                                                                                                                                                    │
│    56 │   │   │   │   password=password,                                                                                                                                                                                                │
│ ❱  57 │   │   │   │   pkey=load_private_key(identity),                                                                                                                                                                                  │
│    58 │   │   │   │   allow_agent=True,                                                                                                                                                                                                 │
│    59 │   │   │   │   look_for_keys=False,                                                                                                                                                                                              │
│    60 │   │   │   )                                                                                                                                                                                                                     │
│                                                                                                                                                                                                                                         │
│ /usr/local/lib/python3.9/dist-packages/pwncat/channel/ssh.py:132 in load_private_key                                                                                                                                                    │
│                                                                                                                                                                                                                                         │
│   129 │                                                                                                                                                                                                                                 │
│   130 │   try:                                                                                                                                                                                                                          │
│   131 │   │   if isinstance(identity, str):                                                                                                                                                                                             │
│ ❱ 132 │   │   │   return paramiko.pkey.load_private_key_file(                                                                                                                                                                           │
│   133 │   │   │   │   os.path.expanduser(identity), password=passphrase                                                                                                                                                                 │
│   134 │   │   │   )                                                                                                                                                                                                                     │
│   135                                                                                                                                                                                                                                   │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
AttributeError: module 'paramiko.pkey' has no attribute 'load_private_key_file'

Expected Behavior

pwncat should accept the private key and establish an ssh session

Screenshots

图片
图片

@Randark-JMT Randark-JMT added the bug Something isn't working label Oct 5, 2023
@cpu0x00
Copy link

cpu0x00 commented Dec 12, 2023

getting the same error

@cpu0x00
Copy link

cpu0x00 commented Dec 12, 2023

was able to solve it by changing line 57 in /usr/local/lib/python3.11/dist-packages/pwncat/channel/ssh.py removing the "pkey" option and replacing with key_filename however i hardcoded my key location, but i guess a simple edit could be made to get dynamically using the identity cli argument

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants