Skip to content

Instantly share code, notes, and snippets.

@wchen-r7
Last active August 29, 2015 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wchen-r7/164c40de6cc8a01e5677 to your computer and use it in GitHub Desktop.
Save wchen-r7/164c40de6cc8a01e5677 to your computer and use it in GitHub Desktop.
require 'msf/core'
class Metasploit3 < Msf::Auxiliary
include Msf::Exploit::Remote::HttpClient
def initialize(info = {})
super(update_info(info,
'Name' => 'HttpClient Example',
'Description' => %q{ Do a send_request_cgi() },
'Author' => [ 'sinn3r' ],
'License' => MSF_LICENSE
))
register_options(
[
OptString.new('TARGETURI', [true, 'The base path', '/'])
], self.class)
end
def try_user_defined_timeouts
print_status("Your connection timeout is: #{datastore['ConnectTimeout']}")
print_status("Your response timeout is : #{datastore['RecvTimeout']}")
print_status("Sending request")
send_request_cgi({
'method' => 'GET',
'uri' => target_uri.path
})
end
def try_mod_defined_timeouts
default_conn_timeout = 3 # connectiont imeout
default_res_timeout = 3 # response timeout
print_status("Module defined connection timeout is: #{default_conn_timeout}")
print_status("Module defined response timeout is : #{default_res_timeout}")
send_request_cgi({
'method' => 'GET',
'uri' => target_uri.path,
'connect_timeout' => default_conn_timeout,
'recv_timeout' => default_res_timeout
})
end
def run
print_status("URL: #{target_uri.path}")
start_time = Time.new
begin
res = try_user_defined_timeouts
# res = try_mod_defined_timeouts
rescue ::Exception => e
print_error("#{e.class} #{e.message}")
ensure
end_time = Time.new
print_status("Time spent: #{end_time - start_time}")
print_status("Your response object is: #{res.class.inspect}")
if res
print_status("The HTTP response code is: #{res.code}")
#print_line(res.body)
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment