Autore |
Discussione  |
|
volley_3
Advanced Member
    

Nota:
672 Messaggi |
Inserito il - 01/04/2008 : 10:58:40
|
vi posto in queste ore notturne il mio script personale di iptables... cosa ne dite? ho sbagliato qualcosa?
#iptables script 1 aprile 0.1 set -x #cancella tutto /sbin/iptables -X /sbin/iptables -F /sbin/iptables -Z
#blocco in ingresso, foward e accetto in uscita /sbin/iptables -P INPUT DROP /sbin/iptables -P FORWARD DROP /sbin/iptables -P OUTPUT ACCEPT
#accetto connessioni gia esistenti /sbin/iptables -A INPUT -i lo -j ACCEPT /sbin/iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
#/sbin/iptables -A OUTPUT -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT
# abilitiamo i pacchetti icmp (il ping) per l'interfaccia di loopback /sbin/iptables -A INPUT -i lo -p icmp -j ACCEPT
# abilitiamo i pacchetti icmp per la scheda di rete /sbin/iptables -A INPUT -i eth0 -p icmp -j ACCEPT
#Rifiuto di rispondere ai ping inviati all'indirizzo broadcast della rete: echo 0 > /proc/sys/net/ipv4/conf/all/accept_redirects echo 0 > /proc/sys/net/ipv4/conf/all/accept_source_route #Rifiuto pacchetti ICMP di route redirection echo 1 > /proc/sys/net/ipv4/icmp_ignore_bogus_error_responses echo 1 > /proc/sys/net/ipv4/tcp_syncookies echo 1 > /proc/sys/net/ipv4/conf/all/rp_filter #Protezione contro attacchi spoofing echo 1 > /proc/sys/net/ipv4/conf/all/log_martians
#Scarto un flood di pacchetti ICMP fuori taglia (dimensione massima 93 bytes) /sbin/iptables -A INPUT -p ICMP --icmp-type 8 -m length --length 93: -j DROP
#consento amule /sbin/iptables -A INPUT -p tcp --dport 4662 -j ACCEPT /sbin/iptables -A INPUT -p udp --dport 4672 -j ACCEPT
#consento msn /sbin/iptables -A INPUT -p tcp --dport 1863 -j ACCEPT /sbin/iptables -A INPUT -p tcp --dport 6981 -j ACCEPT
#consento posta hotmail con thunderbid /sbin/iptables -A INPUT -p tcp --dport 1024 -j ACCEPT /sbin/iptables -A INPUT -p tcp --dport 1025 -j ACCEPT
#log #iptables -N LogInDrop #log delle connessioni bloccate #iptables -N LogFwDrop #log delle connessioni bloccate
ho fatto un test di sicurezza online e quardate cosa è venuto fuori? htt*://[www].pcflank[.com]/scanner1s.htm
TCP "ping" non-stealthed TCP NULL non-stealthed TCP FIN non-stealthed TCP XMAS non-stealthed UDP stealthed
come faccio a risolvere?
|
|
Yves
Moderatore
    

Città: Buenos Aires
6097 Messaggi |
Inserito il - 01/04/2008 : 15:51:20
|
Bè, io non conosco troppo iptables, ho usato uno script presente sul forum Ubuntu.it (settare firewall) e a me da tutt'altro risultato:
yves[No-Spam]gibbon:~$ cat /etc/init.d/firewall
#!/bin/bash
#
# Firewall personale by Benjamin (Mizar)
############################################
######################################################
# Indirizzo web di origine #
# htt*://forum.ubuntu-it.org/index.php?topic=12833.0 #
######################################################
#########################
# Definizione Variabili #
#########################
IPTABLES="/sbin/iptables"
IFLO="lo"
IFEXT1="eth0" # Da sostituire con la propria interfaccia: eth0, eth1, ppp0, etc
IFEXT2="eth1" # Da sostituire con la propria interfaccia: eth0, eth1, ppp0, etc
case "$1" in
start)
########################
# Attivazione Firewall #
########################
echo -n "Attivazione Firewall: "
#################################
# Caricamento Moduli del Kernel #
#################################
modprobe ip_tables
modprobe iptable_nat
modprobe ip_conntrack
modprobe ip_conntrack_ftp
modprobe ip_nat_ftp
modprobe ipt_LOG
modprobe ipt_MARK
modprobe ipt_MASQUERADE
modprobe ipt_REDIRECT
modprobe ipt_REJECT
modprobe ipt_TOS
modprobe ipt_limit
modprobe ipt_mac
modprobe ipt_mark
modprobe ipt_multiport
modprobe ipt_state
modprobe ipt_tos
modprobe iptable_mangle
############################
# Reset delle impostazioni #
############################
$IPTABLES -F
$IPTABLES -F -t nat
$IPTABLES -F -t mangle
$IPTABLES -X
$IPTABLES -X -t nat
$IPTABLES -X -t mangle
################################
# Impostazione Policy standard #
################################
$IPTABLES -P INPUT DROP
$IPTABLES -P FORWARD DROP
$IPTABLES -P OUTPUT ACCEPT
#################################
# Abilitazione traffico interno #
#################################
$IPTABLES -A INPUT -i $IFLO -j ACCEPT
$IPTABLES -A OUTPUT -o $IFLO -j ACCEPT
#############################################################################
# Abilitazione traffico in entrata solo se relativo a pacchetti in risposta #
#############################################################################
$IPTABLES -A INPUT -p tcp -i $IFEXT1 -m state -s 0/0 --state ESTABLISHED,RELATED -j ACCEPT
$IPTABLES -A INPUT -p icmp -i $IFEXT1 -m state -s 0/0 --state ESTABLISHED,RELATED -j ACCEPT
$IPTABLES -A INPUT -p udp -i $IFEXT1 -m state -s 0/0 --state ESTABLISHED,RELATED -j ACCEPT
$IPTABLES -A INPUT -p tcp -i $IFEXT2 -m state -s 0/0 --state ESTABLISHED,RELATED -j ACCEPT
$IPTABLES -A INPUT -p icmp -i $IFEXT2 -m state -s 0/0 --state ESTABLISHED,RELATED -j ACCEPT
$IPTABLES -A INPUT -p udp -i $IFEXT2 -m state -s 0/0 --state ESTABLISHED,RELATED -j ACCEPT
#########
# samba #
#########
$IPTABLES -A INPUT -p udp -m udp -s 192.168.0.0/24 --dport 137 -j ACCEPT
$IPTABLES -A INPUT -p udp -m udp -s 192.168.0.0/24 --dport 138 -j ACCEPT
$IPTABLES -A INPUT -m state --state NEW -m tcp -p tcp -s 192.168.0.0/24 --dport 139 -j ACCEPT
$IPTABLES -A INPUT -m state --state NEW -m tcp -p tcp -s 192.168.0.0/24 --dport 445 -j ACCEPT
########################
# Apertura porte aMule #
########################
iptables -A INPUT -p tcp --dport 4662 -j ACCEPT
iptables -A INPUT -p udp --dport 4665 -j ACCEPT
iptables -A INPUT -p udp --dport 4672 -j ACCEPT
##########################
# Apertura porte Azureus #
##########################
iptables -A INPUT -p tcp --dport 6881 -j ACCEPT
#######################
# Apertura porte giFT #
#######################
iptables -A INPUT -p tcp --dport 1213 -j ACCEPT
iptables -A INPUT -p tcp --dport 2176 -j ACCEPT
#######################
# Apertura porte aMsn #
#######################
iptables -A INPUT -p tcp --dport 1683 -j ACCEPT
echo "ok"
;;
stop)
###########################
# Disattivazione Firewall #
###########################
echo -n "Disattivazione Firewall: "
$IPTABLES -F
$IPTABLES -F -t nat
$IPTABLES -F -t mangle
$IPTABLES -X
$IPTABLES -X -t nat
$IPTABLES -X -t mangle
$IPTABLES -P INPUT ACCEPT
$IPTABLES -P FORWARD ACCEPT
$IPTABLES -P OUTPUT ACCEPT
echo "ok"
;;
status)
##############################
# Display stato del Firewall #
##############################
echo -n "Regole attuali nel Firewall: "
$IPTABLES -L
;;
restart|reload)
$0 stop
$0 start
;;
*)
echo "Utilizzo: firewall {start|stop|restart|reload|status}" >&2
exit 1
;;
esac
exit 0
il risultato che viene fuori sul tuo sito è questo:
Packet' type Status
TCP "ping" stealthed
TCP NULL stealthed
TCP FIN stealthed
TCP XMAS stealthed
UDP stealthed
Ciao. |
 |
|
volley_3
Advanced Member
    

Nota:
672 Messaggi |
Inserito il - 01/04/2008 : 23:06:54
|
ok grazie l'ho modificato a mia esigenza
#!/bin/bash # # Firewall personale by Benjamin (Mizar) ############################################
###################################################### # Indirizzo web di origine # # htt*://forum.ubuntu-it.org/index.php?topic=12833.0 # ######################################################
######################### # Definizione Variabili # ######################### IPTABLES="/sbin/iptables" IFLO="lo" IFEXT1="eth0" # Da sostituire con la propria interfaccia: eth0, eth1, ppp0, etc #IFEXT2="eth1" # Da sostituire con la propria interfaccia: eth0, eth1, ppp0, etc
case "$1" in start) ######################## # Attivazione Firewall # ######################## echo -n "Attivazione Firewall: "
################################# # Caricamento Moduli del Kernel # ################################# modprobe ip_tables modprobe iptable_nat modprobe ip_conntrack modprobe ip_conntrack_ftp modprobe ip_nat_ftp modprobe ipt_LOG modprobe ipt_MARK modprobe ipt_MASQUERADE modprobe ipt_REDIRECT modprobe ipt_REJECT modprobe ipt_TOS modprobe ipt_limit modprobe ipt_mac modprobe ipt_mark modprobe ipt_multiport modprobe ipt_state modprobe ipt_tos modprobe iptable_mangle
############################ # Reset delle impostazioni # ############################ $IPTABLES -F $IPTABLES -F -t nat $IPTABLES -F -t mangle $IPTABLES -X $IPTABLES -X -t nat $IPTABLES -X -t mangle
################################ # Impostazione Policy standard # ################################ $IPTABLES -P INPUT DROP $IPTABLES -P FORWARD DROP $IPTABLES -P OUTPUT ACCEPT
################################# # Abilitazione traffico interno # ################################# $IPTABLES -A INPUT -i $IFLO -j ACCEPT $IPTABLES -A OUTPUT -o $IFLO -j ACCEPT
############################################################################# # Abilitazione traffico in entrata solo se relativo a pacchetti in risposta # ############################################################################# $IPTABLES -A INPUT -p tcp -i $IFEXT1 -m state -s 0/0 --state ESTABLISHED,RELATED -j ACCEPT $IPTABLES -A INPUT -p icmp -i $IFEXT1 -m state -s 0/0 --state ESTABLISHED,RELATED -j ACCEPT $IPTABLES -A INPUT -p udp -i $IFEXT1 -m state -s 0/0 --state ESTABLISHED,RELATED -j ACCEPT #$IPTABLES -A INPUT -p tcp -i $IFEXT2 -m state -s 0/0 --state ESTABLISHED,RELATED -j ACCEPT #$IPTABLES -A INPUT -p icmp -i $IFEXT2 -m state -s 0/0 --state ESTABLISHED,RELATED -j ACCEPT #$IPTABLES -A INPUT -p udp -i $IFEXT2 -m state -s 0/0 --state ESTABLISHED,RELATED -j ACCEPT
######### # samba # ######### #$IPTABLES -A INPUT -p udp -m udp -s 192.168.0.0/24 --dport 137 -j ACCEPT #$IPTABLES -A INPUT -p udp -m udp -s 192.168.0.0/24 --dport 138 -j ACCEPT #$IPTABLES -A INPUT -m state --state NEW -m tcp -p tcp -s 192.168.0.0/24 --dport 139 -j ACCEPT #$IPTABLES -A INPUT -m state --state NEW -m tcp -p tcp -s 192.168.0.0/24 --dport 445 -j ACCEPT
######################## # Apertura porte aMule # ######################## $IPTABLES -A INPUT -p tcp --dport 4662 -j ACCEPT $IPTABLES -A INPUT -p udp --dport 4665 -j ACCEPT $IPTABLES -A INPUT -p udp --dport 4672 -j ACCEPT
########################## # Apertura porte Azureus # ########################## #$IPTABLES -A INPUT -p tcp --dport 6881 -j ACCEPT
####################### # Apertura porte giFT # ####################### #$IPTABLES -A INPUT -p tcp --dport 1213 -j ACCEPT #$IPTABLES -A INPUT -p tcp --dport 2176 -j ACCEPT
####################### # Apertura porte Msn # ####################### $IPTABLES -A INPUT -p tcp --dport 1683 -j ACCEPT #$IPTABLES -A INPUT -p tcp --dport 6981 -j ACCEPT
############################## # Apertura porte smtp e pop3 # ############################## $IPTABLES -A INPUT -p tcp --dport 1024 -j ACCEPT $IPTABLES -A INPUT -p tcp --dport 1025 -j ACCEPT
############################## # Contro attacchi hacker # ############################## #Rifiuto di rispondere ai ping inviati all'indirizzo broadcast della rete: echo 0 > /proc/sys/net/ipv4/conf/all/accept_redirects echo 0 > /proc/sys/net/ipv4/conf/all/accept_source_route #Rifiuto pacchetti ICMP di route redirection echo 1 > /proc/sys/net/ipv4/icmp_ignore_bogus_error_responses echo 1 > /proc/sys/net/ipv4/tcp_syncookies echo 1 > /proc/sys/net/ipv4/conf/all/rp_filter #Protezione contro attacchi spoofing echo 1 > /proc/sys/net/ipv4/conf/all/log_martians #Scarto un flood di pacchetti ICMP fuori taglia (dimensione massima 93 bytes) $IPTABLES -A INPUT -p ICMP --icmp-type 8 -m length --length 93: -j DROP
echo "ok" ;;
stop) ########################### # Disattivazione Firewall # ########################### echo -n "Disattivazione Firewall: "
$IPTABLES -F $IPTABLES -F -t nat $IPTABLES -F -t mangle $IPTABLES -X $IPTABLES -X -t nat $IPTABLES -X -t mangle
$IPTABLES -P INPUT ACCEPT $IPTABLES -P FORWARD ACCEPT $IPTABLES -P OUTPUT ACCEPT
echo "ok" ;;
status) ##############################
# Display stato del Firewall # ############################## echo -n "Regole attuali nel Firewall: "
$IPTABLES -L ;;
restart|reload) $0 stop $0 start ;;
*) echo "Utilizzo: firewall {start|stop|restart|reload|status}" >&2 exit 1 ;;
esac
exit 0
però nn capisco perkè incollarlo in /etc/init.d e dandogli chmod 755 nn mi si avvia alla'avvio del pc...
ke dite? |
 |
|
Yves
Moderatore
    

Città: Buenos Aires
6097 Messaggi |
Inserito il - 02/04/2008 : 00:04:28
|
Devi metterlo in avvio automatico, Gnome utilizza Bum, su KDE si risolve dal impostazioni di sistema -> advanced -> servizi di sistema, di li fai il necessario per metterlo in avvio automatico. |
 |
|
volley_3
Advanced Member
    

Nota:
672 Messaggi |
Inserito il - 02/04/2008 : 09:27:28
|
si però poi devo mettere la password di root?c'è un modo per nn metterla? |
 |
|
Yves
Moderatore
    

Città: Buenos Aires
6097 Messaggi |
Inserito il - 02/04/2008 : 15:28:27
|
Prima di fare domande a vanvera hai provato a farlo?
La password di root te la chiede per impostare la preferenza (in Bom o pannello di controllo), una volta che è impostata (cioè che hai aggiunto lo script correttamente nella sezione di avvio) la procedura ad ogni avvio del PC diventa trasparente, come gli altri servizio di sistema, non richiede più password, lo script deve essere messo nella cartella /etc/init.d, deve in oltre essere eseguibile. |
Modificato da - Yves in data 02/04/2008 15:31:10 |
 |
|
volley_3
Advanced Member
    

Nota:
672 Messaggi |
Inserito il - 02/04/2008 : 18:21:13
|
ok risolto aspettaimo il riavvio che avverrà stasera |
Modificato da - volley_3 in data 02/04/2008 18:29:18 |
 |
|
volley_3
Advanced Member
    

Nota:
672 Messaggi |
Inserito il - 07/04/2008 : 11:16:06
|
ragazzi come posso loggare i pacchetti droppati dal mio script??? magari creando un nuovo log in /var/log |
 |
|
volley_3
Advanced Member
    

Nota:
672 Messaggi |
Inserito il - 07/04/2008 : 14:21:09
|
dovrei usare queste 3 stringhe
iptables -A FORWARD -j LOG --log-prefix="FORWARD: " iptables -A INPUT -j LOG --log-prefix="INPUT:" iptables -A OUTPUT -j LOG --log-prefix="OUTPUT:"
ma ho due domande...
-in quale file verranno loggati i pacchetti? -io vorrei che loggase solo i pacchetti bloccati dal firewall
mi date una mano?
dovrebbe essere tipo questa stringa iptables -A INPUT -m pkttype --pkt-type unicast -j LOG --log-prefix "INPUT: " --log-level 7
ma nn so che mi dite? |
 |
|
ori
Moderatore
    

Città: Verona
2043 Messaggi |
Inserito il - 07/04/2008 : 16:13:51
|
I pacchetti loggati finiscono in /var/log/messages, come tutti i messaggi generati dal kernel.
Se vuoi mandarli anche su un file specifico, devi configurare in modo opportuno syslog, i cui file di configurazione li trovi in /etc/
Se vuoi loggare solo quelli droppati dal firewall, la tecnica standard usata consiste nel duplicare le regole di drop: la prima logga, la seconda (con le medesime condizioni della prima) droppa. E di solito si mettono a coppie, ossia regola di log immediatamente seguita da quella di drop. |
Modificato da - ori in data 07/04/2008 16:16:08 |
 |
|
volley_3
Advanced Member
    

Nota:
672 Messaggi |
Inserito il - 07/04/2008 : 16:24:18
|
come faccio a creare la stringa? |
 |
|
|
Discussione  |
|