Class: Subdomain_enum
- Inherits:
-
Object
- Object
- Subdomain_enum
- Defined in:
- lib/opnsrcint/subdomain_enum.rb
Instance Attribute Summary collapse
-
#max_thread ⇒ Object
Returns the value of attribute max_thread.
-
#target ⇒ Object
Returns the value of attribute target.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
-
#wordlist ⇒ Object
Returns the value of attribute wordlist.
Instance Method Summary collapse
- #brut ⇒ Object
- #get_domain(domain) ⇒ Object
-
#initialize ⇒ Subdomain_enum
constructor
A new instance of Subdomain_enum.
- #loader(list) ⇒ Object
- #print_domain(domain) ⇒ Object
Constructor Details
#initialize ⇒ Subdomain_enum
Returns a new instance of Subdomain_enum.
23 24 25 26 27 |
# File 'lib/opnsrcint/subdomain_enum.rb', line 23 def initialize @timeout = TIME_OUT @max_thread = MAX_THREAD @wordlist = WORDLIST end |
Instance Attribute Details
#max_thread ⇒ Object
Returns the value of attribute max_thread.
20 21 22 |
# File 'lib/opnsrcint/subdomain_enum.rb', line 20 def max_thread @max_thread end |
#target ⇒ Object
Returns the value of attribute target.
20 21 22 |
# File 'lib/opnsrcint/subdomain_enum.rb', line 20 def target @target end |
#timeout ⇒ Object
Returns the value of attribute timeout.
20 21 22 |
# File 'lib/opnsrcint/subdomain_enum.rb', line 20 def timeout @timeout end |
#wordlist ⇒ Object
Returns the value of attribute wordlist.
20 21 22 |
# File 'lib/opnsrcint/subdomain_enum.rb', line 20 def wordlist @wordlist end |
Instance Method Details
#brut ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/opnsrcint/subdomain_enum.rb', line 72 def brut File.open(@wordlist).readlines.map do |line| Thread::new do print_domain( [line.chomp, @target.strip].join(".") ) end sleep 0.03 while Thread::list.length > @max_thread;end end while Thread::list.length > 1;end end |
#get_domain(domain) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/opnsrcint/subdomain_enum.rb', line 41 def get_domain(domain) NAME_SERVERS.keys.shuffle.map do |dns| begin Timeout::timeout(@timeout) do addrs = Resolv::new( loader(NAME_SERVERS[dns]) ).getaddresses(domain) if addrs.length > 0 return addrs end end rescue Timeout::Error => e end end return [] end |
#loader(list) ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/opnsrcint/subdomain_enum.rb', line 29 def loader(list) return Resolv::DefaultResolver.replace_resolvers([ Resolv::Hosts.new, Resolv::DNS.new( nameserver: list, ndots: 1 ) ]) end |
#print_domain(domain) ⇒ Object
65 66 67 68 69 70 |
# File 'lib/opnsrcint/subdomain_enum.rb', line 65 def print_domain(domain) response = get_domain(domain) if response.length > 0 puts "\e[32m#{domain}\e[0m :#{response.join("\e[2m/\e[0m")}" end end |