Skip to content

Commit 919eec2

Browse files
author
us3r777
committed
Refactor auto_target from Jboss mixin
Removed fail_with and targets from the mixin.
1 parent b8ba2dd commit 919eec2

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

lib/msf/http/jboss/base.rb

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,26 +47,28 @@ def http_verb
4747
end
4848

4949

50-
def auto_target
50+
def auto_target(available_targets)
5151
if http_verb == 'HEAD' then
5252
print_status("Sorry, automatic target detection doesn't work with HEAD requests")
5353
else
5454
print_status("Attempting to automatically select a target...")
5555
res = query_serverinfo
5656
if not (plat = detect_platform(res))
57-
fail_with(Failure::NoTarget, 'Unable to detect platform!')
57+
print_warning('Unable to detect platform!')
58+
return nil
5859
end
5960

6061
if not (arch = detect_architecture(res))
61-
fail_with(Failure::NoTarget, 'Unable to detect architecture!')
62+
print_warning('Unable to detect architecture!')
63+
return nil
6264
end
6365

6466
# see if we have a match
65-
targets.each { |t| return t if (t['Platform'] == plat) and (t['Arch'] == arch) }
67+
available_targets.each { |t| return t if (t['Platform'] == plat) and (t['Arch'] == arch) }
6668
end
6769

6870
# no matching target found, use Java as fallback
69-
java_targets = targets.select {|t| t.name =~ /^Java/ }
71+
java_targets = available_targets.select {|t| t.name =~ /^Java/ }
7072
return java_targets[0]
7173
end
7274

modules/exploits/multi/http/jboss_bshdeployer.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def exploit
9696
mytarget = target
9797

9898
if target.name =~ /Automatic/
99-
mytarget = auto_target
99+
mytarget = auto_target(targets)
100100
unless mytarget
101101
fail_with(Failure::NoTarget, "Unable to automatically select a target")
102102
end

modules/exploits/multi/http/jboss_deploymentfilerepository.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def exploit
9393
print_status("Unable to automatically select a target with HEAD requests")
9494
else
9595
if (target.name =~ /Automatic/)
96-
mytarget = auto_target()
96+
mytarget = auto_target(targets)
9797
if (not mytarget)
9898
fail_with(Failure::NoTarget, "Unable to automatically select a target")
9999
end

0 commit comments

Comments
 (0)