#!/bin/perl print("=============================================================================\n"); print(" Limpiar logs v0.3 [www.hackcraft.com] \n"); print(" (IN-net,IN-world,IN-unknown) por Hugo Martin \n"); print("=============================================================================\n"); print(" Ejecuta: \"perldoc $0\" para más información\n\n"); $file=$ARGV[0]; if ($ARGV[0] eq "") { die ("Uso : $0 fichero_a_filtrar \nEjm : $0 messages.1 \n"); } print("[*] Limpiando logs ($file) de contenido *IN-net* ...\n"); system("grep -v 'IN-net' $file | sed /^\$/d > atemp000"); print("[*] Limpiando logs ($file) de contenido *IN-world* ...\n"); system("grep -v 'IN-world' atemp000 | sed /^\$/d > btemp000"); print("[*] Limpiando logs ($file) de contenido *IN-unknown* ...\n"); system("grep -v 'IN-unknown' btemp000 | sed /^\$/d > ctemp000"); print("[*] Eliminando ficheros temporales ...\n"); system("rm -f {$file,atemp000,btemp000}"); system("mv ctemp000 $file"); print("[*] Listo.\n\n"); # DOCUMENTATION =head1 NOMBRE limpialog.pl - Limpia un fichero de los de las lineas que contengan el texto: IN-net, IN-world, IN-unknown. Si utilizas *firehol* y tu red está infectada con algún gusano es probable que tus logs estén repletos. Esto lo solucionas con este limpiador de logs que permite visualizar los registros importantes, eliminando los generados por los gusanos o por broadcasts parecidos que firehol haya estado alertando constantemente. =head1 SINOPSIS Simplemente usa perl para correr este script y especifica el fichero de logs que quieres limpiar: $ perl limpialog.pl /var/log/messages/messages.2 $ perl limpialog.pl messages.2 =head1 DESCRIPCION =head2 Uso Normal $ ./limpialog.pl =head1 OPCIONES Todas las opciones son preguntadas en el modo =head1 BUGS Por ahora el Script asume que los ficheros atemp000,btemp000 y ctemp000 no existen en la carpeta desde donde se ejecuta, y los usa como temporales =head2 Reportando Fallas (Bugs) Versiones nuevas de este Script pueden ser descargadas de: http://www.hackcraft.com/ Si el bug está en la versión más reciente, envía un reporte al autor. Parches que arreglen problemas o agreguen nuevas características son bienvenidos. =head1 VER TAMBIEN perl(1) http://www.hackcraft.com http://www.perl.com =head1 AUTOR Hugo Martín, hugomartin@hackcraft.com =head1 COPYRIGHT Copyright (c) 2004, Hugo Martín. This script is free software; you may redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License with your Linuxin GNU/Linux system, in /usr/share/common-licenses/GPL, or with the dpkg source package as the file COPYING. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston. =head1 VERSION $Id: limpiarlog.pl,v 0.3 29/12/2004 13:24:02 mk Exp $ =cut