elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Trabajando con las ramas de git (tercera parte)


+  Foro de elhacker.net
|-+  Programación
| |-+  Scripting
| | |-+  [Perl] Finder Text 0.2
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: [Perl] Finder Text 0.2  (Leído 1,356 veces)
BigBear


Desconectado Desconectado

Mensajes: 545



Ver Perfil
[Perl] Finder Text 0.2
« en: 23 Junio 2012, 18:15 pm »

Simple script para buscar patrones en cualquier directorio.

Código
  1. #!usr/bin/perl
  2. #FinderText 0.2
  3. #Coded by Doddy H
  4.  
  5. head();
  6. print "[+] Directory : ";
  7. chomp( my $dir = <stdin> );
  8. print "\n[+] String : ";
  9. chomp( my $string = <stdin> );
  10. print "\n[+] Searching text\n\n";
  11. goodbye( $dir, $string );
  12. copyright();
  13.  
  14. sub verificar {
  15.  
  16.    my ( $file, $text ) = @_;
  17.    my $numero_linea = 0;
  18.  
  19.    open( FILE, $file );
  20.    my @words = <FILE>;
  21.    close FILE;
  22.  
  23.    chomp @words;
  24.  
  25.    for my $linea (@words) {
  26.        chomp $linea;
  27.        $numero_linea++;
  28.        if ( $linea =~ /$text/ ) {
  29.            print "[+] Text $text Found in file $file in line $numero_linea\n";
  30.        }
  31.    }
  32. }
  33.  
  34. sub goodbye {
  35.    opendir DIR, $_[0];
  36.    my @archivos = readdir DIR;
  37.    close DIR;
  38.  
  39.    for (@archivos) {
  40.        next if $_ eq "." or $_ eq "..";
  41.        my $fichero = $_[0] . "/" . $_;
  42.  
  43.        if ( -f $fichero ) {
  44.            verificar( $fichero, $_[1] );
  45.        }
  46.  
  47.        if ( -d $fichero ) {
  48.            &goodbye( $fichero, $_[1] );
  49.        }
  50.    }
  51. }
  52.  
  53. sub head {
  54.  
  55.    print qq(
  56.  
  57.  
  58. @@@@@ @           @             @@@@@              
  59. @                 @               @               @
  60. @                 @               @               @
  61. @     @ @ @@   @@@@  @@@  @@      @     @@@  @  @ @@
  62. @@@@  @ @@  @ @   @ @   @ @       @    @   @ @  @ @
  63. @     @ @   @ @   @ @@@@@ @       @    @@@@@  @@  @
  64. @     @ @   @ @   @ @     @       @    @      @@  @
  65. @     @ @   @ @   @ @   @ @       @    @   @ @  @ @
  66. @     @ @   @  @@@@  @@@  @       @     @@@  @  @  @
  67.  
  68.  
  69.  
  70. );
  71.  
  72. }
  73.  
  74. sub copyright {
  75.    print "\n\n-- == Doddy Hackman 2012 == --\n\n";
  76.    <stdin>;
  77.    exit(1);
  78. }
  79.  
  80. # The End ?
  81.  


En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
[Perl] Finder Paths
Scripting
BigBear 0 1,462 Último mensaje 14 Octubre 2011, 15:25 pm
por BigBear
[Perl] Finder Pass 0.3
Scripting
BigBear 0 1,490 Último mensaje 31 Marzo 2012, 22:46 pm
por BigBear
[Perl Tk] Finder Pass 0.4
Scripting
BigBear 0 1,451 Último mensaje 31 Marzo 2012, 22:47 pm
por BigBear
[Perl] Finder Paths 0.6
Scripting
BigBear 0 1,315 Último mensaje 8 Abril 2012, 01:55 am
por BigBear
[Perl Tk] Finder Text 0.2
Scripting
BigBear 1 1,814 Último mensaje 23 Junio 2012, 19:41 pm
por 0xDani
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines