Class: Snackhack2::TomCat

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize ⇒ TomCat

Returns a new instance of TomCat.



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

def initialize
  @site = site
end

Instance Attribute Details

#site ⇒ Object

Returns the value of attribute site.



6
7
8
# File 'lib/snackhack2/tomcat.rb', line 6

def site
  @site
end

Instance Method Details

#run ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/snackhack2/tomcat.rb', line 11

def run
  # adds `/docs/` to the instance variable @site
  tc = Snackhack2.get(@site)
  if tc.headers.has_key?("server")
    if tc.headers['server'].match?("Tomcat")
      puts "[+] Found Tomcat in the site's header... #{tc.headers['server']}\n\n\n"
      tc_body = Snackhack2.get(File.join(@site, '/docs/'))
      if tc_body.code.to_i.eql?(404)
        if tc_body.body.include?('Tomcat')
          doc = Nokogiri::HTML(tc.body)
          # it will then extract the version displayed if
          # the word is found
          begin
            # use to get the version
            version = doc.at('h3').text
            puts "[+] Looks like the site is Tomcat, running #{version}."
          rescue => e
            puts "ERROR: #{e}"
          end
        end
      end
    end
  end
end