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

ssh: Allow passing disabled_algorithms keyword argument from ssh to paramiko #2546

Merged
merged 4 commits into from
Mar 1, 2025
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 @@ -85,6 +85,7 @@ The table below shows which release corresponds to each branch, and what date th
- [#2529][2529] Add LoongArch64 support
- [#2506][2506] ROP: fix `ROP(ELF(exe)).leave` is `None` in some ELF
- [#2504][2504] doc: add example case for `tuple` (host, port pair) in `gdb.attach`
- [#2546][2546] ssh: Allow passing disabled_algorithms keyword argument from ssh to paramiko

[2519]: https://github.com/Gallopsled/pwntools/pull/2519
[2507]: https://github.com/Gallopsled/pwntools/pull/2507
Expand All @@ -97,6 +98,7 @@ The table below shows which release corresponds to each branch, and what date th
[2529]: https://github.com/Gallopsled/pwntools/pull/2529
[2506]: https://github.com/Gallopsled/pwntools/pull/2506
[2504]: https://github.com/Gallopsled/pwntools/pull/2504
[2546]: https://github.com/Gallopsled/pwntools/pull/2546

## 4.15.0 (`beta`)

Expand Down
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ def __setattr__(self, name, value):
]

intersphinx_mapping = {'python': ('https://docs.python.org/3/', None),
'paramiko': ('https://docs.paramiko.org/en/2.1/', None)}
'paramiko': ('https://docs.paramiko.org/en/stable/', None)}
Copy link
Contributor Author

@Ninja3047 Ninja3047 Mar 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just noticed that the docs were for some reason locked to a very old version of paramiko which did not have the disabled_algorithms keyword argument. Since pwntools doesn't have any particular upper bound version for paramiko, I think it would make more sense if this was linked to stable since that will be what is most likely used? Alternatively, the lowest version of paramiko that does contain the disable_algorithms keyword arg is 2.6


# The name of an image file (relative to this directory) to place at the top of
# the title page.
Expand Down
7 changes: 5 additions & 2 deletions pwnlib/tubes/ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ 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,
auth_none=False, *a, **kw):
auth_none=False, disabled_algorithms=None, *a, **kw):
"""Creates a new ssh connection.

Arguments:
Expand All @@ -593,6 +593,9 @@ def __init__(self, user=None, host=None, port=22, password=None, key=None,
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
disabled_algorithms(dict):
Mapping of algorithm type and list of algorithm identifiers to disable.
See :class:`paramiko.transport.Transport` for more information.

NOTE: The proxy_command and proxy_sock arguments is only available if a
fairly new version of paramiko is used.
Expand Down Expand Up @@ -682,7 +685,7 @@ def __init__(self, user=None, host=None, port=22, password=None, key=None,
proxy_sock = None

try:
self.client.connect(host, port, user, password, key, keyfiles, self.timeout, allow_agent=ssh_agent, compress=True, sock=proxy_sock, look_for_keys=not ignore_config)
self.client.connect(host, port, user, password, key, keyfiles, self.timeout, allow_agent=ssh_agent, compress=True, sock=proxy_sock, look_for_keys=not ignore_config, disabled_algorithms=disabled_algorithms)
except paramiko.BadHostKeyException as e:
self.error("Remote host %(host)s is using a different key than stated in known_hosts\n"
" To remove the existing entry from your known_hosts and trust the new key, run the following commands:\n"
Expand Down
Loading