Skip to content

Commit

Permalink
Fix encoded payloads test
Browse files Browse the repository at this point in the history
  • Loading branch information
dwelch-r7 committed Jan 16, 2024
1 parent 2cf045d commit 1c4258f
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/msf/core/encoded_payload.rb
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ def encode

begin
eout = self.encoder.encode(eout, reqs['BadChars'], nil, pinst.platform)
rescue EncodingError
rescue EncodingError => e
wlog("#{err_start}: Encoder #{encoder.refname} failed: #{$!}", 'core', LEV_1)
dlog("#{err_start}: Call stack\n#{$@.join("\n")}", 'core', LEV_3)
next_encoder = true
Expand Down
5 changes: 5 additions & 0 deletions spec/lib/msf/core/encoded_payload_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
module_type: 'encoder',
modules_path: modules_path,
)
allow(framework.encoders).to receive(:each_module_ranked)
.and_yield('x86/shikata_ga_nai', framework.encoders['x86/shikata_ga_nai'])
.and_yield('x86/xor_dynamic', framework.encoders['x86/xor_dynamic'])
.and_yield('x86/call4_dword_xor', framework.encoders['x86/call4_dword_xor'])
.and_yield('generic/none', framework.encoders['generic/none'])
end

let(:ancestor_reference_names) {
Expand Down
2 changes: 1 addition & 1 deletion spec/lib/msf/core/module_set_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@
end
end

describe 'create' do
describe '#create' do
let(:module_refname) { 'module_refname' }
let(:framework) { instance_double(Msf::Framework) }
let(:module_manager) { instance_double(Msf::ModuleManager) }
Expand Down
2 changes: 1 addition & 1 deletion test/modules/post/test/all.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def select_available_modules
session_type = session.type

module_results = []
framework.modules.post.module_refnames.each do | refname |
framework.modules.post.module_refnames.each do |refname|
next unless refname.start_with?('test/') && refname != self.refname
mod = framework.modules.create(refname)

Expand Down
2 changes: 1 addition & 1 deletion tools/modules/module_ports.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

# Initialize the simplified framework instance.
$framework = Msf::Simple::Framework.create('DisableDatabase' => true)
# TODO: this is weird, merging module sets together for different module types could lead to unforseen issues
# XXX: this is weird, merging module sets together for different module types could lead to unforseen issues
all_modules = $framework.exploits.merge($framework.auxiliary)
all_ports = {}

Expand Down

0 comments on commit 1c4258f

Please sign in to comment.