Class: Snackhack2::Drupal

Inherits:
Object
  • Object
show all
Defined in:
lib/snackhack2/drupal.rb

Instance Method Summary collapse

Constructor Details

#initialize(site) ⇒ Drupal

Returns a new instance of Drupal.



5
6
7
# File 'lib/snackhack2/drupal.rb', line 5

def initialize(site)
  @site = site
end

Instance Method Details

#allObject



9
10
11
12
# File 'lib/snackhack2/drupal.rb', line 9

def all
  drupal_score
  user_brute
end

#drupal_scoreObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/snackhack2/drupal.rb', line 14

def drupal_score
  drupal_score = 0
  d = Snackhack2::get(@site)
  if d.code == 200
    d.headers.each do |k|
      if k.include?("drupal")
        drupal_score += 10
      end
    end
  end
  d.headers.each do |v|
    if v.include?("drupal")
      drupal_score += 10
    end
  end
  doc = Nokogiri::HTML(URI.open(@site))
  posts = doc.xpath('//meta')
  posts.each do |l|
    if l.attributes['content'].to_s.include?("Drupal")
      puts "[+] Drupal Version: #{l.attributes['content']}\n"
    end
  end
  puts "Drupal Score: #{drupal_score}"
end

#user_bruteObject



39
40
41
42
43
44
45
46
47
# File 'lib/snackhack2/drupal.rb', line 39

def user_brute
  for user in 1..1000 do
    u = Snackhack2::get(File.join(@site, "user", user.to_s)).body
    if u.include?("Page not found")
      puts "User count: #{user - 1}"
      break
    end
  end
end