diff --git a/documentation/plan.txt b/documentation/plan.txt index fac5dae642..b49175535f 100644 --- a/documentation/plan.txt +++ b/documentation/plan.txt @@ -30,6 +30,9 @@ X - stack requirements X - make payload prepend target specific X - sessions X - logging session activity + - module load caching + - switch to demand loaded modules rather than always loading + - should make things faster - modules needing ports (above other modules) - encoders - shikata diff --git a/lib/msf/core/encoder.rb b/lib/msf/core/encoder.rb index 84458a99df..af630360c8 100644 --- a/lib/msf/core/encoder.rb +++ b/lib/msf/core/encoder.rb @@ -193,7 +193,7 @@ class Encoder < Module # Copy the decoder stub since we may need to modify it stub = decoder_stub(state).dup - if (state.key != nil and decoder_key_offset) + if (state.key != nil and state.decoder_key_offset) # Substitute the decoder key in the copy of the decoder stub with the # one that we found stub[state.decoder_key_offset,state.decoder_key_size] = [ state.key.to_i ].pack(state.decoder_key_pack) diff --git a/lib/msf/core/module_manager.rb b/lib/msf/core/module_manager.rb index 01f4a29d53..91a490160b 100644 --- a/lib/msf/core/module_manager.rb +++ b/lib/msf/core/module_manager.rb @@ -400,6 +400,12 @@ protected # Try to load modules from all the files in the supplied path Find.find(path) { |file| + # Skip unit test files + next if (file =~ /rb\.ut\.rb$/) + + # Skip test-suite files + next if (file =~ /rb\.ts\.rb$/) + begin load_module_from_file(path, file, loaded, recalc, counts) diff --git a/modules/encoders/generic/none.rb.ut.rb b/modules/encoders/generic/none.rb.ut.rb new file mode 100644 index 0000000000..fde902fa56 --- /dev/null +++ b/modules/encoders/generic/none.rb.ut.rb @@ -0,0 +1,29 @@ +#!/usr/bin/ruby + +$:.unshift(File.join(File.dirname(__FILE__), '..', '..', '..', 'lib')) + +require 'test/unit' +require 'rex/ui' +require 'msf/core' +require 'none' + +class Msf::Encoders::Generic::None::UnitTest < Test::Unit::TestCase + + Klass = Msf::Encoders::Generic::None + + def test_encoder + + k = Klass.new + + [ + "\x41\x42\x43\x44", + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + ].each { |raw| + assert_equal( + raw, k.encode(raw, '') + ) + } + + end + +end diff --git a/modules/encoders/x86/call4_dword_xor.rb.ut.rb b/modules/encoders/x86/call4_dword_xor.rb.ut.rb new file mode 100644 index 0000000000..e03dca2e1e --- /dev/null +++ b/modules/encoders/x86/call4_dword_xor.rb.ut.rb @@ -0,0 +1,44 @@ +#!/usr/bin/ruby + +$:.unshift(File.join(File.dirname(__FILE__), '..', '..', '..', 'lib')) + +require 'test/unit' +require 'rex/ui' +require 'msf/core' +require 'call4_dword_xor' + +class Msf::Encoders::X86::Call4Dword::UnitTest < Test::Unit::TestCase + + Klass = Msf::Encoders::X86::Call4Dword + + def test_encoder + + k = Klass.new + + { + "\x41\x42\x43\x44" => + [ + "\x29\xc9\x83\xe9\xff\xe8\xff\xff\xff\xff\xc0\x5e\x81\x76" + + "\x0e\x66\x30\x86\x84\x83\xee\xfc\xe2\xf4\x27\x72\xc5\xc0", + 0x84863066 + ], + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" => + [ + "\x29\xc9\x83\xe9\xf9\xe8\xff\xff\xff\xff\xc0\x5e\x81\x76" + + "\x0e\xad\x6c\x5d\xb4\x83\xee\xfc\xe2\xf4\xec\x2e\x1e\xf0" + + "\xe8\x2a\x1a\xfc\xe4\x26\x16\xf8\xe0\x22\x12\xe4\xfc\x3e" + + "\x0e\xe0\xf8\x3a\x0a\xec\xf4\x36\x5d\xb4", + 0xb45d6cad, + 2 + ] + }.each_pair { |raw, real| + offset = real[2] || 0 + + encoded = k.encode(raw, '', Msf::EncoderState.new(real[1])) + + assert_equal(real[0][offset, -1], encoded[offset, -1]) + } + + end + +end diff --git a/modules/encoders/x86/jmp_call_additive.rb.ut.rb b/modules/encoders/x86/jmp_call_additive.rb.ut.rb new file mode 100644 index 0000000000..eaf4b5db4c --- /dev/null +++ b/modules/encoders/x86/jmp_call_additive.rb.ut.rb @@ -0,0 +1,42 @@ +#!/usr/bin/ruby + +$:.unshift(File.join(File.dirname(__FILE__), '..', '..', '..', 'lib')) + +require 'test/unit' +require 'rex/ui' +require 'msf/core' +require 'jmp_call_additive' + +class Msf::Encoders::X86::JmpCallAdditive::UnitTest < Test::Unit::TestCase + + Klass = Msf::Encoders::X86::JmpCallAdditive + + def test_encoder + + k = Klass.new + + { + "\x41\x42\x43\x44" => + [ + "\xfc\xbb\x99\x65\xdb\xf5\xeb\x0c\x5e\x56\x31\x1e\xad\x01" + + "\xc3\x85\xc0\x75\xf7\xc3\xe8\xef\xff\xff\xff\xd8\x27\x98" + + "\xb1", + 0xf5db6599 + ], + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" => + [ + "\xfc\xbb\xb7\x2c\xb5\x03\xeb\x0c\x5e\x56\x31\x1e\xad\x01" + + "\xc3\x85\xc0\x75\xf7\xc3\xe8\xef\xff\xff\xff\xf6\x6e\xf6" + + "\x47\xbd\x28\xbf\x0f\x74\xff\x74\xdc\xcb\xb1\xc5\x8c\x82" + + "\x1f\x89\x78\x71\xf6\x7a\xd9\x20\xac\x84\xd9", + 0x03b52cb7 + ] + }.each_pair { |raw, real| + encoded = k.encode(raw, '', Msf::EncoderState.new(real[1])) + + assert_equal(real[0], encoded) + } + + end + +end