handle exception - ResolverArgumentError

bug/bundler_fix
nixawk 2016-01-12 00:48:02 +08:00
parent 408b8fa4fd
commit e491502023
1 changed files with 15 additions and 16 deletions

View File

@ -96,9 +96,9 @@ class Metasploit3 < Msf::Auxiliary
dns.retry_number = datastore['RETRY'] dns.retry_number = datastore['RETRY']
dns.retry_interval = datastore['RETRY_INTERVAL'] dns.retry_interval = datastore['RETRY_INTERVAL']
dns.query(domain, type) dns.query(domain, type)
rescue Errno::ETIMEDOUT rescue ResolverArgumentError, Errno::ETIMEDOUT, ::NoResponseError, ::Timeout::Error => e
rescue ::NoResponseError print_error("Query #{domain} DNS #{type} - exception: #{e}")
rescue ::Timeout::Error return nil
end end
end end
@ -200,7 +200,7 @@ class Metasploit3 < Msf::Auxiliary
report_host(host: ip, name: "#{r.ptr}", info: 'ip reverse') report_host(host: ip, name: "#{r.ptr}", info: 'ip reverse')
print_good("#{ip}: PTR: #{r.ptr} ") print_good("#{ip}: PTR: #{r.ptr} ")
end end
return if records.none? return if records.blank?
records records
end end
@ -215,7 +215,7 @@ class Metasploit3 < Msf::Auxiliary
report_host(host: r.address, name: domain, info: 'A') report_host(host: r.address, name: domain, info: 'A')
print_good("#{domain}: A: #{r.address} ") if datastore['ENUM_BRT'] print_good("#{domain}: A: #{r.address} ") if datastore['ENUM_BRT']
end end
return if records.none? return if records.blank?
records records
end end
@ -229,7 +229,7 @@ class Metasploit3 < Msf::Auxiliary
records << r.cname records << r.cname
print_good("#{domain}: CNAME: #{r.cname}") print_good("#{domain}: CNAME: #{r.cname}")
end end
return if records.none? return if records.blank?
save_loot('ENUM_CNAME', domain, 'text/plain', domain, "#{records.join(',')}", domain) save_loot('ENUM_CNAME', domain, 'text/plain', domain, "#{records.join(',')}", domain)
records records
end end
@ -245,7 +245,7 @@ class Metasploit3 < Msf::Auxiliary
report_host(host: r.nsdname, name: domain, info: 'NS') report_host(host: r.nsdname, name: domain, info: 'NS')
print_good("#{domain}: NS: #{r.nsdname}") print_good("#{domain}: NS: #{r.nsdname}")
end end
return if records.none? return if records.blank?
save_loot('ENUM_NS', 'text/plain', domain, "#{records.join(',')}", domain) save_loot('ENUM_NS', 'text/plain', domain, "#{records.join(',')}", domain)
records records
@ -266,7 +266,7 @@ class Metasploit3 < Msf::Auxiliary
rescue SocketError => e rescue SocketError => e
print_error("Query #{domain} DNS MX - exception: #{e}") print_error("Query #{domain} DNS MX - exception: #{e}")
ensure ensure
return if records.none? return if records.blank?
save_loot('ENUM_MX', 'text/plain', domain, "#{records.join(',')}", domain) save_loot('ENUM_MX', 'text/plain', domain, "#{records.join(',')}", domain)
records records
end end
@ -283,7 +283,7 @@ class Metasploit3 < Msf::Auxiliary
report_host(host: r.mname, info: 'SOA') report_host(host: r.mname, info: 'SOA')
print_good("#{domain}: SOA: #{r.mname}") print_good("#{domain}: SOA: #{r.mname}")
end end
return if records.none? return if records.blank?
save_loot('ENUM_SOA', 'text/plain', domain, "#{records.join(',')}", domain) save_loot('ENUM_SOA', 'text/plain', domain, "#{records.join(',')}", domain)
records records
end end
@ -298,7 +298,7 @@ class Metasploit3 < Msf::Auxiliary
records << r.txt records << r.txt
print_good("#{domain}: TXT: #{r.txt}") print_good("#{domain}: TXT: #{r.txt}")
end end
return if records.none? return if records.blank?
save_loot('ENUM_TXT', 'text/plain', domain, "#{records.join(',')}", domain) save_loot('ENUM_TXT', 'text/plain', domain, "#{records.join(',')}", domain)
records records
end end
@ -346,7 +346,7 @@ class Metasploit3 < Msf::Auxiliary
rescue ArgumentError => e rescue ArgumentError => e
print_error("Query #{domain} DNS TLD - exception: #{e}") print_error("Query #{domain} DNS TLD - exception: #{e}")
ensure ensure
return if records.none? return if records.blank?
report_note( report_note(
host: "#{domain}", host: "#{domain}",
sname: 'dns', sname: 'dns',
@ -392,7 +392,7 @@ class Metasploit3 < Msf::Auxiliary
print_good("#{domain} : SRV: (Host: #{r.host}, Port: #{r.port}, Priority: #{r.priority})") print_good("#{domain} : SRV: (Host: #{r.host}, Port: #{r.port}, Priority: #{r.priority})")
end end
end end
return if records.none? return if records.blank?
save_loot('ENUM_SRV', 'text/plain', domain, "#{records.join(',')}", domain) save_loot('ENUM_SRV', 'text/plain', domain, "#{records.join(',')}", domain)
records records
end end
@ -417,16 +417,15 @@ class Metasploit3 < Msf::Auxiliary
dns.nameservers -= dns.nameservers dns.nameservers -= dns.nameservers
dns.nameservers = "#{r}" dns.nameservers = "#{r}"
zone = dns.axfr(domain) zone = dns.axfr(domain)
rescue Errno::ETIMEDOUT rescue ResolverArgumentError, Errno::ETIMEDOUT, ::NoResponseError, ::Timeout::Error => e
rescue ::NoResponseError print_error("Query #{domain} DNS AXFR - exception: #{e}")
rescue ::Timeout::Error
end end
next if zone.blank? next if zone.blank?
records << "#{zone}" records << "#{zone}"
print_good("#{domain}: Zone Transfer: #{zone}") print_good("#{domain}: Zone Transfer: #{zone}")
end end
end end
return if records.none? return if records.blank?
save_loot('ENUM_AXFR', 'text/plain', domain, "#{records.join(',')}", domain) save_loot('ENUM_AXFR', 'text/plain', domain, "#{records.join(',')}", domain)
records records
end end