2007-02-18 00:10:39 +00:00
|
|
|
##
|
2007-04-21 01:53:49 +00:00
|
|
|
# $Id$
|
2007-02-18 00:10:39 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
##
|
2010-04-30 08:40:19 +00:00
|
|
|
# This file is part of the Metasploit Framework and may be subject to
|
2007-02-18 00:10:39 +00:00
|
|
|
# redistribution and commercial restrictions. Please see the Metasploit
|
2012-02-21 01:40:50 +00:00
|
|
|
# web site for more information on licensing and terms of use.
|
|
|
|
# http://metasploit.com/
|
2007-02-18 00:10:39 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
|
2005-12-30 04:57:52 +00:00
|
|
|
#!/usr/bin/env ruby
|
|
|
|
#
|
|
|
|
# This file tests all x86 encoders to ensure that they execute correctly.
|
|
|
|
#
|
|
|
|
|
|
|
|
$:.unshift(File.join(File.dirname(__FILE__), '..', '..', 'lib'))
|
|
|
|
$:.unshift(File.join(File.dirname(__FILE__), '..', '..', 'dev', 'machinetest'))
|
|
|
|
|
|
|
|
require 'rex'
|
|
|
|
require 'msf/core'
|
|
|
|
require 'msf/base'
|
|
|
|
require 'machinetest'
|
|
|
|
|
|
|
|
$framework = Msf::Simple::Framework.create
|
|
|
|
|
|
|
|
$framework.encoders.each_module { |name, mod|
|
|
|
|
e = mod.new
|
|
|
|
h = {}
|
|
|
|
failed = 0
|
|
|
|
passed = 0
|
|
|
|
|
|
|
|
next if (e.arch?(ARCH_X86) == false)
|
|
|
|
|
|
|
|
1000.times {
|
|
|
|
|
2007-04-21 01:53:49 +00:00
|
|
|
if (rv = MachineTest.testraw(buf = e.to_native(e.encode("\xcc"))))
|
2005-12-30 04:57:52 +00:00
|
|
|
failed += 1
|
2007-04-21 01:53:49 +00:00
|
|
|
$stderr.puts("#{name.ljust(25)}[off=#{rv}]: failure: #{Rex::Text.to_hex(buf)}")
|
2005-12-30 04:57:52 +00:00
|
|
|
else
|
|
|
|
passed += 1
|
|
|
|
end
|
|
|
|
|
|
|
|
h[buf] = true
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
$stderr.puts("#{name.ljust(25)}: Passed: #{passed}, Failed: #{failed}, Unique: #{h.keys.length}")
|
|
|
|
|
2010-04-30 08:40:19 +00:00
|
|
|
}
|