Skip to content

Commit

Permalink
more cleanups
Browse files Browse the repository at this point in the history
git-svn-id: file:///home/svn/framework3/trunk@9212 4d416f70-5f16-0410-b530-b9f4589650da
  • Loading branch information
jduck committed May 3, 2010
1 parent df9ec8a commit 0e72894
Show file tree
Hide file tree
Showing 169 changed files with 1,484 additions and 943 deletions.
31 changes: 22 additions & 9 deletions data/msfcrawler/basic.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
##
# $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$

require 'rubygems'
require 'pathname'
require 'hpricot'
Expand All @@ -6,28 +19,28 @@
class CrawlerSimple < BaseParser

def parse(request,result)

if !result['Content-Type'].include? "text/html"
return
end

doc = Hpricot(result.body.to_s)
doc.search('a').each do |link|

hr = link.attributes['href']
if hr and !hr.match(/^(\#|javascript\:)/)

if hr and !hr.match(/^(\#|javascript\:)/)
begin
hreq = urltohash('GET',hr,request['uri'],nil)
hreq = urltohash('GET',hr,request['uri'],nil)

insertnewpath(hreq)

rescue URI::InvalidURIError
#puts "Parse error"
#puts "Error: #{link[0]}"
end
end
end
end
end
end

54 changes: 33 additions & 21 deletions data/msfcrawler/flash.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
##
# $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$

require 'rubygems'
require 'pathname'
require 'uri'


$flarebinary = "/home/et/Downloads/flare"
$flareoutdir = "/home/et/Downloads/"

Expand All @@ -13,52 +25,52 @@ def parse(request,result)
rexp = ['loadMovieNum\(\'(.*?)\'',
'loadMovie\(\'(.*?)\'',
'getURL\(\'(.*?)\''
]
]



if !result['Content-Type'].include? "application/x-shockwave-flash"
return
end

outswf = File.join($flareoutdir,request['uri'].gsub(/\//,'_'))
puts "Downloading SWF file to: #{outswf}"
ffile = File.new(outswf, "wb")

puts "Downloading SWF file to: #{outswf}"

ffile = File.new(outswf, "wb")
ffile.puts(result.body)
ffile.close
ffile.close

system("#{$flarebinary} #{outswf}")

outflr = outswf.gsub('.swf','.flr')

if File.exists?(outflr)
puts "Decompiled SWF file to: #{outflr}"
puts "Decompiled SWF file to: #{outflr}"
else
puts "Error: Decompilation failed."
return
end

File.open(outflr, "r") do |infile|
while (line = infile.gets)

rexp.each do |r|
links = line.to_s.scan(Regexp.new(r,true)) #"
links.each do |link|
rexp.each do |r|
links = line.to_s.scan(Regexp.new(r,true)) #"
links.each do |link|

begin
hreq = urltohash('GET',link[0],request['uri'],nil)

insertnewpath(hreq)

rescue URI::InvalidURIError
#puts "Parse error"
#puts "Error: #{link[0]}"
end
end
end
end
end
end
end
end
end
end

53 changes: 33 additions & 20 deletions data/msfcrawler/forms.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
##
# $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$

require 'rubygems'
require 'pathname'
require 'hpricot'
Expand All @@ -6,11 +19,11 @@
class CrawlerForms < BaseParser

def parse(request,result)

if !result['Content-Type'].include? "text/html"
return
end

hr = ''
m = ''

Expand All @@ -21,44 +34,44 @@ def parse(request,result)
fname = f.attributes['name']
if fname.empty?
fname = "NONE"
end
end

m = "GET"
if !f.attributes['method'].empty?
m = f.attributes['method'].upcase
end
#puts "Parsing form name: #{fname} (#{m})"

#puts "Parsing form name: #{fname} (#{m})"

htmlform = Hpricot(f.inner_html)

arrdata = []

htmlform.search('input').each do |p|
#puts p.attributes['name']
#puts p.attributes['type']
#puts p.attributes['value']
#raw_request has uri_encoding disabled as it encodes '='.
arrdata << (p.attributes['name'] + "=" + Rex::Text.uri_encode(p.attributes['value']))

#raw_request has uri_encoding disabled as it encodes '='.
arrdata << (p.attributes['name'] + "=" + Rex::Text.uri_encode(p.attributes['value']))
end

data = arrdata.join("&").to_s


begin
hreq = urltohash(m,hr,request['uri'],data)

hreq['ctype'] = 'application/x-www-form-urlencoded'

insertnewpath(hreq)


rescue URI::InvalidURIError
#puts "Parse error"
#puts "Error: #{link[0]}"
end
end
end
end
end
end

27 changes: 20 additions & 7 deletions data/msfcrawler/objects.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
##
# $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$

require 'rubygems'
require 'pathname'
require 'hpricot'
Expand All @@ -6,11 +19,11 @@
class CrawlerObjects < BaseParser

def parse(request,result)

if !result['Content-Type'].include? "text/html"
return
end

hr = ''
m = ''

Expand All @@ -21,15 +34,15 @@ def parse(request,result)

begin
hreq = urltohash('GET',s,request['uri'],nil)

insertnewpath(hreq)


rescue URI::InvalidURIError
#puts "Parse error"
#puts "Error: #{link[0]}"
end
end
end
end
end
end

29 changes: 21 additions & 8 deletions data/msfcrawler/scripts.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
##
# $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$

require 'rubygems'
require 'pathname'
require 'hpricot'
Expand All @@ -6,11 +19,11 @@
class CrawlerScripts < BaseParser

def parse(request,result)

if !result['Content-Type'].include? "text/html"
return
end

hr = ''
m = ''

Expand All @@ -20,16 +33,16 @@ def parse(request,result)
s = obj['src']

begin
hreq = urltohash('GET',s,request['uri'],nil)
hreq = urltohash('GET',s,request['uri'],nil)

insertnewpath(hreq)


rescue URI::InvalidURIError
#puts "Parse error"
#puts "Error: #{link[0]}"
end
end
end
end
end
end

4 changes: 4 additions & 0 deletions documentation/samples/framework/dump_module_info.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
#!/usr/bin/env ruby
#
# $Id$
#
# This sample demonstrates how a module's information can be easily serialized
# to a readable format.
#
# $Revision$
#

$:.unshift(File.join(File.dirname(__FILE__), '..', '..', '..', 'lib'))

Expand Down
4 changes: 4 additions & 0 deletions documentation/samples/framework/encode_file.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
#!/usr/bin/env ruby
#
# $Id$
#
# This sample demonstrates how a file can be encoded using a framework
# encoder.
#
# $Revision$
#

$:.unshift(File.join(File.dirname(__FILE__), '..', '..', '..', 'lib'))

Expand Down
4 changes: 4 additions & 0 deletions documentation/samples/framework/enumerate_modules.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
#!/usr/bin/env ruby
#
# $Id$
#
# This sample demonstrates enumerating all of the modules in the framework and
# displays their module type and reference name.
#
# $Revision$
#

$:.unshift(File.join(File.dirname(__FILE__), '..', '..', '..', 'lib'))

Expand Down
Loading

0 comments on commit 0e72894

Please sign in to comment.