determine most precise filter
drop back to our most precise level of filtering MS-2325bug/bundler_fix
parent
201b65e43d
commit
1afc57da40
|
@ -15,9 +15,7 @@ module Msf
|
|||
return nil unless auto_target?
|
||||
host_record = target_host
|
||||
return nil if host_record.nil?
|
||||
filtered_by_family = filter_by_os_family(host_record)
|
||||
filtered_by_name = filter_by_os_name(filtered_by_family, host_record)
|
||||
filtered_by_sp = filter_by_os_sp(filtered_by_name,host_record)
|
||||
|
||||
end
|
||||
|
||||
def target_host
|
||||
|
@ -27,6 +25,17 @@ module Msf
|
|||
current_workspace.hosts.where(address: rhost).first
|
||||
end
|
||||
|
||||
def filter_by_os(host_record)
|
||||
filtered_by_family = filter_by_os_family(host_record)
|
||||
filtered_by_name = filter_by_os_name(filtered_by_family, host_record)
|
||||
# If Filtering by name gave us no results, then we reset back to the family filter group
|
||||
filtered_by_name = filtered_by_family if filtered_by_name.empty?
|
||||
filtered_by_sp = filter_by_os_sp(filtered_by_name,host_record)
|
||||
# If Filtering by SP was a bust, revert back one level
|
||||
filtered_by_sp = filtered_by_name if filtered_by_sp.empty?
|
||||
filtered_by_sp
|
||||
end
|
||||
|
||||
def filter_by_os_family(host_record)
|
||||
return [] if host_record.os_family.blank?
|
||||
filtered_targets = targets.collect do |target|
|
||||
|
|
|
@ -116,6 +116,16 @@ RSpec.describe Msf::Exploit::AutoTarget do
|
|||
|
||||
end
|
||||
|
||||
context '#filter_by_os' do
|
||||
it 'should return an array of matching targets' do
|
||||
expect(windows_exploit.filter_by_os(windows_xp_sp1_host)).to eq [xp_targets[0]]
|
||||
end
|
||||
|
||||
it 'should fall back to previous filter levels if a more strict filter did not return results' do
|
||||
expect(windows_exploit.filter_by_os(windows_xp_host)).to eq xp_targets
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue