2006-09-19 03:15:25 +00:00
|
|
|
#!/usr/bin/env ruby
|
|
|
|
|
|
|
|
module Rex
|
|
|
|
|
|
|
|
###
|
|
|
|
#
|
|
|
|
# This class provides an easy interface for loading and executing ruby
|
|
|
|
# scripts.
|
|
|
|
#
|
|
|
|
###
|
|
|
|
module Script
|
|
|
|
|
2009-10-25 20:50:07 +00:00
|
|
|
class Completed < ::RuntimeError
|
|
|
|
end
|
|
|
|
|
2006-09-19 03:15:25 +00:00
|
|
|
#
|
|
|
|
# Reads the contents of the supplied file and exeutes them.
|
|
|
|
#
|
|
|
|
def self.execute_file(file, in_binding = nil)
|
|
|
|
str = ''
|
2009-10-25 20:50:07 +00:00
|
|
|
buf = ::File.read(file, ::File.size(file))
|
|
|
|
execute(buf, in_binding)
|
2006-09-19 03:15:25 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
#
|
|
|
|
# Executes arbitrary ruby from the supplied string.
|
|
|
|
#
|
|
|
|
def self.execute(str, in_binding = nil)
|
2009-10-25 20:50:07 +00:00
|
|
|
begin
|
|
|
|
eval(str, in_binding)
|
|
|
|
rescue Completed
|
|
|
|
end
|
2006-09-19 03:15:25 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
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'
|
|
|
|
|