title: Using existing Ruby script written with net/http as metasploit auxiliary
body: <p>I want to use follwing ruby code written using net/http as metasploit auxiliary.</p>
  
  <p>I want to know which one will help me to convert it easily either librex or any other metasploit API that supports file reading/writing and string manipulation using gsub:</p>
  
  <p>My code is foloowing:</p>
  
  <pre><code>require 'net/http'
  require 'uri'
  
  puts "Enter Target:\n"
  target = URI(gets())
  Net::HTTP.start(target.host, target.port) do |http|
  request = Net::HTTP::Get.new target.request_uri
  response = http.request request 
  puts response.body
  end
  a = target
  puts "File contents:\n"
  f= File.open("fuzz.txt","r")
  outfile = File.new('out.txt','w')
  while line = f.gets do
      line1 = URI.escape("#{line}")
      puts "\n---------------------------------------------\nAttack value: #{line1}"
      newuri = a.to_s.gsub('fuzz',"#{line1}\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
      puts "Attack Request:\n\n#{newuri}\n"
      nuri = URI.parse("#{newuri}")
      outfile.puts "\nAttack Value:#{line1}\nRequest:#{newuri}\n####################\n\n"
      Net::HTTP.start(nuri.host, nuri.port) do |http|
      request = Net::HTTP::Get.new nuri.request_uri
      response = http.request request 
      puts "Attack Response \n\n####################\n\n"
      puts response.body
      outfile.puts response.body
  end
  </code></pre>
  
  <p>end</p>