lib/wmap/dns_bruter.rb
# Perform zone transfer on a domain, return found host entries in an array
Perform zone transfer on a domain, return found host entries in an array
Perform zone transfer on a domain return found host entries in an array
def zone_transfer(domain)
		puts "Perform zone transfer on zone: #{domain}"
		domain=domain.downcase
		nameservers = get_nameservers(domain)
		hosts=Array.new
		puts "Retrieved name servers: #{nameservers}" if @verbose
		nameservers.each do |nssrv|
			begin
				puts "Attempt zone transfer on name server: #{nssrv}"
				if nssrv.nil?
					abort "Method input variable error: no name server found!" if @verbose
					next
				end
				zt = Dnsruby::ZoneTransfer.new
				zt.server=nssrv unless nssrv.empty?
				records = zt.transfer(domain)
				if records==nil
					puts "Zone transfer failed for zone #{domain} on: #{nssrv}"
					next
				else
					puts "Zone transfer successfully for zone #{domain} on the name server: #{nssrv}"
					records = records.delete_if {|x| not x.to_s=~/(\s+|\t+)IN/ }
					records.each  { |line| puts line.to_s } if @verbose
					hosts=records.collect {|x| x.to_s.split(/\.(\s+|\t+)/).first}
					hosts=hosts.sort!.uniq!
					puts "Found hosts: #{hosts}" if @verbose
					@discovered_hosts_from_dns_bruter[domain] = hosts
					return hosts
				end
			rescue Exception=>ee
				puts "Exception on method #{__method__}: #{ee}" if @verbose
			end
		end
		return hosts
	end
def zone_transfer ( domain ) puts "Perform zone transfer on zone: #{domain}" domain = domain . downcase nameservers = get_nameservers ( domain ) hosts = Array . new puts "Retrieved name servers: #{nameservers}" if @verbose nameservers . each do | nssrv | begin puts "Attempt zone transfer on name server: #{nssrv}" if nssrv . nil? abort "Method input variable error: no name server found!" if @verbose next end zt = Dnsruby :: ZoneTransfer . new zt . server = nssrv unless nssrv . empty? records = zt . transfer ( domain ) if records == nil puts "Zone transfer failed for zone #{domain} on: #{nssrv}" next else puts "Zone transfer successfully for zone #{domain} on the name server: #{nssrv}" records = records . delete_if { | x | not x . to_s =~ / ( \s +| \t +)IN / } records . each { | line | puts line . to_s } if @verbose hosts = records . collect { | x | x . to_s . split ( / \. ( \s +| \t +) / ) . first } hosts = hosts . sort! . uniq! puts "Found hosts: #{hosts}" if @verbose @discovered_hosts_from_dns_bruter [ domain ] = hosts return hosts end rescue Exception => ee puts "Exception on method #{__method__}: #{ee}" if @verbose end end return hosts end
Perform zone transfer on a domain, return found host entries in an array
Perform zone transfer on a domain return found host entries in an array
domain
<not_specific>