metasploit-framework/lib/msf/core/payload/ruby.rb

40 lines
898 B
Ruby
Raw Normal View History

# -*- coding: binary -*-
require 'msf/core'
module Msf::Payload::Ruby
2013-08-30 21:28:33 +00:00
def initialize(info = {})
super(info)
2013-08-30 21:28:33 +00:00
register_advanced_options(
[
# Since space restrictions aren't really a problem, default this to
# true.
Msf::OptBool.new('PrependFork', [ false, "Start the payload in its own process via fork or popen", "true" ])
]
)
end
2013-08-30 21:28:33 +00:00
def prepends(buf)
if datastore['PrependFork']
buf = %Q^
code = %(#{ Rex::Text.encode_base64(buf) }).unpack(%(m0)).first
if RUBY_PLATFORM =~ /mswin|mingw|win32/
inp = IO.popen(%(ruby), %(wb)) rescue nil
if inp
inp.write(code)
inp.close
end
else
if ! Process.fork()
eval(code) rescue nil
end
end
^.strip.split(/\n/).map{|line| line.strip}.join("\n")
end
2013-08-30 21:28:33 +00:00
buf
end
end