weee
git-svn-id: file:///home/svn/incoming/trunk@2537 4d416f70-5f16-0410-b530-b9f4589650daunstable
parent
ffeb0f27f7
commit
77688d73b4
|
@ -17,7 +17,7 @@ class Msf::Module::Platform
|
|||
#
|
||||
def self.find_platform(str)
|
||||
# remove any whitespace and downcase
|
||||
str = str.sub(' ', '').downcase
|
||||
str = str.gsub(' ', '').downcase
|
||||
|
||||
mod = Msf::Module::Platform
|
||||
|
||||
|
|
|
@ -10,12 +10,12 @@
|
|||
require 'Msf/Core/Module/Platform'
|
||||
|
||||
class Msf::Module::PlatformList
|
||||
attr_accessor :modules
|
||||
attr_accessor :platforms
|
||||
def initialize(*args)
|
||||
self.modules = [ ]
|
||||
self.platforms = [ ]
|
||||
args.each { |a|
|
||||
if a.kind_of?(String)
|
||||
modules << Msf::Module::Platform.find_platform(a)
|
||||
platforms << Msf::Module::Platform.find_platform(a)
|
||||
elsif a.kind_of?(Range)
|
||||
b = Msf::Module::Platform.find_platform(a.begin)
|
||||
e = Msf::Module::Platform.find_platform(a.end)
|
||||
|
@ -23,17 +23,33 @@ class Msf::Module::PlatformList
|
|||
children = Msf::Module::Platform._find_children(b.superclass)
|
||||
r = (b::Rank .. e::Rank)
|
||||
children.each { |c|
|
||||
modules << c if r.include?(c::Rank)
|
||||
platforms << c if r.include?(c::Rank)
|
||||
}
|
||||
else
|
||||
modules << a
|
||||
platforms << a
|
||||
end
|
||||
|
||||
}
|
||||
end
|
||||
|
||||
def names
|
||||
modules.map { |m| m.name.split('::')[3 .. -1].join(' ') }
|
||||
platforms.map { |m| m.name.split('::')[3 .. -1].join(' ') }
|
||||
end
|
||||
|
||||
# Do I support plist (do I support all of they support?)
|
||||
def supports?(plist)
|
||||
plist.platforms.each { |pl|
|
||||
supported = false
|
||||
platforms.each { |p|
|
||||
if p >= pl
|
||||
supported = true
|
||||
break
|
||||
end
|
||||
}
|
||||
return false if !supported
|
||||
}
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -15,7 +15,7 @@ class Msf::Module::PlatformList::UnitTest < Test::Unit::TestCase
|
|||
assert_equal(
|
||||
[ Msf::Module::Platform::Windows::X86::XP::SP0,
|
||||
Msf::Module::Platform::Windows::X86::XP::SP1
|
||||
], Msf::Module::PlatformList.new('winxpsp0' .. 'winxpsp1').modules
|
||||
], Msf::Module::PlatformList.new('winxpsp0' .. 'winxpsp1').platforms
|
||||
)
|
||||
end
|
||||
|
||||
|
@ -24,6 +24,13 @@ class Msf::Module::PlatformList::UnitTest < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_all
|
||||
assert_equal( [ Msf::Module::Platform ], Msf::Module::PlatformList.new('').modules)
|
||||
assert_equal( [ Msf::Module::Platform ], Msf::Module::PlatformList.new('').platforms)
|
||||
end
|
||||
|
||||
def test_supports
|
||||
l1 = Msf::Module::PlatformList.new('win')
|
||||
l2 = Msf::Module::PlatformList.new('win xp sp0', 'win xp sp2')
|
||||
assert_equal( true, l1.supports?(l2) )
|
||||
assert_equal( false, l2.supports?(l1) )
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue