Sinn3r,

 

So, I tested this idea out. The reality is, it does a GET request for each line in a file. So, for a 35 line /etc/passwd, it has to do 35ish get requests. that will take let's say 30ish seconds to run. So, would it be better to not incorporate your idea at all -or- a much longer timeout like this code:

begin

  Timeout.timeout(600) do |i|

    loop do

        #Run this code for 10 minutes max

        file = sqli(left_marker, right_marker, sql_true, i, cookie, filename)

        return if file.nil?

        break if file.empty?

        str = [file].pack("H*")

        full << str

        vprint_status(str)

        i = i+1

    end

  end

rescue Timeout::Error

#Code has been running for more than 10 minutes. Bail.

end

 

 

Chris Hebert

 

From: sinn3r [mailto:notifications@github.com] 
Sent: Monday, May 12, 2014 1:30 AM
To: rapid7/metasploit-framework
Cc: Chris Hebert
Subject: Re: [metasploit-framework] Add module - alienvault_newpolicyform_sqli (#3345)

 

In modules/auxiliary/gather/alienvault_newpolicyform_sqli.rb:

> +
> +    if cookie.blank?
> +      print_error("#{peer} - Could not retrieve the authenticated cookie")
> +      return
> +    end
> +
> +    i = 0
> +    full = ''
> +    filename = datastore['FILEPATH'].unpack("H*")[0]
> +    left_marker = Rex::Text.rand_text_alpha(6)
> +    right_marker = Rex::Text.rand_text_alpha(6)
> +    sql_true = Rex::Text.rand_text_alpha(6)
> +    
> +    print_status("#{peer} - Exploiting SQLi...")
> +
> +    loop do

By reading the code, I feel it's sort of unlikely that you'll actually hit an infinite loop, but it probably wouldn't be a bad idea either to wrap around the loop do block with a Timeout. Just in case?

Code example:

require 'Timeout'
 
begin
    Timeout.timeout(3) do |i|
        loop do
            # Run this code for 3 seconds max
        end
    end
rescue Timeout::Error
    # Weird. That code has been running way to long. Bail.
end

—
Reply to this email directly or view it on GitHub <https://github.com/rapid7/metasploit-framework/pull/3345/files#r12514529> .  <https://github.com/notifications/beacon/2874448__eyJzY29wZSI6Ik5ld3NpZXM6QmVhY29uIiwiZXhwaXJlcyI6MTcxNTQ5MTgyMywiZGF0YSI6eyJpZCI6MzE4NzgzNDl9fQ==--1211e1c36e74c3bf9fb1a83b3fe67cd6edd6d474.gif>