Check Firewall for Open Ports

Linux Dec 15, 2021

Quite often in corporate environments I have to tunnel my traffic during red teaming engagements and I don't know about you, but UDP and other ports than 443 and 80 are often restricted on German networks.

In order to verify which ports are accessible for TCP you can use the following redirect rule on a VPS in order to redirect all traffic to one port and then scan the host with nmap or any other manual tool of your choice.

# On the VPS
iptables -t nat -A PREROUTING -p tcp --dport 1:65535 -j REDIRECT --to-ports 10000

Then depending on the python version of the server you can start a simple HTTPlistener in an empty folder:

mkdir /tmp/emptything && cd /tmp/emptything

python3 -m http.server 10000
python2 -m SimpleHTTPServer 10000

Now scan your VPS IP:

nmap -p- -v <ip>

Tags