InfoSec Write-ups

A collection of write-ups from the best hackers in the world on topics ranging from bug bounties…

Follow publication

Bypass the Firewall with SSH Tunnelling

Febi Mudiyanto
InfoSec Write-ups
Published in
3 min readMay 28, 2022

Do you work for a company?
You have a problem with their firewall?
Or are you a hacker who making the netcat listener in your local computer?

This article fit for you. Because today I will explain you how making an ssh tunnel for accessing blocked port over port 22.

Port 22 by default use to ssh connection, and almost every company have allowed this port in their firewall.

Dummy Scenario

In this scenario, I wanna make a firewall rule to block facebook.com in my Windows Machine. This is an prove of concept that we will bypass the firewall with ssh tunnel.

My firewall settings

Firstly, collect the Facebook’s IP with nslookup command.

Then I am creating a new outbound rule in the firewall for specific blocking the facebook.com

My Working Laptop (Windows) — Before SSH Tunnel

Because the firewall block access to facebook.com, so when I try to connect with browser, and this is my browser respond:

Bypass Firewall

At the beginning, I am setting the sshd_config on the Ubuntu Server.

My Server (Ubuntu Server)

Make sure that in the file /etc/ssh/sshd_config have this configuration:

AllowTcpForwarding yes
GatewayPorts yes

After that restart the sshd service, for making sure that the config applied.

sudo service sshd restart

My Working Laptop (Windows) — After SSH Tunnel

Step number 1 on the windows machine, create an ssh tunnel:

ssh -N -D user@ip-server

Note:

-N → without login in to the server

-D →dynamic tunneling

8181 → is the port binding in the localhost to any port in the 192.168.0.113

The next step is setting your proxy like this,

And congratulation, your proxy server with ssh tunneling works and you bypass the firewall.

Demo

Conclusion

Firewall is not a one of the security tools for make sure your company is secure. Make a combination with some security tools and make the attacker in trouble.

Thanks for reading.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Published in InfoSec Write-ups

A collection of write-ups from the best hackers in the world on topics ranging from bug bounties and CTFs to vulnhub machines, hardware challenges and real life encounters. Subscribe to our weekly newsletter for the coolest infosec updates: https://weekly.infosecwriteups.com/

Written by Febi Mudiyanto

Just a Learner and CTFs Player on a quite night.

Responses (1)

Write a response

Yep ssh tunnel over port 22 is indeed effective. Correctly set up you have a tunnel and a network connection ie you basically connected the target network with your network.
If you want to spice it up try the same over http and https as they are…

--