• Earn real money by being active: Hello Guest, earn real money by simply being active on the forum — post quality content, get reactions, and help the community. Once you reach the minimum credit amount, you’ll be able to withdraw your balance directly. Learn how it works.

Ruby [Ruby] FinderText

Status
Not open for further replies.

Doddy

Leech
User
Joined
Apr 1, 2012
Messages
169
Reputation
0
Reaction score
406
Points
63
Credits
0
‎13 Years of Service‎
57%
Un buscador de texto , sirve para encontrar archivos que contengan cierto patron.

Code:
>
#!usr/bin/ruby
#FinderText 0.1
#Coded By Doddy H

def openwords(file)
 if File.file?(file)
   ar = File.open(file)
   lineas = ar.readlines
   ar.close
   return lineas
 end
end

def escalar(dir,text)
 files = Dir.new(dir).entries
 files.each do |file|
   if File.file?(dir+"/"+file)
     contador = 0
     words = openwords(dir+"/"+file)
     words.each do |word|
     word = word.chomp
     contador+=1
     if word=~/#{text}/
       parteuno = dir+"/"+file
       patron = File.basename(__FILE__) 
       if not parteuno=~/#{patron}/
         print "[+] File Found : "+dir+"/"+file+" in line #{contador}\n"
       end        
     end
   end
   else
     if file != "." and file != ".." and file != File.basename(__FILE__) 
       escalar(dir+"/"+file,text)
     end
   end
 end
end

def sintax()
 print "\n[+] sintax : ruby findertext.rb  \n"
end

def head()
 print "\n-- == FinderText 0.1 == --\n\n"
end

def copyright()
 print "\n\n(C) Doddy Hackman 2012\n\n"
end

head()

dir = ARGV[0]
text = ARGV[1]

if !dir and !text
 sintax()
else
 print "\n[+] Starting the search\n\n\n"
 escalar(dir,text)
 print "\n\n[+] Finished\n\n"
end

copyright()
   
# The End ?
 
Status
Not open for further replies.
Back
Top