ronin-rb / ronin-recon

A micro-framework and tool for performing reconnaissance.
https://ronin-rb.dev
GNU Lesser General Public License v3.0
30 stars 8 forks source link

Add a helper method for handling random network timeouts #89

Open postmodern opened 10 months ago

postmodern commented 10 months ago

It appears that Async::HTTP::Internet.instance can raise an Errno::ETIMEDOUT exception when the connection to the HTTP server times out. We should decide whether to ignore timeouts, or add a helper method that can retry the given block possibly with a sleep(1) delay and incremental counter. Such a helper method could be provided by a Ronin::Recon::Mixins::Retry mixin module.

Pseudocode

def retry_on_timeout(limit: 3, &block)
  retries = 0

  begin
    block.call
   rescue Errno::ETIMEDOUT => error
    sleep(1)
    retries += 1
    if retries > limit
      raise(error)
    else
      retry
    end
  end
end
postmodern commented 10 months ago

Appears there's similar code in lib/ronin/recon/builtin/web/dir_enum.rb. Could extract that code into a Mixin and helper method. https://github.com/ronin-rb/ronin-recon/blob/92b2623eda791e81efe2623fc33fdb834d4aa5bd/lib/ronin/recon/builtin/web/dir_enum.rb#L93-L110

AI-Mozi commented 10 months ago

Should this new Mixin be included in CertSh and DirEnum classes or somewhere higher? Also should it catch Errno::ETIMEDOUT or just StandardError?

AI-Mozi commented 10 months ago

Or should we include it just in CertSh?

postmodern commented 10 months ago

@AI-Mozi that is a good question. I would say only include it where we are currently needing to handle network timeouts and retries.