使用用net / http编写的现有Ruby脚本作为metasploit辅助

时间:2012-02-17 06:53:39

标签: ruby net-http metasploit

我想使用使用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

1 个答案:

答案 0 :(得分:1)

我建议您查看Github上的Metasploit仓库,了解与您尝试的相似的示例。

https://github.com/rapid7/metasploit-framework

永远不要在Metasploit辅助模块中使用puts。您应该使用注册选项进行用户输入。您可以使用print_line代替puts

有关Metasploit指南的更多信息,请查看:

https://github.com/rapid7/metasploit-framework/blob/master/HACKING