Class: Snackhack2::BannerGrabber
- Inherits:
-
Object
- Object
- Snackhack2::BannerGrabber
- Defined in:
- lib/snackhack2/bannergrabber.rb
Instance Attribute Summary collapse
-
#save_file ⇒ Object
Returns the value of attribute save_file.
-
#site ⇒ Object
Returns the value of attribute site.
Instance Method Summary collapse
- #apache2 ⇒ Object
- #curl ⇒ Object
- #headers ⇒ Object
-
#initialize(site, port: 443, save_file: true) ⇒ BannerGrabber
constructor
A new instance of BannerGrabber.
- #nginx ⇒ Object
- #run ⇒ Object
- #server ⇒ Object
- #wordpress ⇒ Object
Constructor Details
#initialize(site, port: 443, save_file: true) ⇒ BannerGrabber
Returns a new instance of BannerGrabber.
8 9 10 11 12 13 |
# File 'lib/snackhack2/bannergrabber.rb', line 8 def initialize(site, port: 443, save_file: true) @site = site @port = port @headers = Snackhack2::get(@site).headers @save_file = save_file end |
Instance Attribute Details
#save_file ⇒ Object
Returns the value of attribute save_file.
6 7 8 |
# File 'lib/snackhack2/bannergrabber.rb', line 6 def save_file @save_file end |
#site ⇒ Object
Returns the value of attribute site.
6 7 8 |
# File 'lib/snackhack2/bannergrabber.rb', line 6 def site @site end |
Instance Method Details
#apache2 ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/snackhack2/bannergrabber.rb', line 50 def apache2 if @headers['server'].match(/Apache/) puts "[+] Server is running Apache2... Now checking #{File.join(@site, "server-status")}..." apache = Snackhack2::get(File.join(@site, "server-status")) if apache.code == 200 puts "Check #{@site}/server-status" else puts "[+] Response Code: #{apache.code}...\n\n" end else puts "Apache2 is not found...\n\n" end end |
#curl ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/snackhack2/bannergrabber.rb', line 38 def curl servers = '' cmd = `curl -s -I #{@site.gsub('https://', '')}` version = cmd.split('Server: ')[1].split("\n")[0].strip if @save_file servers += version.to_s else puts "Banner: #{cmd.split('Server: ')[1].split("\n")[0]}" end Snackhack2::file_save(@site, "serverversion", servers) if @save_file end |
#headers ⇒ Object
71 72 73 74 |
# File 'lib/snackhack2/bannergrabber.rb', line 71 def headers h = Snackhack2::get(@site).headers puts "[+] Server Version: #{h['server']}..." end |
#nginx ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/snackhack2/bannergrabber.rb', line 26 def nginx if @headers['server'].match(/nginx/) puts "[+] Server is running NGINX... Now checking if #{File.join(@site, "nginx_status")} is valid..." nginx = Snackhack2::get(File.join(@site, "nginx_status")) if nginx.code == 200 puts "Check #{@site}/nginx_status" else puts "Response code: #{nginx.code}" end end end |
#run ⇒ Object
19 20 21 22 23 24 |
# File 'lib/snackhack2/bannergrabber.rb', line 19 def run nginx apache2 wordpress headers end |
#server ⇒ Object
76 77 78 |
# File 'lib/snackhack2/bannergrabber.rb', line 76 def server @headers['server'] end |
#wordpress ⇒ Object
64 65 66 67 68 69 |
# File 'lib/snackhack2/bannergrabber.rb', line 64 def wordpress wp = Snackhack2::get(@site).body return unless wp.match(/wp-content/) puts "[+] Wordpress found [+]\n\n\n" end |