2008-10-09 03:57:28 +00:00
|
|
|
#!/usr/bin/env ruby
|
2010-05-03 17:13:09 +00:00
|
|
|
#
|
|
|
|
# $Id$
|
|
|
|
# $Revision$
|
|
|
|
#
|
2008-10-09 03:57:28 +00:00
|
|
|
|
|
|
|
path = ARGV.shift || exit
|
|
|
|
data = File.read(path)
|
|
|
|
outp = ""
|
|
|
|
|
|
|
|
endc = 0
|
|
|
|
data.each_line do |line|
|
|
|
|
if(line =~ /^\s*module\s+[A-Z]/)
|
|
|
|
endc += 1
|
|
|
|
next
|
|
|
|
end
|
|
|
|
|
|
|
|
if(line =~ /^(\s*)include (.*)/)
|
2008-10-13 04:23:07 +00:00
|
|
|
spaces = $1
|
|
|
|
inc = $2
|
|
|
|
if (inc !~ /Msf/)
|
|
|
|
line = "#{spaces}include Msf::#{inc.strip}\n"
|
|
|
|
end
|
2008-10-09 03:57:28 +00:00
|
|
|
end
|
2010-05-03 17:13:09 +00:00
|
|
|
|
2008-10-09 03:57:28 +00:00
|
|
|
if(line =~ /^(\s*)class ([^\<]+)\s*<\s*(.*)/)
|
|
|
|
prefix = ""
|
|
|
|
spaces = $1
|
|
|
|
parent = $3
|
2010-05-03 17:13:09 +00:00
|
|
|
|
2008-10-09 03:57:28 +00:00
|
|
|
if(parent !~ /^Msf/)
|
|
|
|
prefix = "Msf::"
|
|
|
|
end
|
|
|
|
line = "#{spaces}class Metasploit3 < #{prefix}#{parent.strip}\n"
|
|
|
|
end
|
2010-05-03 17:13:09 +00:00
|
|
|
|
2008-10-09 03:57:28 +00:00
|
|
|
outp += line
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
endc.downto(1) do |idx|
|
|
|
|
i = outp.rindex("end")
|
2008-10-10 02:47:23 +00:00
|
|
|
outp[i, 4] = "" if i
|
2008-10-09 03:57:28 +00:00
|
|
|
end
|
|
|
|
|
2008-10-10 02:47:23 +00:00
|
|
|
outp.rstrip!
|
2008-10-10 03:05:30 +00:00
|
|
|
outp << "\n"
|
2008-10-10 02:47:23 +00:00
|
|
|
|
2008-10-09 03:57:28 +00:00
|
|
|
fd = File.open(path, "w")
|
|
|
|
fd.write(outp)
|
2008-10-19 21:03:39 +00:00
|
|
|
fd.close
|