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