Finding out what is doing a port
Quickly run:
Reverse SSH tunnelling theory
Info
Reverseย SSHย port forwarding specifies that the given port on the remote server host is to be forwarded to the given host and port on the local side.
Note
-L
ย is a local tunnel (YOU โ CLIENT). If a site was blocked, you can forward the traffic to a server you own and view it. For example, ifimgur
was blocked at work, you can doยssh -L 9000:imgur.com:80 user@example.com
ย Going toยlocalhost:9000
on your machine, will loadimgur
traffic using your other server.
-R
ย is a remote tunnel (YOU โ CLIENT).ย You forward your traffic to the other server for others to view. Similar to the example above, but in reverse.
We will use a tool calledย ssย to investigate sockets running on a host.
If we runย ss -tulpn
ย it will tell us what socket connections are running
Argument | Description |
---|---|
-t | Display TCP sockets |
-u | Display UDP sockets |
-l | Displays only listening sockets |
-p | Shows the process using the socket |
-n | Doesnโt resolve service names |
To expose a service running on a blocked port by a firewall rule to the outside, we can expose the port to us (locally). Run the following on your machine:
Performing a reverse SSH tunneling
When you find a port that is only opened in localhost like:
you can drop a SSH key on the server and use SSH to do a reverse tunneling of the port you want to access back on our machine:
Now copy the USERNAME.pub
key into the USERNAME .ssh
folder:
Give to the SSH private key the necessary permissions and use the argument -L
to perform a reverse port forwarding of the local port to your local box port: