lib/wmap/utils/url_magic.rb
# Input is host and open port, output is a URL for valid http response code or nil
Input is host and open port, output is a URL for valid http response code or nil
Input is host and open port output is a URL for valid http response code or nil
def host_2_url (host,port=80)
		puts "Perform simple http(s) service detection on host #{host}, port #{port}" if @verbose
		host=host.strip
		if port.to_i == 80
			url_1 = "http://" + host + "/"
		elsif port.to_i ==443
			url_1 = "https://" + host + "/"
		else
			url_1 = "http://" + host + ":" + port.to_s + "/"
			url_2 = "https://" + host + ":" + port.to_s + "/"
		end
		puts "Please ensure your internet connection is active before running this method: #{__method__}" if @verbose
		checker=Wmap::UrlChecker.new
		if checker.response_code(url_1) != 10000
			puts "Found URL: #{url_1}" if @verbose
			return url_1
		elsif checker.response_code(url_2) != 10000
			puts "Found URL: #{url_2}" if @verbose
			return url_2
		else
			puts "No http(s) service found on: #{host}:#{port}" if @verbose
			return nil
		end
	rescue => ee
		puts "Exception on method #{__method__}: #{ee}" if @verbose
		return nil
	end
def host_2_url ( host , port = 80 ) puts "Perform simple http(s) service detection on host #{host}, port #{port}" if @verbose host = host . strip if port . to_i == 80 url_1 = "http://" + host + "/" elsif port . to_i == 443 url_1 = "https://" + host + "/" else url_1 = "http://" + host + ":" + port . to_s + "/" url_2 = "https://" + host + ":" + port . to_s + "/" end puts "Please ensure your internet connection is active before running this method: #{__method__}" if @verbose checker = Wmap :: UrlChecker . new if checker . response_code ( url_1 ) != 10000 puts "Found URL: #{url_1}" if @verbose return url_1 elsif checker . response_code ( url_2 ) != 10000 puts "Found URL: #{url_2}" if @verbose return url_2 else puts "No http(s) service found on: #{host}:#{port}" if @verbose return nil end rescue => ee puts "Exception on method #{__method__}: #{ee}" if @verbose return nil end
Input is host and open port, output is a URL for valid http response code or nil
Input is host and open port output is a URL for valid http response code or nil
host
<not_specific>
port
<not_specific>