• # sauver de la BP : bloquer nimda par ipchains

    Posté par . En réponse à la dépêche Un script pour detecter un scan de Nimda. Évalué à 3.

    ce script peut tourner en permanence, il ne perturbe pas logrotate. Lancer avec "nohup script"


    ----8<-------------8<----------
    #!/bin/sh

    # Repertoire des logs Apache
    cd /var/log/httpd

    # Augmenter le -n au besoin
    tail -n10000 --follow=name access_log | \
    awk '
    # on matche Nimda
    /scripts\/root.exe/ {
    old=0
    while(getline line < "nimda.txt"){if(1ドル ~ line) old=1}
    if(old==0){
    # On trace la becane verolee
    print 1ドル >> "nimda.txt"
    # Goodbye
    system("/sbin/ipchains -A input -j DENY -i eth0 -p tcp -s " 1ドル "
    --destination-port 80")
    }
    close("nimda.txt")
    }
    # on matche CodeRed
    /default.ida/ {
    old=0
    while(getline line < "codered.txt"){if(1ドル ~ line) old=1}
    if(old==0){
    # on trace la becane verolee
    print 1ドル >> "codered.txt"
    # Goodbye
    system("/sbin/ipchains -A input -j DENY -i eth0 -p tcp -s " 1ドル "
    --destination-port 80")
    }
    close("codered.txt")
    }' - &
    -------8<----------8<------------

    Sauver le fichier et comparer rend plus sur le fait de lancer plusieurs fois le script. Sinon ca n'est pas utile.


    traduction d'un post de Raimo Koski (www.raimokoski.com) sur comp.os.linux.security