Class: Snackhack2::Drupal

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeDrupal

Returns a new instance of Drupal.



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

def initialize
  @site = site
end

Instance Attribute Details

#siteObject

Returns the value of attribute site.



7
8
9
# File 'lib/snackhack2/drupal.rb', line 7

def site
  @site
end

Instance Method Details

#allObject



13
14
15
16
# File 'lib/snackhack2/drupal.rb', line 13

def all
  drupal_score
  user_brute
end

#drupal_scoreObject



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

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

#user_bruteObject



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

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