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