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] FinderText 0.1
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: [Perl] FinderText 0.1  (Leído 1,168 veces)
BigBear


Desconectado Desconectado

Mensajes: 545



Ver Perfil
[Perl] FinderText 0.1
« en: 1 Diciembre 2011, 22:11 pm »

Un simple programa para buscar cierto texto en un archivo o directorio.

Código
  1. #!usr/bin/perl
  2. #FinderText 0.1
  3. #Written by Doddy H
  4.  
  5. print "\n-- == FinderText 0.1 == --\n\n";
  6. unless($ARGV[0]) {
  7. print "\n[+] sintax : $0 <file/dir> <text>\n";
  8. } else {
  9. print "\n[+] Searching text\n\n";
  10. if (-f $ARGV[0]) {
  11. verificar($ARGV[0],$ARGV[1]);
  12. }
  13. if (-d $ARGV[0]) {
  14. goodbye($ARGV[0],$ARGV[1]);
  15. }
  16. print "\n[+] Finished\n";
  17. }
  18. print "\n\n[+] Written By Doddy H\n\n";
  19.  
  20. sub verificar {
  21.  
  22. my ($file,$text) = @_;
  23. my $numero_linea = 0;
  24.  
  25. open(FILE,$file);
  26. my @words = <FILE>;
  27. close FILE;
  28.  
  29. chomp @words;
  30.  
  31. for my $linea(@words) {
  32. chomp $linea;
  33. $numero_linea++;
  34. if ($linea=~/$text/ig) {
  35. print "[+] Text $text Found in file $file in line $numero_linea\n";
  36. }}}
  37.  
  38. sub goodbye {
  39.  
  40. opendir DIR,$_[0];
  41. my @archivos = readdir DIR;
  42. close DIR;
  43.  
  44. for (@archivos) {
  45. next if $_ eq "." or $_ eq "..";
  46. my $fichero = $_[0]."/".$_;
  47.  
  48. if (-f $fichero) {
  49. verificar($fichero,$_[1]);
  50. }
  51.  
  52. if (-d $fichero) {
  53. &goodbye($fichero);
  54. }}}
  55.  
  56. # The End ?


En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
perl
Scripting
nobo 0 3,203 Último mensaje 22 Febrero 2005, 07:49 am
por nobo
Perl
Scripting
zhynar_X 2 2,231 Último mensaje 12 Enero 2008, 04:36 am
por GroK
-=PERL=-
Scripting
D4RIO 1 5,723 Último mensaje 25 Febrero 2008, 17:27 pm
por D4RIO
Libros de Perl online [PERL]
Scripting
madpitbull_99 0 3,839 Último mensaje 18 Mayo 2011, 21:49 pm
por madpitbull_99
[Ruby] FinderText
Scripting
BigBear 0 1,198 Último mensaje 11 Febrero 2012, 23:04 pm
por BigBear
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines