Mirror of metasploit
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

basic.rb 936B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. ##
  2. # $Id$
  3. ##
  4. ##
  5. # This file is part of the Metasploit Framework and may be subject to
  6. # redistribution and commercial restrictions. Please see the Metasploit
  7. # Framework web site for more information on licensing and terms of use.
  8. # http://metasploit.com/framework/
  9. ##
  10. # $Revision$
  11. require 'rubygems'
  12. require 'pathname'
  13. require 'nokogiri'
  14. require 'uri'
  15. class CrawlerSimple < BaseParser
  16. def parse(request,result)
  17. if !result['Content-Type'].include? "text/html"
  18. return
  19. end
  20. # doc = Hpricot(result.body.to_s)
  21. doc = Nokogiri::HTML(result.body.to_s)
  22. doc.css('a').each do |anchor_tag|
  23. hr = anchor_tag['href']
  24. if hr && !hr.match(/^(\#|javascript\:)/)
  25. begin
  26. hreq = urltohash('GET', hr, request['uri'], nil)
  27. insertnewpath(hreq)
  28. rescue URI::InvalidURIError
  29. #puts "Parse error"
  30. #puts "Error: #{link[0]}"
  31. end
  32. end
  33. end
  34. end
  35. end