Skip to content

Commit e25a8d3

Browse files
committed
Land rapid7#7811, fix autotargeting failure.
2 parents 18347a8 + 4029dbd commit e25a8d3

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

lib/msf/core/exploit/auto_target.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ module Exploit::AutoTarget
1111
def auto_target?
1212
selected_target = targets[target_index]
1313
return false if selected_target.nil?
14-
if selected_target.name =~ /Automatic/ && selected_target['AutoGenerated'] == true
14+
if selected_target.name =~ /Automatic/ && selected_target['AutoGenerated'] == true && auto_target_host
1515
true
1616
else
1717
false

spec/lib/msf/core/exploit/auto_target_spec.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,11 @@
4848

4949
describe '#auto_target?' do
5050
it 'should return true if the automatic target is selected' do
51+
host_addr = '192.168.1.5'
52+
host_obj = FactoryGirl.create(:mdm_host, address: host_addr )
5153
windows_exploit.datastore['TARGET'] = 0
54+
windows_exploit.datastore['WORKSPACE'] = host_obj.workspace.name
55+
windows_exploit.datastore['RHOST'] = host_addr
5256
expect(windows_exploit.auto_target?).to be true
5357
end
5458

0 commit comments

Comments
 (0)