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

Add "none" ssh authentication method #2405

Merged
merged 3 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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