Files
metasploit-gs/lib/rex/script.rb
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

38 lines
602 B
Ruby
Raw Normal View History

# -*- 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
class Completed < ::RuntimeError
end
2013-08-30 16:28:33 -05:00
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 = ''
2022-03-10 18:03:35 +00:00
buf = ::File.read(file, ::File.size(file), mode: 'rb')
execute(buf, in_binding)
2006-09-19 03:15:25 +00:00
end
2013-08-30 16:28:33 -05:00
2006-09-19 03:15:25 +00:00
#
# Executes arbitrary ruby from the supplied string.
#
def self.execute(str, in_binding = nil)
begin
eval(str, in_binding)
rescue Completed
end
2006-09-19 03:15:25 +00:00
end
end
end