lib/scanner/plugins/dns/generic.rb in yawast-0.6.0 vs lib/scanner/plugins/dns/generic.rb in yawast-0.7.0.beta1

- old
+ new

@@ -19,13 +19,17 @@ host_name = 'N/A' end Yawast::Utilities.puts_info "\t\t#{ip.address} (#{host_name})" + Yawast::Shared::Output.log_value 'dns', 'a', ip.address, host_name + # if address is private, force internal SSL mode, don't show links if IPAddr.new(ip.address.to_s, Socket::AF_INET).private? options.internalssl = true + + Yawast::Shared::Output.log_value 'force_internal_ssl', true else #show network info Yawast::Utilities.puts_info "\t\t\t#{get_network_info(ip.address)}" puts "\t\t\thttps://www.shodan.io/host/#{ip.address}" @@ -43,10 +47,12 @@ host_name = 'N/A' end Yawast::Utilities.puts_info "\t\t#{ip.address} (#{host_name})" + Yawast::Shared::Output.log_value 'dns', 'aaaa', ip.address, host_name + # if address is private, force internal SSL mode, don't show links if IPAddr.new(ip.address.to_s, Socket::AF_INET6).private? options.internalssl = true else #show network info @@ -59,30 +65,40 @@ txt = resv.getresources(uri.host, Resolv::DNS::Resource::IN::TXT) unless txt.empty? txt.each do |rec| Yawast::Utilities.puts_info "\t\tTXT: #{rec.data}" + + Yawast::Shared::Output.log_append_value 'dns', 'txt', uri.host, rec.data end end #check for higher-level TXT records, if we aren't already at the top if root_domain != uri.host - txt = resv.getresources(root_domain, Resolv::DNS::Resource::IN::TXT) - unless txt.empty? - txt.each do |rec| - Yawast::Utilities.puts_info "\t\tTXT (#{root_domain}): #{rec.data}" + begin + txt = resv.getresources(root_domain, Resolv::DNS::Resource::IN::TXT) + unless txt.empty? + txt.each do |rec| + Yawast::Utilities.puts_info "\t\tTXT (#{root_domain}): #{rec.data}" + + Yawast::Shared::Output.log_append_value 'dns', 'txt', root_domain, rec.data + end end + rescue => e + Yawast::Utilities.puts_error "\t\tTXT: #{root_domain} (Error: #{e.message})" end end mx = resv.getresources(uri.host, Resolv::DNS::Resource::IN::MX) unless mx.empty? mx.each do |rec| begin ip = resv.getaddress rec.exchange Yawast::Utilities.puts_info "\t\tMX: #{rec.exchange} (#{rec.preference}) - #{ip} (#{get_network_info(ip.to_s)})" + + Yawast::Shared::Output.log_value 'dns', 'mx', rec.exchange, ip rescue => e Yawast::Utilities.puts_error "\t\tMX: #{rec.exchange} (#{rec.preference}) - Error: #{e.message})" end end end @@ -94,10 +110,12 @@ mx.each do |rec| begin ip = resv.getaddress rec.exchange Yawast::Utilities.puts_info "\t\tMX (#{root_domain}): #{rec.exchange} (#{rec.preference}) - #{ip} (#{get_network_info(ip.to_s)})" + + Yawast::Shared::Output.log_value 'dns', 'mx', rec.exchange, ip rescue => e Yawast::Utilities.puts_error "\t\tMX (#{root_domain}): #{rec.exchange} (#{rec.preference}) - Error: #{e.message})" end end end @@ -107,10 +125,12 @@ unless ns.empty? ns.each do |rec| ip = resv.getaddress rec.name Yawast::Utilities.puts_info "\t\tNS: #{rec.name} - #{ip} (#{get_network_info(ip.to_s)})" + + Yawast::Shared::Output.log_value 'dns', 'ns', rec.name, ip end end if options.srv find_srv root_domain, resv @@ -143,10 +163,12 @@ unless srv.empty? srv.each do |rec| ip = resv.getaddress rec.target Yawast::Utilities.puts_info "\t\tSRV: #{host}: #{rec.target}:#{rec.port} - #{ip} (#{get_network_info(ip.to_s)})" + + Yawast::Shared::Output.log_value 'dns', 'srv', host, "#{rec.target}:#{rec.port}" end end rescue #if this fails, don't really care end @@ -167,10 +189,12 @@ if IPAddr.new(ip.address.to_s, Socket::AF_INET).private? Yawast::Utilities.puts_info "\t\tA: #{host}: #{ip.address}" else Yawast::Utilities.puts_info "\t\tA: #{host}: #{ip.address} (#{get_network_info(ip.address)})" end + + Yawast::Shared::Output.log_value 'dns', 'subdomain', host, ip.address end end rescue #if this fails, don't really care end @@ -191,9 +215,11 @@ begin network_info = Yawast::Shared::Http.get_json URI("https://api.iptoasn.com/v1/as/ip/#{ip}") ret = "#{network_info['as_country_code']} - #{network_info['as_description']}" @netinfo[ip] = ret + + Yawast::Shared::Output.log_value 'dns', 'asn_info', ip, ret return ret rescue => e @netinfo_failed = true return "Error: getting network information failed (#{e.message})"