Advertisement
Guest User

Untitled

a guest
Jun 4th, 2012
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.95 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. ## SCRIPT SET UP IPTABLES ##
  4. #*****************************#
  5. # LITTLE CONFIG
  6. #i_man="wlan0" ;
  7. RED="\e[0;31m" ;
  8. YEL="\e[0;33m" ;
  9. NORM="\e[0m" ;
  10.  
  11.  
  12. fun_usage () {
  13. echo -e "$RED USAGE: { start | clean | list }  $NORM"
  14. echo
  15. echo -e "$YEL set up iptable, read manual for more information,"
  16. echo -e " if you want improve this script you are welcome! "
  17. echo -e " remember that that iptable rules prevent you to be scanned or pinged "
  18. echo -e " no one rules for OUTGOING or FORWARDED pack."
  19. exit 0
  20. }
  21.  
  22.  
  23.  
  24. fun_clean () {
  25. echo -e "$YEL ripulisco iptables $NORM"
  26. iptables -F
  27. #iptables -F -t nat
  28. #iptables -F -t mangle
  29. iptables -L
  30. echo -e "$YEL fatto! $NORM"
  31. exit 0
  32. }
  33.  
  34. fun_start () {
  35. echo
  36. iptables -I INPUT -p icmp -m state -s 0/0 --state INVALID,NEW -j DROP
  37. iptables -I INPUT -p udp -m state -s 0/0  --state INVALID,NEW -j DROP
  38. iptables -I INPUT -p tcp -m state --state NEW -m recent --set
  39. iptables -I INPUT -p tcp -m state --state NEW -m recent --update --seconds 30 --hitcount 10 -j DROP
  40. iptables -I INPUT -p tcp ! --syn -m state --state NEW -j DROP
  41. iptables -I INPUT -f -j DROP
  42. iptables -I INPUT -p tcp --tcp-flags ALL ALL -j DROP #this is for xmas malformed packet!
  43. iptables -I INPUT -p tcp --tcp-flags ALL NONE -j DROP
  44. iptables -I INPUT -p tcp -m state -s 0/0 --dport 1:65535 --state INVALID,NEW -j DROP
  45. #echo -e "$YEL.fun start eseguita corretamente! $NORM"
  46. exit 0
  47. }
  48.  
  49. fun_list (){
  50. iptables -L
  51. echo
  52. echo -e "$YEL vuoi ripulire le chain? do you want to clean? [si/no] $NORM"
  53.     read risp
  54.  
  55. case $risp in
  56.     no) exit ;;
  57.     n) exit ;;
  58.     *) fun_clean ;;
  59. esac
  60. }
  61.  
  62. if [ $UID == 0 ]
  63.     then
  64.         echo -e "$YEL permessi ok! $NORM"
  65.     else
  66.         echo -e "$RED non hai i permessi, need to be root! $NORM"
  67.         fun_usage
  68. fi
  69. echo
  70. if [ $# != "1" ]
  71.     then
  72.         echo -e "$RED devi specificare un argomento! $NORM"
  73.         echo " $1 "
  74.         fun_usage
  75. fi
  76.  
  77. case $1 in
  78.     start) fun_start ;;
  79.     clean) fun_clean ;;
  80.     list) fun_list ;;
  81.      *) fun_usage ;;
  82. esac
  83.  
  84. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement