我想使用以下使用 net/http 编写的 ruby 代码作为 metasploit 辅助。
我想知道哪一个可以帮助我轻松地将它转换为 librex 或任何其他支持文件读/写和使用 gsub 进行字符串操作的 metasploit API:
我的代码如下:
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
结尾