Skip to content

Commit

Permalink
Add "none" ssh authentication method (#2405)
Browse files Browse the repository at this point in the history
* Add "none" ssh authentication method

Allow to "disable" ssh authentication if the remote server has it enabled.

Fixes #2380

* Add CHANGELOG
  • Loading branch information
peace-maker committed Jun 17, 2024
1 parent d5fffb6 commit 4dc8d60
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ The table below shows which release corresponds to each branch, and what date th
- [#2387][2387] Convert apport_corefile() output from bytes-like object to string
- [#2388][2388] libcdb: add `offline_only` to `search_by_symbol_offsets`
- [#2415][2415] Add shellcraft template for IPv6 socket
- [#2405][2405] Add "none" ssh authentication method

[2360]: https://github.com/Gallopsled/pwntools/pull/2360
[2356]: https://github.com/Gallopsled/pwntools/pull/2356
Expand All @@ -97,6 +98,7 @@ The table below shows which release corresponds to each branch, and what date th
[2387]: https://github.com/Gallopsled/pwntools/pull/2387
[2388]: https://github.com/Gallopsled/pwntools/pull/2388
[2415]: https://github.com/Gallopsled/pwntools/pull/2415
[2405]: https://github.com/Gallopsled/pwntools/pull/2405

## 4.13.0 (`beta`)

Expand Down
17 changes: 12 additions & 5 deletions pwnlib/tubes/ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,8 @@ class ssh(Timeout, Logger):

def __init__(self, user=None, host=None, port=22, password=None, key=None,
keyfile=None, proxy_command=None, proxy_sock=None, level=None,
cache=True, ssh_agent=False, ignore_config=False, raw=False, *a, **kw):
cache=True, ssh_agent=False, ignore_config=False, raw=False,
auth_none=False, *a, **kw):
"""Creates a new ssh connection.
Arguments:
Expand All @@ -587,10 +588,11 @@ def __init__(self, user=None, host=None, port=22, password=None, key=None,
proxy_sock(str): Use this socket instead of connecting to the host.
timeout: Timeout, in seconds
level: Log level
cache: Cache downloaded files (by hash/size/timestamp)
ssh_agent: If :const:`True`, enable usage of keys via ssh-agent
ignore_config: If :const:`True`, disable usage of ~/.ssh/config and ~/.ssh/authorized_keys
raw: If :const:`True`, assume a non-standard shell and don't probe the environment
cache(bool): Cache downloaded files (by hash/size/timestamp)
ssh_agent(bool): If :const:`True`, enable usage of keys via ssh-agent
ignore_config(bool): If :const:`True`, disable usage of ~/.ssh/config and ~/.ssh/authorized_keys
raw(bool): If :const:`True`, assume a non-standard shell and don't probe the environment
auth_none(bool): If :const:`True`, try to authenticate with no authentication methods
NOTE: The proxy_command and proxy_sock arguments is only available if a
fairly new version of paramiko is used.
Expand Down Expand Up @@ -686,6 +688,11 @@ def __init__(self, user=None, host=None, port=22, password=None, key=None,
" To remove the existing entry from your known_hosts and trust the new key, run the following commands:\n"
" $ ssh-keygen -R %(host)s\n"
" $ ssh-keygen -R [%(host)s]:%(port)s" % locals())
except paramiko.SSHException as e:
if user and auth_none and str(e) == "No authentication methods available":
self.client.get_transport().auth_none(user)
else:
raise

self.transport = self.client.get_transport()
self.transport.use_compression(True)
Expand Down

0 comments on commit 4dc8d60

Please sign in to comment.