Add parsers

git-svn-id: file:///home/svn/framework3/trunk@9441 4d416f70-5f16-0410-b530-b9f4589650da
unstable
et 2010-06-06 03:48:25 +00:00
parent 1337a8483e
commit 334f4915f1
3 changed files with 127 additions and 0 deletions

41
data/msfcrawler/frames.rb Executable file
View File

@ -0,0 +1,41 @@
##
# This file is part of the Metasploit Framework and may be subject to
# redistribution and commercial restrictions. Please see the Metasploit
# Framework web site for more information on licensing and terms of use.
# http://metasploit.com/framework/
##
require 'rubygems'
require 'pathname'
require 'hpricot'
require 'uri'
class CrawlerFrames < BaseParser
def parse(request,result)
if !result['Content-Type'].include? "text/html"
return
end
doc = Hpricot(result.body.to_s)
doc.search('iframe').each do |ifra|
ir = ifra.attributes['src']
if ir and !ir.match(/^(\#|javascript\:)/)
begin
hreq = urltohash('GET',ir,request['uri'],nil)
insertnewpath(hreq)
rescue URI::InvalidURIError
#puts "Error"
end
end
end
end
end

43
data/msfcrawler/image.rb Executable file
View File

@ -0,0 +1,43 @@
##
# This file is part of the Metasploit Framework and may be subject to
# redistribution and commercial restrictions. Please see the Metasploit
# Framework web site for more information on licensing and terms of use.
# http://metasploit.com/framework/
##
# $Revision: 9212 $
require 'rubygems'
require 'pathname'
require 'hpricot'
require 'uri'
class CrawlerImage < BaseParser
def parse(request,result)
if !result['Content-Type'].include? "text/html"
return
end
doc = Hpricot(result.body.to_s)
doc.search('img').each do |i|
im = i.attributes['src']
if im and !im.match(/^(\#|javascript\:)/)
begin
hreq = urltohash('GET',im,request['uri'],nil)
insertnewpath(hreq)
rescue URI::InvalidURIError
#puts "Parse error"
#puts "Error: #{i[0]}"
end
end
end
end
end

43
data/msfcrawler/link.rb Executable file
View File

@ -0,0 +1,43 @@
##
# This file is part of the Metasploit Framework and may be subject to
# redistribution and commercial restrictions. Please see the Metasploit
# Framework web site for more information on licensing and terms of use.
# http://metasploit.com/framework/
##
# $Revision: 9212 $
require 'rubygems'
require 'pathname'
require 'hpricot'
require 'uri'
class CrawlerLink < BaseParser
def parse(request,result)
if !result['Content-Type'].include? "text/html"
return
end
doc = Hpricot(result.body.to_s)
doc.search('link').each do |link|
hr = link.attributes['href']
if hr and !hr.match(/^(\#|javascript\:)/)
begin
hreq = urltohash('GET',hr,request['uri'],nil)
insertnewpath(hreq)
rescue URI::InvalidURIError
#puts "Parse error"
#puts "Error: #{link[0]}"
end
end
end
end
end