Class: Octograb::Octograbber
- Inherits:
-
Object
- Object
- Octograb::Octograbber
- Defined in:
- lib/octograb.rb
Instance Method Summary collapse
-
#initialize(params) ⇒ Octograbber
constructor
A new instance of Octograbber.
- #run ⇒ Object
Constructor Details
#initialize(params) ⇒ Octograbber
Returns a new instance of Octograbber.
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/octograb.rb', line 11 def initialize(params) @threads = params[:threads] || 50 user_agent = params[:useragent] || 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36' @path = params[:path] || '/' @content = params[:content] @inputfile = params[:inputfile] @follow_r = params[:follow_r] || false Typhoeus::Config.user_agent = user_agent end |
Instance Method Details
#run ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 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 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/octograb.rb', line 22 def run File.readlines(@inputfile).each do |line| # do not overload the queue hydra.run if hydra.queued_requests.size > 50 r1 = Typhoeus::Request.new("http://#{line.strip}#{@path}", followlocation: @follow_r, timeout: 1) r1.on_complete do |response| .increment .log "[+] Content match: #{r1.url}".green if response.body.include? @content end r2 = Typhoeus::Request.new("https://#{line.strip}#{@path}", followlocation: @follow_r, ssl_verifyhost: 0, timeout: 1) r2.on_complete do |response| .increment .log "[+] Content match: #{r2.url}".green if response.body.include? @content end hydra.queue(r1) hydra.queue(r2) # check if current line is already an ip address if line.strip =~ Regexp.union(Resolv::IPv4::Regex, Resolv::IPv6::Regex) ? true : false .total -= 2 else begin ip = dns.getaddress(line.strip) r3 = Typhoeus::Request.new("http://#{ip}#{@path}", followlocation: @follow_r, timeout: 1) r3.on_complete do |response| .increment .log "[+] Content match: #{r3.url}".green if response.body.include? @content end r4 = Typhoeus::Request.new("https://#{ip}#{@path}", followlocation: @follow_r, timeout: 1, ssl_verifyhost: 0) r4.on_complete do |response| .increment .log "[+] Content match: #{r4.url}".green if response.body.include? @content end hydra.queue(r3) hydra.queue(r4) rescue StandardError .total -= 2 end end end # run the last "< 50" requests hydra.run end |