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-04-04 05:22:26 +00:00
|
|
|
require 'rubygems'
|
|
|
|
require 'pathname'
|
|
|
|
require 'uri'
|
|
|
|
|
2010-04-07 03:32:50 +00:00
|
|
|
$flarebinary = "/home/et/Downloads/flare"
|
|
|
|
$flareoutdir = "/home/et/Downloads/"
|
2010-04-04 05:22:26 +00:00
|
|
|
|
|
|
|
class CrawlerFlash < BaseParser
|
|
|
|
|
|
|
|
|
|
|
|
def parse(request,result)
|
2010-04-07 03:32:50 +00:00
|
|
|
rexp = ['loadMovieNum\(\'(.*?)\'',
|
|
|
|
'loadMovie\(\'(.*?)\'',
|
|
|
|
'getURL\(\'(.*?)\''
|
2010-05-03 17:13:09 +00:00
|
|
|
]
|
|
|
|
|
2010-04-07 03:32:50 +00:00
|
|
|
|
2010-04-04 05:22:26 +00:00
|
|
|
if !result['Content-Type'].include? "application/x-shockwave-flash"
|
|
|
|
return
|
|
|
|
end
|
2010-05-03 17:13:09 +00:00
|
|
|
|
2010-04-04 05:22:26 +00:00
|
|
|
outswf = File.join($flareoutdir,request['uri'].gsub(/\//,'_'))
|
2010-05-03 17:13:09 +00:00
|
|
|
|
|
|
|
puts "Downloading SWF file to: #{outswf}"
|
|
|
|
|
|
|
|
ffile = File.new(outswf, "wb")
|
2010-04-04 05:22:26 +00:00
|
|
|
ffile.puts(result.body)
|
2010-05-03 17:13:09 +00:00
|
|
|
ffile.close
|
2010-04-07 03:32:50 +00:00
|
|
|
|
2010-04-04 05:22:26 +00:00
|
|
|
system("#{$flarebinary} #{outswf}")
|
2010-05-03 17:13:09 +00:00
|
|
|
|
2010-04-04 05:22:26 +00:00
|
|
|
outflr = outswf.gsub('.swf','.flr')
|
2010-05-03 17:13:09 +00:00
|
|
|
|
2010-04-04 05:22:26 +00:00
|
|
|
if File.exists?(outflr)
|
2010-05-03 17:13:09 +00:00
|
|
|
puts "Decompiled SWF file to: #{outflr}"
|
2010-04-04 05:22:26 +00:00
|
|
|
else
|
|
|
|
puts "Error: Decompilation failed."
|
|
|
|
return
|
|
|
|
end
|
2010-05-03 17:13:09 +00:00
|
|
|
|
2010-04-04 05:22:26 +00:00
|
|
|
File.open(outflr, "r") do |infile|
|
|
|
|
while (line = infile.gets)
|
2010-04-07 03:32:50 +00:00
|
|
|
|
2010-05-03 17:13:09 +00:00
|
|
|
rexp.each do |r|
|
|
|
|
links = line.to_s.scan(Regexp.new(r,true)) #"
|
|
|
|
links.each do |link|
|
|
|
|
|
2010-04-04 05:22:26 +00:00
|
|
|
begin
|
2010-04-08 03:40:08 +00:00
|
|
|
hreq = urltohash('GET',link[0],request['uri'],nil)
|
2010-04-04 05:22:26 +00:00
|
|
|
|
|
|
|
insertnewpath(hreq)
|
2010-05-03 17:13:09 +00:00
|
|
|
|
2010-04-04 05:22:26 +00:00
|
|
|
rescue URI::InvalidURIError
|
|
|
|
#puts "Parse error"
|
|
|
|
#puts "Error: #{link[0]}"
|
|
|
|
end
|
2010-05-03 17:13:09 +00:00
|
|
|
end
|
2010-04-04 05:22:26 +00:00
|
|
|
end
|
2010-04-07 03:32:50 +00:00
|
|
|
end
|
2010-05-03 17:13:09 +00:00
|
|
|
end
|
|
|
|
end
|
2010-04-04 05:22:26 +00:00
|
|
|
end
|
|
|
|
|