Platform handling utilities. I want to protect railgun against changes to client.platform's general form

This commit is contained in:
chao-mu 2012-01-04 21:56:34 -05:00
parent d46379dda2
commit d995c3893b
2 changed files with 55 additions and 0 deletions

View File

@ -0,0 +1,25 @@
module Rex
module Post
module Meterpreter
module Extensions
module Stdapi
module Railgun
module Type
module PlatformUtil
X86_64 = :x86_64
X86_32 = :x86_32
def self.parse_client_platform(meterp_client_platform)
meterp_client_platform =~ /win64/ ? X86_64 : X86_32
end
end # PlatformUtil
end # Type
end # Railgun
end # Stdapi
end # Extensions
end # Meterpreter
end # Post
end # Rex

View File

@ -0,0 +1,30 @@
#!/usr/bin/env ruby
$:.unshift(File.join(File.dirname(__FILE__), '..', '..','..','..','..','..', '..', '..', 'lib'))
require 'rex/post/meterpreter/extensions/stdapi/railgun/type/platform_util'
require 'rex/post/meterpreter/extensions/stdapi/railgun/mock_magic'
require 'test/unit'
module Rex
module Post
module Meterpreter
module Extensions
module Stdapi
module Railgun
module Type
class PlatformUtil::UnitTest < Test::Unit::TestCase
def test_parse_client_platform
assert_equal(PlatformUtil.parse_client_platform('x86/win32'), PlatformUtil::X86_32,
'parse_client_platform should translate Win32 client platforms')
assert_equal(PlatformUtil.parse_client_platform('x86/win64'), PlatformUtil::X86_64,
'parse_client_platform should translate Win64 client platforms')
end
end
end
end
end
end
end
end
end