Do a first clean related to auto_target
parent
57b8b49744
commit
c336133a8e
|
@ -139,35 +139,29 @@ class Metasploit3 < Msf::Exploit::Remote
|
|||
def auto_target
|
||||
print_status("Attempting to automatically select a target...")
|
||||
|
||||
res = query_status()
|
||||
return nil if not res
|
||||
res = query_status
|
||||
return nil unless res
|
||||
|
||||
plat = detect_platform(res.body)
|
||||
arch = detect_arch(res.body)
|
||||
|
||||
# No arch or platform found?
|
||||
if (not arch or not plat)
|
||||
unless arch and plat
|
||||
return nil
|
||||
end
|
||||
|
||||
# see if we have a match
|
||||
targets.each { |t|
|
||||
if (t['Platform'] == plat) and (t['Arch'] == arch)
|
||||
return t
|
||||
end
|
||||
}
|
||||
targets.each { |t| return t if t['Platform'] == plat and t['Arch'] == arch }
|
||||
|
||||
# no matching target found
|
||||
return nil
|
||||
end
|
||||
|
||||
|
||||
|
||||
def exploit
|
||||
mytarget = target
|
||||
if (target.name =~ /Automatic/)
|
||||
mytarget = auto_target
|
||||
if (not mytarget)
|
||||
unless mytarget
|
||||
fail_with(Failure::NoTarget, "Unable to automatically select a target")
|
||||
end
|
||||
print_status("Automatically selected target \"#{mytarget.name}\"")
|
||||
|
@ -305,20 +299,15 @@ class Metasploit3 < Msf::Exploit::Remote
|
|||
handler
|
||||
end
|
||||
|
||||
def query_status()
|
||||
path = normalize_uri(target_uri.path.to_s, '/status')
|
||||
res = send_request_raw(
|
||||
{
|
||||
'uri' => path
|
||||
}, 10)
|
||||
def query_status
|
||||
path = normalize_uri(target_uri.path.to_s, 'status')
|
||||
res = send_request_raw('uri' => path)
|
||||
|
||||
if (not res) or (res.code != 200)
|
||||
print_error("Failed: Error requesting #{path}")
|
||||
unless res and res.code == 200
|
||||
vprint_error("Failed: Error requesting #{path}")
|
||||
return nil
|
||||
end
|
||||
|
||||
vprint_status(res.body)
|
||||
|
||||
return res
|
||||
end
|
||||
|
||||
|
@ -329,12 +318,8 @@ class Metasploit3 < Msf::Exploit::Remote
|
|||
return res
|
||||
end
|
||||
|
||||
def detect_platform(body = nil)
|
||||
if not body
|
||||
res = query_status()
|
||||
return nil if not res
|
||||
body = res.body
|
||||
end
|
||||
def detect_platform(body)
|
||||
return nil if body.blank?
|
||||
|
||||
i=0
|
||||
|
||||
|
@ -363,11 +348,7 @@ class Metasploit3 < Msf::Exploit::Remote
|
|||
end
|
||||
|
||||
def detect_arch(body)
|
||||
if not body
|
||||
res = query_status()
|
||||
return nil if not res
|
||||
body = res.body
|
||||
end
|
||||
return nil if body.blank?
|
||||
|
||||
i=0
|
||||
body.each_line { |ln|
|
||||
|
|
Loading…
Reference in New Issue