2010-05-03 17:13:09 +00:00
|
|
|
##
|
|
|
|
# $Id$
|
|
|
|
##
|
|
|
|
|
|
|
|
##
|
|
|
|
# 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$
|
|
|
|
|
2010-03-26 02:39:19 +00:00
|
|
|
require 'rubygems'
|
|
|
|
require 'pathname'
|
|
|
|
require 'hpricot'
|
|
|
|
require 'uri'
|
|
|
|
|
|
|
|
class CrawlerForms < BaseParser
|
|
|
|
|
|
|
|
def parse(request,result)
|
2010-05-03 17:13:09 +00:00
|
|
|
|
2010-03-26 02:39:19 +00:00
|
|
|
if !result['Content-Type'].include? "text/html"
|
|
|
|
return
|
|
|
|
end
|
2010-05-03 17:13:09 +00:00
|
|
|
|
2010-03-26 03:15:00 +00:00
|
|
|
hr = ''
|
|
|
|
m = ''
|
2010-03-26 02:39:19 +00:00
|
|
|
|
|
|
|
doc = Hpricot(result.body.to_s)
|
|
|
|
doc.search('form').each do |f|
|
2010-03-26 03:15:00 +00:00
|
|
|
hr = f.attributes['action']
|
2010-04-03 05:52:22 +00:00
|
|
|
|
|
|
|
fname = f.attributes['name']
|
|
|
|
if fname.empty?
|
|
|
|
fname = "NONE"
|
2010-05-03 17:13:09 +00:00
|
|
|
end
|
2010-04-03 05:52:22 +00:00
|
|
|
|
2010-03-26 03:15:00 +00:00
|
|
|
m = "GET"
|
2010-04-03 05:52:22 +00:00
|
|
|
if !f.attributes['method'].empty?
|
|
|
|
m = f.attributes['method'].upcase
|
2010-03-26 03:15:00 +00:00
|
|
|
end
|
2010-05-03 17:13:09 +00:00
|
|
|
|
|
|
|
#puts "Parsing form name: #{fname} (#{m})"
|
|
|
|
|
2010-03-26 02:39:19 +00:00
|
|
|
htmlform = Hpricot(f.inner_html)
|
2010-05-03 17:13:09 +00:00
|
|
|
|
2010-03-26 03:15:00 +00:00
|
|
|
arrdata = []
|
2010-05-03 17:13:09 +00:00
|
|
|
|
2010-03-26 02:39:19 +00:00
|
|
|
htmlform.search('input').each do |p|
|
|
|
|
#puts p.attributes['name']
|
|
|
|
#puts p.attributes['type']
|
|
|
|
#puts p.attributes['value']
|
2010-05-03 17:13:09 +00:00
|
|
|
|
|
|
|
#raw_request has uri_encoding disabled as it encodes '='.
|
|
|
|
arrdata << (p.attributes['name'] + "=" + Rex::Text.uri_encode(p.attributes['value']))
|
2010-03-26 02:39:19 +00:00
|
|
|
end
|
2010-05-03 17:13:09 +00:00
|
|
|
|
2010-03-26 03:15:00 +00:00
|
|
|
data = arrdata.join("&").to_s
|
2010-05-03 17:13:09 +00:00
|
|
|
|
|
|
|
|
2010-03-26 03:15:00 +00:00
|
|
|
begin
|
2010-04-08 03:40:08 +00:00
|
|
|
hreq = urltohash(m,hr,request['uri'],data)
|
2010-05-03 17:13:09 +00:00
|
|
|
|
2010-04-08 03:40:08 +00:00
|
|
|
hreq['ctype'] = 'application/x-www-form-urlencoded'
|
2010-05-03 17:13:09 +00:00
|
|
|
|
2010-03-26 03:15:00 +00:00
|
|
|
insertnewpath(hreq)
|
2010-05-03 17:13:09 +00:00
|
|
|
|
|
|
|
|
2010-03-26 03:15:00 +00:00
|
|
|
rescue URI::InvalidURIError
|
|
|
|
#puts "Parse error"
|
|
|
|
#puts "Error: #{link[0]}"
|
|
|
|
end
|
2010-05-03 17:13:09 +00:00
|
|
|
end
|
|
|
|
end
|
2010-03-26 02:39:19 +00:00
|
|
|
end
|
|
|
|
|