FFFF
Skip to content

Add ssh -L / ssh.connect_remote() workaround when AllowTcpForwarding is disabled#2538

Merged
peace-maker merged 5 commits intoGallopsled:devfrom
peace-maker:ssh_connector_netcat
Mar 30, 2025
Merged

Add ssh -L / ssh.connect_remote() workaround when AllowTcpForwarding is disabled#2538
peace-maker merged 5 commits intoGallopsled:devfrom
peace-maker:ssh_connector_netcat

Conversation

@peace-maker
Copy link
Copy Markdown
Member
@peace-maker peace-maker commented Jan 30, 2025

Use a netcat process on the remote to connect to the specified host:port and tunnel the traffic using normal ssh.process I/O.

This was inspired by the "Circumventing Disabled SSH Port-Forwarding with a Multiplexer" article by @guysv in the Paged Out! zine no. 5.

from pwn import *
io_ssh = ssh('hacker', 'pwn.college', keyfile=os.path.expanduser('~/.ssh/id_ed25519'), raw=True)
io = gdb.debug('/challenge/some_challenge', ssh=io_ssh)
io.interactive()

Debugging works now instead of throwing a paramiko.ssh_exception.ChannelException: ChannelException(1, 'Administratively prohibited') exception on pwn.college.

@peace-maker peace-maker force-pushed the ssh_connector_netcat branch 2 times, most recently from dc0ec3c to 1323dc5 Compare January 30, 2025 10:53
…ding` is disabled

Use a netcat process on the remote to connect to the specified host:port and tunnel the traffic using normal `ssh.process` I/O.

This was inspired by the "Circumventing Disabled SSH Port-Forwarding with a Multiplexer" article by @guysv in the Paged Out! zine no. 5.

It allows to use `gdb.debug(arg, ssh=ssh)` to debug processes on pwn.college.
Co-authored-by: Xeonacid <h.dwwwwww@gmail.com>
if parent.which('nc'):
ncat = 'nc'
elif parent.which('ncat'):
ncat = 'ncat'
8000 Copy link
Copy Markdown

Choose a reason for hiding this comment

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

maybe add a fallback to bash's /dev/tcp? might be worth checking out.

Copy link
Copy Markdown
@guysv guysv Feb 17, 2025

Choose a reason for hiding this comment

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

chatgpt crafted

bash -c 'exec 3<>/dev/tcp/localhost/1337; cat <&3 & cat >&3; kill $!'

to connect to localhost:1337 (tying stdin & stdout)

@peace-maker peace-maker merged commit 6954b03 into Gallopsled:dev Mar 30, 2025
12 of 13 checks passed
@peace-maker peace-maker deleted the ssh_connector_netcat branch March 30, 2025 11:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

0