class Interface
Public Instance Methods
dump()
click to toggle source
# File bin/nmap_http_title_dumper, line 23 def dump() infile = options[:input_file] outfile = options[:output_file] raise "Error: Input file doesn't exist." if !File::exist?(infile) puts puts "Input File: #{infile}".prefix if outfile and File::exist?(outfile) puts print "Output file already exists! Overwrite it? (y/n): " resp = STDIN.gets.chomp() if resp == "n" puts "Execution aborted!".prefix() exit end puts end puts "Output File: #{outfile}".prefix if outfile # parse the input file puts "Parsing the XML file".prefix parser = NmapXML::Parser.new(xml_file: infile) print "Dumping HTTP service information".prefix() if outfile puts " to output file: #{outfile}..." else puts " to stdout..." puts end # open the output file for writing outfile = File::open(outfile, 'w+') if outfile reg = /http_(server|title)/ parser.hosts.each do |host| host_address = host.addresses.by_type(:ipv4) next if !host_address host_address = host_address.address banner = "Host: " + host_address print_and_log(banner.borderize, outfile) host.ports.by_script_id(reg).each do |port| port.service.respond_to?(:tunnel) ? scheme = "https://" : scheme = "http://" port_number = port.number.to_s title, header = nil, nil port.scripts.by_id(reg).each do |script| title = script.output if script.id =~ /title/ header = script.output if script.id =~ /server/ end output = "Raw URL: #{scheme}#{host_address}:#{port_number}" print_and_log(output, outfile) if host.hostnames.count > 1 output = "Potential Vhosts: " hostnames.each {|hn| output += "\n"+scheme+hostname+":"+port_number} print_and_log(output, outfile) end if title or header print_and_log("Server: #{header}", outfile) if header print_and_log("Title: #{title}", outfile) if title else print_and_log("No title or server header available!", outfile) end print_and_log("", outfile) end end puts "Done!".prefix() end
print_and_log(output,outfile)
click to toggle source
# File bin/nmap_http_title_dumper, line 128 def print_and_log(output,outfile) puts output unless outfile outfile.puts(output) if outfile end