Part of Slepp's ProjectsPastebinTURLImagebinFilebin
Feedback -- English French German Japanese
Create Upload Newest Tools Donate

Advertising

Someone
Friday, November 2nd, 2012 at 9:45:25am UTC 

  1. ##Probar iptables con nmap
  2. #nmap -v -f ipptables-IP
  3.  
  4. #CONEXION
  5. IFACE="eth0"
  6.  
  7. #Borramos las reglas que pudiera haber, las cadenas y los contadores
  8. iptables -F
  9. iptables -X
  10. iptables -Z
  11. iptables -t nat -F
  12.  
  13. ## Establecemos politica por defecto: DROP
  14. iptables -P INPUT DROP
  15. iptables -P OUTPUT DROP
  16. iptables -P FORWARD DROP
  17.  
  18. # Aceptamos todo de localhost
  19. iptables -A INPUT -i lo -j ACCEPT
  20. iptables -A OUTPUT -o lo -j ACCEPT
  21.  
  22. #PERMITIR CONEXIONES
  23. #previamente establecida en reglas posteriores.
  24. iptables -t filter -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
  25. iptables -t filter -A OUTPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
  26. iptables -t filter -A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT
  27.  
  28. #Robot chupabanda.
  29. iptables -I INPUT -s 208.115.111.64/28 -j DROP
  30.  
  31. #HTTP-HTTPS
  32. iptables -A INPUT -p tcp --dport 80 -j ACCEPT
  33. iptables -A INPUT -p tcp --dport 443 -j ACCEPT
  34.  
  35. # impedimos iniciar conexion los puertos altos
  36. #iptables -A INPUT -p tcp --syn --dport 1025:65535 -j DROP
  37.  
  38. # Cerramos el rango de puerto bien conocido
  39. iptables -A INPUT -i eth0 -p tcp --dport 1:1024 --j DROP
  40. iptables -A INPUT -i eth0 -p udp --dport 1:1024 --j DROP
  41.  
  42. # Deshabilitar broadcast
  43. /bin/echo "1" > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts
  44.  
  45. # Deshabilitar el ping… quizá discutible.
  46. /bin/echo "1" > /proc/sys/net/ipv4/icmp_echo_ignore_all
  47.  
  48. # Deshabilitar la redirección del ping
  49. /bin/echo "1" > /proc/sys/net/ipv4/conf/all/accept_redirects
  50.  
  51. # Registrar los accesos extraños, paquetes falseados, etc..
  52. /bin/echo "1" > /proc/sys/net/ipv4/conf/all/log_martians
  53.  
  54. # Anti nmap :)
  55. iptables -N PORTSCAN
  56. iptables -A INPUT -i all -p tcp --tcp-flags ALL FIN,URG,PSH -m recent --set -j PORTSCAN
  57. iptables -A FORWARD -i all -p tcp --tcp-flags ALL FIN,URG,PSH -m recent --set -j PORTSCAN
  58.  
  59. # SYN/RST
  60. iptables -A INPUT -i all -p tcp --tcp-flags SYN,RST SYN,RST -m recent --set -j PORTSCAN
  61. iptables -A FORWARD -i all -p tcp --tcp-flags SYN,RST SYN,RST -m recent --set -j PORTSCAN
  62.  
  63. # SYN/FIN -- Scan(probably)
  64. iptables -A INPUT -i all -p tcp --tcp-flags SYN,FIN SYN,FIN -m recent --set -j PORTSCAN
  65. iptables -A FORWARD -i all -p tcp --tcp-flags SYN,FIN SYN,FIN -m recent --set -j PORTSCAN
  66.  
  67. # NMAP FIN Stealth
  68. iptables -A INPUT -i all -p tcp --tcp-flags ALL FIN -m recent --set -j PORTSCAN
  69. iptables -A FORWARD -i all -p tcp --tcp-flags ALL FIN -m recent --set -j PORTSCAN
  70.  
  71. # ALL/ALL Scan
  72. iptables -A INPUT -i all -p tcp --tcp-flags ALL ALL -m recent --set -j PORTSCAN
  73. iptables -A FORWARD -i all -p tcp --tcp-flags ALL ALL -m recent --set -j PORTSCAN
  74.  
  75. # NMAP Null Scan
  76. iptables -A INPUT -i all -p tcp --tcp-flags ALL NONE -m recent --set -j PORTSCAN
  77. iptables -A FORWARD -i all -p tcp --tcp-flags ALL NONE -m recent --set -j PORTSCAN
  78.  
  79. #XMAS
  80. iptables -A INPUT -i all -p tcp --tcp-flags ALL URG,ACK,PSH,RST,SYN,FIN -m recent --set -j PORTSCAN
  81. iptables -A FORWARD -i all -p tcp --tcp-flags ALL URG,ACK,PSH,RST,SYN,FIN -m recent --set -j PORTSCAN
  82. iptables -A PORTSCAN -m limit --limit 1/second -j LOG --log-level info --log-prefix "PORTSCAN -- SHUN " --log-tcp-sequence --log-tcp-options --log-ip-options
  83.  
  84. # Drop this packet !!
  85. iptables -A PORTSCAN -j DROP
  86.  
  87. # permitir al server hacer ping a cualquier lado
  88. iptables -t filter -A OUTPUT -p icmp -j ACCEPT
  89.  
  90. #REGLAS
  91. iptables -L
  92.  
  93. exit

advertising

Update the Post

Either update this post and resubmit it with changes, or make a new post.

You may also comment on this post.

update paste below
details of the post (optional)

Note: Only the paste content is required, though the following information can be useful to others.

Save name / title?

(space separated, optional)



Please note that information posted here will not expire by default. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.

comments powered by Disqus
worth-right