1
mirror of https://github.com/rapid7/metasploit-framework synced 2024-11-12 11:52:01 +01:00
metasploit-framework/modules/nops/nop_test.rb.ut.rb
HD Moore abbeb2e87e Adding an Id tag and a standard header to all modules
git-svn-id: file:///home/svn/framework3/trunk@4419 4d416f70-5f16-0410-b530-b9f4589650da
2007-02-18 00:10:39 +00:00

52 lines
1.1 KiB
Ruby

##
# $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/projects/Framework/
##
#!/usr/bin/env ruby
#
# This file tests all x86 nops 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.nops.each_module { |name, mod|
e = mod.new
h = {}
failed = 0
passed = 0
next if (e.arch?(ARCH_X86) == false)
1000.times {
if (off = MachineTest.test(buf = e.generate_sled(64), true))
failed += 1
$stderr.puts("#{name.ljust(25)}: failure at byte #{off}: #{Rex::Text.to_hex(buf)}")
else
passed += 1
end
h[buf] = true
}
$stderr.puts("#{name.ljust(25)}: Passed: #{passed}, Failed: #{failed}, Unique: #{h.keys.length}")
}