2012-06-29 05:18:28 +00:00
|
|
|
# -*- coding: binary -*-
|
2006-09-19 03:15:25 +00:00
|
|
|
|
|
|
|
module Rex
|
|
|
|
|
|
|
|
###
|
|
|
|
#
|
|
|
|
# This class provides an easy interface for loading and executing ruby
|
|
|
|
# scripts.
|
|
|
|
#
|
|
|
|
###
|
|
|
|
module Script
|
|
|
|
|
2013-08-30 21:28:33 +00:00
|
|
|
class Completed < ::RuntimeError
|
|
|
|
end
|
|
|
|
|
|
|
|
#
|
|
|
|
# Reads the contents of the supplied file and exeutes them.
|
|
|
|
#
|
|
|
|
def self.execute_file(file, in_binding = nil)
|
|
|
|
str = ''
|
|
|
|
buf = ::File.read(file, ::File.size(file))
|
|
|
|
execute(buf, in_binding)
|
|
|
|
end
|
|
|
|
|
|
|
|
#
|
|
|
|
# Executes arbitrary ruby from the supplied string.
|
|
|
|
#
|
|
|
|
def self.execute(str, in_binding = nil)
|
|
|
|
begin
|
|
|
|
eval(str, in_binding)
|
|
|
|
rescue Completed
|
|
|
|
end
|
|
|
|
end
|
2006-09-19 03:15:25 +00:00
|
|
|
|
|
|
|
end
|
|
|
|
|
2009-10-25 20:50:07 +00:00
|
|
|
end
|
2010-02-23 17:59:35 +00:00
|
|
|
|
2010-02-24 23:15:01 +00:00
|
|
|
require 'rex/script/base'
|
2010-02-23 17:59:35 +00:00
|
|
|
require 'rex/script/shell'
|
|
|
|
require 'rex/script/meterpreter'
|
|
|
|
|