2005-12-17 06:46:23 +00:00
|
|
|
#!/usr/bin/env ruby
|
2005-11-28 14:26:33 +00:00
|
|
|
#
|
2010-05-03 17:13:09 +00:00
|
|
|
# $Id$
|
|
|
|
#
|
2005-11-28 14:26:33 +00:00
|
|
|
# This sample demonstrates how a file can be encoded using a framework
|
|
|
|
# encoder.
|
|
|
|
#
|
2010-05-03 17:13:09 +00:00
|
|
|
# $Revision$
|
|
|
|
#
|
2005-11-28 14:26:33 +00:00
|
|
|
|
|
|
|
$:.unshift(File.join(File.dirname(__FILE__), '..', '..', '..', 'lib'))
|
|
|
|
|
|
|
|
require 'msf/base'
|
|
|
|
|
|
|
|
if (ARGV.empty?)
|
2013-09-30 18:47:53 +00:00
|
|
|
puts "Usage: #{File.basename(__FILE__)} encoder_name file_name format"
|
|
|
|
exit
|
2005-11-28 14:26:33 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
framework = Msf::Simple::Framework.create
|
|
|
|
|
|
|
|
begin
|
2013-09-30 18:47:53 +00:00
|
|
|
# Create the encoder instance.
|
|
|
|
mod = framework.encoders.create(ARGV.shift)
|
2005-11-28 14:26:33 +00:00
|
|
|
|
2013-09-30 18:47:53 +00:00
|
|
|
puts(Msf::Simple::Buffer.transform(
|
|
|
|
mod.encode(IO.read(ARGV.shift)), ARGV.shift || 'ruby'))
|
2005-11-28 14:26:33 +00:00
|
|
|
rescue
|
2013-09-30 18:47:53 +00:00
|
|
|
puts "Error: #{$!}\n\n#{$@.join("\n")}"
|
2005-11-28 14:26:33 +00:00
|
|
|
end
|