Mensaje editado: Había puesto información incorrectaPues eso, información para hacer port knocking hay un montón en la web, me he propuesto hacerlo para el puerto 22 de la máquina zentyal y le knock hacerlo con una secuencia telnet.
El código funciona bien (no es mío).
Lo que he hecho:
- Modifico el archivo firewall.postservice
- añado:
/sbin/iptables -N INTO-PHASE2
/sbin/iptables -A INTO-PHASE2 -m recent --name PHASE1 --remove
/sbin/iptables -A INTO-PHASE2 -m recent --name PHASE2 --set
/sbin/iptables -A INTO-PHASE2 -j LOG --log-prefix "INTO PHASE2: "
/sbin/iptables -N INTO-PHASE3
/sbin/iptables -A INTO-PHASE3 -m recent --name PHASE2 --remove
/sbin/iptables -A INTO-PHASE3 -m recent --name PHASE3 --set
/sbin/iptables -A INTO-PHASE3 -j LOG --log-prefix "INTO PHASE3: "
/sbin/iptables -N INTO-PHASE4
/sbin/iptables -A INTO-PHASE4 -m recent --name PHASE3 --remove
/sbin/iptables -A INTO-PHASE4 -m recent --name PHASE4 --set
/sbin/iptables -A INTO-PHASE4 -j LOG --log-prefix "INTO PHASE4: "
/sbin/iptables -A INPUT -m recent --update --name PHASE1
/sbin/iptables -A INPUT -p tcp --dport 100 -m recent --set --name PHASE1
/sbin/iptables -A INPUT -p tcp --dport 200 -m recent --rcheck --name PHASE1 -j INTO-PHASE2
/sbin/iptables -A INPUT -p tcp --dport 300 -m recent --rcheck --name PHASE2 -j INTO-PHASE3
/sbin/iptables -A INPUT -p tcp --dport 400 -m recent --rcheck --name PHASE3 -j INTO-PHASE4
/sbin/iptables -A INPUT -p tcp --dport 22 -m recent --rcheck --seconds 5 --name PHASE4 -j ACCEPT
Obtenido de: http://blog.amarelloartis.com/2009/07/07/port-knocking/De momento no funciona.
Desde la misma maquina ejecuto:
telnet localhost 100 ; telnet localhost 200 ; telnet localhost 300 ; telnet localhost 400 ; ssh localhost
resultado:
Trying ::1...
Trying 127.0.0.1...
telnet: Unable to connect to remote host: Connection refused
Trying ::1...
Trying 127.0.0.1...
telnet: Unable to connect to remote host: Connection refused
Trying ::1...
Trying 127.0.0.1...
telnet: Unable to connect to remote host: Connection refused
Trying ::1...
Trying 127.0.0.1...
telnet: Unable to connect to remote host: Connection refused
ssh: connect to host localhost port 22: Connection refused
EDITO: Viendo iptables -L veo que las cadenas si que me las crea