Class: Subdomain_enum

Inherits:
Object
  • Object
show all
Defined in:
lib/opnsrcint/subdomain_enum.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSubdomain_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_threadObject

Returns the value of attribute max_thread.



20
21
22
# File 'lib/opnsrcint/subdomain_enum.rb', line 20

def max_thread
  @max_thread
end

#targetObject

Returns the value of attribute target.



20
21
22
# File 'lib/opnsrcint/subdomain_enum.rb', line 20

def target
  @target
end

#timeoutObject

Returns the value of attribute timeout.



20
21
22
# File 'lib/opnsrcint/subdomain_enum.rb', line 20

def timeout
  @timeout
end

#wordlistObject

Returns the value of attribute wordlist.



20
21
22
# File 'lib/opnsrcint/subdomain_enum.rb', line 20

def wordlist
  @wordlist
end

Instance Method Details

#brutObject



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


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