8e5cf31e9a
NOTE: These changes specifically affect payload encoding via RPC, "use payload", and msfencode 1. consolidate user-specified exe generation routine (now Msf::Util::EXE.to_executable_fmt) 2. supported format types are now queried/checked using arrays 3. cleaned up and standardized exe option passing 4. rename data store options for EXE mixin 5. add generate_payload_exe_service for psexec/smb_relay 6. reworked default template handling in Msf::Util::EXE a. added template search path option (not used if template includes a path separator) b. "fallback" flag to enable using default if specified file doesn't exist 7. added Msf::Util::EXE.to_win64pe_dll 8. improved error messages from exe generation git-svn-id: file:///home/svn/framework3/trunk@10404 4d416f70-5f16-0410-b530-b9f4589650da
80 lines
1.5 KiB
Ruby
80 lines
1.5 KiB
Ruby
##
|
|
# $Id$
|
|
##
|
|
|
|
require 'msf/base'
|
|
|
|
module Msf
|
|
module Simple
|
|
|
|
###
|
|
#
|
|
# Wraps interaction with a generated buffer from the framework.
|
|
# Its primary use is to transform a raw buffer into another
|
|
# format.
|
|
#
|
|
###
|
|
module Buffer
|
|
|
|
#
|
|
# Serializes a buffer to a provided format. The formats supported are raw,
|
|
# ruby, perl, c, js_be, js_le and java
|
|
#
|
|
def self.transform(buf, fmt = "ruby")
|
|
case fmt
|
|
when 'raw'
|
|
when 'ruby', 'rb'
|
|
buf = Rex::Text.to_ruby(buf)
|
|
when 'perl', 'pl'
|
|
buf = Rex::Text.to_perl(buf)
|
|
when 'c'
|
|
buf = Rex::Text.to_c(buf)
|
|
when 'js_be'
|
|
buf = Rex::Text.to_unescape(buf, ENDIAN_BIG)
|
|
when 'js_le'
|
|
buf = Rex::Text.to_unescape(buf, ENDIAN_LITTLE)
|
|
when 'java'
|
|
buf = Rex::Text.to_java(buf)
|
|
else
|
|
raise ArgumentError, "Unsupported buffer format: #{fmt}", caller
|
|
end
|
|
|
|
return buf
|
|
end
|
|
|
|
#
|
|
# Creates a comment using the supplied format. The formats supported are
|
|
# raw, ruby, perl, js_be, js_le, c, and java.
|
|
#
|
|
def self.comment(buf, fmt = "ruby")
|
|
case fmt
|
|
when 'raw'
|
|
when 'ruby', 'rb'
|
|
buf = Rex::Text.to_ruby_comment(buf)
|
|
when 'perl', 'pl'
|
|
buf = Rex::Text.to_perl_comment(buf)
|
|
when 'c'
|
|
buf = Rex::Text.to_c_comment(buf)
|
|
when 'js_be', 'js_le'
|
|
buf = Rex::Text.to_js_comment(buf)
|
|
when 'java'
|
|
buf = Rex::Text.to_c_comment(buf)
|
|
else
|
|
raise ArgumentError, "Unsupported buffer format: #{fmt}", caller
|
|
end
|
|
|
|
return buf
|
|
end
|
|
|
|
#
|
|
# Returns the list of supported formats
|
|
#
|
|
def self.transform_formats
|
|
['raw','ruby','rb','perl','pl','c','js_be','js_le','java']
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
end
|