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

 

 


Tema destacado: Como proteger una cartera - billetera de Bitcoin


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


Desconectado Desconectado

Mensajes: 545



Ver Perfil
[Ruby] FinderText
« en: 11 Febrero 2012, 23:04 pm »

Un buscador de texto , sirve para encontrar archivos que contengan cierto patron.

Código
  1. #!usr/bin/ruby
  2. #FinderText 0.1
  3. #Coded By Doddy H
  4.  
  5. def openwords(file)
  6.  if File.file?(file)
  7.    ar = File.open(file)
  8.    lineas = ar.readlines
  9.    ar.close
  10.    return lineas
  11.  end
  12. end
  13.  
  14. def escalar(dir,text)
  15.  files = Dir.new(dir).entries
  16.  files.each do |file|
  17.    if File.file?(dir+"/"+file)
  18.      contador = 0
  19.      words = openwords(dir+"/"+file)
  20.      words.each do |word|
  21.      word = word.chomp
  22.      contador+=1
  23.      if word=~/#{text}/
  24.        parteuno = dir+"/"+file
  25.        patron = File.basename(__FILE__)
  26.        if not parteuno=~/#{patron}/
  27.          print "[+] File Found : "+dir+"/"+file+" in line #{contador}\n"
  28.        end        
  29.      end
  30.    end
  31.    else
  32.      if file != "." and file != ".." and file != File.basename(__FILE__)
  33.        escalar(dir+"/"+file,text)
  34.      end
  35.    end
  36.  end
  37. end
  38.  
  39. def sintax()
  40.  print "\n[+] sintax : ruby findertext.rb <directory> <text>\n"
  41. end
  42.  
  43. def head()
  44.  print "\n-- == FinderText 0.1 == --\n\n"
  45. end
  46.  
  47. def copyright()
  48.  print "\n\n(C) Doddy Hackman 2012\n\n"
  49. end
  50.  
  51. head()
  52.  
  53. dir = ARGV[0]
  54. text = ARGV[1]
  55.  
  56. if !dir and !text
  57.  sintax()
  58. else
  59.  print "\n[+] Starting the search\n\n\n"
  60.  escalar(dir,text)
  61.  print "\n\n[+] Finished\n\n"
  62. end
  63.  
  64. copyright()
  65.  
  66. # The End ?
  67.  


En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
ruby vs perl ??
Scripting
vacio 3 4,255 Último mensaje 26 Julio 2006, 17:32 pm
por vacio
Ruby
Programación General
¡Micronet! 2 3,149 Último mensaje 18 Octubre 2010, 22:49 pm
por ¡Micronet!
[Ruby] IRC Bot
Scripting
BigBear 0 2,307 Último mensaje 7 Octubre 2011, 01:30 am
por BigBear
[Perl] FinderText 0.1
Scripting
BigBear 0 1,171 Último mensaje 1 Diciembre 2011, 22:11 pm
por BigBear
[Ruby] FTP Crack 0.1
Scripting
BigBear 0 1,489 Último mensaje 10 Febrero 2012, 21:04 pm
por BigBear
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines