2010-05-03 17:13:09 +00:00
|
|
|
##
|
2017-03-13 16:32:56 +00:00
|
|
|
# This module requires Metasploit: http://metasploit.com/download
|
|
|
|
# Current source: https://github.com/rapid7/metasploit-framework
|
2010-05-03 17:13:09 +00:00
|
|
|
##
|
|
|
|
|
2010-03-26 02:39:19 +00:00
|
|
|
require 'pathname'
|
2014-07-16 22:14:07 +00:00
|
|
|
require 'nokogiri'
|
2010-03-26 02:39:19 +00:00
|
|
|
require 'uri'
|
|
|
|
|
|
|
|
class CrawlerForms < BaseParser
|
|
|
|
|
2013-09-30 18:47:53 +00:00
|
|
|
def parse(request,result)
|
2017-03-13 16:32:56 +00:00
|
|
|
return unless result['Content-Type'].include?('text/html')
|
2010-03-26 02:39:19 +00:00
|
|
|
|
2014-07-16 22:14:07 +00:00
|
|
|
doc = Nokogiri::HTML(result.body.to_s)
|
|
|
|
doc.css('form').each do |f|
|
|
|
|
hr = f['action']
|
2010-04-03 05:52:22 +00:00
|
|
|
|
2017-03-13 16:32:56 +00:00
|
|
|
# Removed because unused
|
|
|
|
#fname = f['name']
|
|
|
|
#fname = 'NONE' if fname.empty?
|
2010-05-03 17:13:09 +00:00
|
|
|
|
2017-03-13 16:32:56 +00:00
|
|
|
m = (f['method'].empty? ? 'GET' : f['method'].upcase)
|
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
|
|
|
|
2017-03-13 16:32:56 +00:00
|
|
|
f.css('input').each do |p|
|
2014-07-16 22:14:07 +00:00
|
|
|
arrdata << "#{p['name']}=#{Rex::Text.uri_encode(p['value'])}"
|
2013-09-30 18:47:53 +00:00
|
|
|
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
|
2014-07-16 22:14:07 +00:00
|
|
|
hreq = urltohash(m, hr, request['uri'], data)
|
2013-09-30 18:47:53 +00:00
|
|
|
hreq['ctype'] = 'application/x-www-form-urlencoded'
|
|
|
|
insertnewpath(hreq)
|
|
|
|
rescue URI::InvalidURIError
|
2017-03-13 16:32:56 +00:00
|
|
|
#puts "Parse error"
|
|
|
|
#puts "Error: #{link[0]}"
|
2013-09-30 18:47:53 +00:00
|
|
|
end
|
2017-03-13 16:32:56 +00:00
|
|
|
|
2013-09-30 18:47:53 +00:00
|
|
|
end
|
|
|
|
end
|
2010-03-26 02:39:19 +00:00
|
|
|
end
|
|
|
|
|