git-svn-id: file:///home/svn/incoming/trunk@3273 4d416f70-5f16-0410-b530-b9f4589650da
unstable
Matt Miller 2005-12-30 05:09:45 +00:00
parent 504168eda9
commit da914742fc
3 changed files with 41 additions and 5 deletions

View File

@ -0,0 +1,39 @@
#!/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}")
}

View File

@ -25,7 +25,7 @@ class Opty2 < Msf::Nop
'Arch' => ARCH_X86)
end
def generate_sled(length, opts)
def generate_sled(length, opts = {})
opty = Rex::Nop::Opty2.new(
opts['BadChars'] || '',
opts['SaveRegisters'])

View File

@ -6,9 +6,6 @@ module X86
###
#
# SingleByte
# ----------
#
# This class implements single-byte NOP generation for X86. It takes from
# ADMmutate and from spoonfu.
#
@ -94,7 +91,7 @@ SINGLE_BYTE_SLED =
end
# Generate a single-byte NOP sled for X86
def generate_sled(length, opts)
def generate_sled(length, opts = {})
sled_hash = SINGLE_BYTE_SLED
sled_max_idx = sled_hash.length
sled_cur_idx = 0