|
7 | 7 | require 'support/shared/contexts/msf/util/exe'
|
8 | 8 |
|
9 | 9 | describe Msf::Util::EXE do
|
| 10 | + include_context 'Msf::Simple::Framework#modules loading' |
10 | 11 |
|
11 | 12 | subject do
|
12 | 13 | described_class
|
13 | 14 | end
|
14 | 15 |
|
15 |
| - $framework = Msf::Simple::Framework.create( |
16 |
| - :module_types => [ Msf::MODULE_NOP ], |
17 |
| - 'DisableDatabase' => true |
18 |
| - ) |
19 |
| - |
20 | 16 | describe '.win32_rwx_exec' do
|
21 | 17 | it "should contain the shellcode" do
|
22 | 18 | bin = subject.win32_rwx_exec("asdfjklASDFJKL")
|
|
32 | 28 |
|
33 | 29 | describe '.to_executable_fmt' do
|
34 | 30 | it "should output nil when given a bogus format" do
|
35 |
| - bin = subject.to_executable_fmt($framework, "", "", "", "does not exist", {}) |
| 31 | + bin = subject.to_executable_fmt(framework, "", "", "", "does not exist", {}) |
36 | 32 |
|
37 | 33 | bin.should == nil
|
38 | 34 | end
|
|
41 | 37 |
|
42 | 38 | @platform_format_map.each do |plat, formats|
|
43 | 39 | context "with platform=#{plat}" do
|
| 40 | + if plat == 'windows' |
| 41 | + before(:each) do |
| 42 | + load_and_create_module( |
| 43 | + module_type: 'encoder', |
| 44 | + reference_name: 'x86/shikata_ga_nai' |
| 45 | + ) |
| 46 | + load_and_create_module( |
| 47 | + module_type: 'nop', |
| 48 | + reference_name: 'x86/opty2' |
| 49 | + ) |
| 50 | + end |
| 51 | + end |
| 52 | + |
44 | 53 | let(:platform) do
|
45 | 54 | Msf::Module::PlatformList.transform(plat)
|
46 | 55 | end
|
47 | 56 |
|
48 | 57 | it "should output nil when given bogus format" do
|
49 |
| - bin = subject.to_executable_fmt($framework, formats.first[:arch], platform, "\xcc", "asdf", {}) |
| 58 | + bin = subject.to_executable_fmt(framework, formats.first[:arch], platform, "\xcc", "asdf", {}) |
50 | 59 | bin.should == nil
|
51 | 60 | end
|
52 | 61 | it "should output nil when given bogus arch" do
|
53 |
| - bin = subject.to_executable_fmt($framework, "asdf", platform, "\xcc", formats.first[:format], {}) |
| 62 | + bin = subject.to_executable_fmt(framework, "asdf", platform, "\xcc", formats.first[:format], {}) |
54 | 63 | bin.should == nil
|
55 | 64 | end
|
56 | 65 | [ ARCH_X86, ARCH_X64, ARCH_X86_64, ARCH_PPC, ARCH_MIPSLE, ARCH_MIPSBE, ARCH_ARMLE ].each do |arch|
|
57 | 66 | it "returns nil when given bogus format for arch=#{arch}" do
|
58 |
| - bin = subject.to_executable_fmt($framework, arch, platform, "\xcc", "asdf", {}) |
| 67 | + bin = subject.to_executable_fmt(framework, arch, platform, "\xcc", "asdf", {}) |
59 | 68 | end
|
60 | 69 | end
|
61 | 70 |
|
|
69 | 78 | end
|
70 | 79 |
|
71 | 80 | it "returns an executable when given arch=#{arch}, fmt=#{fmt}" do
|
72 |
| - bin = subject.to_executable_fmt($framework, arch, platform, "\xcc", fmt, {}) |
| 81 | + bin = subject.to_executable_fmt(framework, arch, platform, "\xcc", fmt, {}) |
73 | 82 | bin.should be_a String
|
74 | 83 |
|
75 | 84 | verify_bin_fingerprint(format_hash, bin)
|
|
0 commit comments