Class: Snackhack2::Subdomains2
- Inherits:
-
Object
- Object
- Snackhack2::Subdomains2
- Defined in:
- lib/snackhack2/subdomains2.rb
Instance Attribute Summary collapse
-
#site ⇒ Object
Returns the value of attribute site.
Instance Method Summary collapse
- #fetch(url) ⇒ Object
-
#initialize ⇒ Subdomains2
constructor
A new instance of Subdomains2.
- #run ⇒ Object
- #save ⇒ Object
- #wordlist ⇒ Object
Constructor Details
#initialize ⇒ Subdomains2
Returns a new instance of Subdomains2.
7 8 9 10 |
# File 'lib/snackhack2/subdomains2.rb', line 7 def initialize @site = site @urls = [] end |
Instance Attribute Details
#site ⇒ Object
Returns the value of attribute site.
6 7 8 |
# File 'lib/snackhack2/subdomains2.rb', line 6 def site @site end |
Instance Method Details
#fetch(url) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/snackhack2/subdomains2.rb', line 32 def fetch(url) Sync do |task| task.with_timeout(2) do internet = Async::HTTP::Internet.new m = internet.get(url, { 'user-agent' => Snackhack2::UA }) # only adds it to the @url instance variable if # it returns a status code of `200` OR `301` @urls << url if (m.status == 200) || (m.status == 301) m.read end end rescue StandardError => e puts e end |
#run ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/snackhack2/subdomains2.rb', line 20 def run File.readlines(wordlist).each do |a| # removes `https://` from the instance variable # `@site`. Adds the subdomain from the file to test if it is valid url = "https://#{a.strip}.#{@site.gsub('https://', '')}" fetch(url) puts url end save end |
#save ⇒ Object
16 17 18 |
# File 'lib/snackhack2/subdomains2.rb', line 16 def save Snackhack2.file_save(@site, 'subdomain_brute2', @urls.join("\n")) end |
#wordlist ⇒ Object
12 13 14 |
# File 'lib/snackhack2/subdomains2.rb', line 12 def wordlist File.join(__dir__, 'lists', 'subdomains.txt') end |