2009-11-17 00:00:08 +00:00
|
|
|
##
|
2014-10-17 16:47:33 +00:00
|
|
|
# This module requires Metasploit: http://metasploit.com/download
|
2013-10-15 18:50:46 +00:00
|
|
|
# Current source: https://github.com/rapid7/metasploit-framework
|
2009-11-17 00:00:08 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
|
|
|
|
require 'msf/core'
|
|
|
|
|
|
|
|
|
|
|
|
class Metasploit3 < Msf::Encoder
|
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
# Below normal ranking because this will produce incorrect code a lot of
|
|
|
|
# the time.
|
|
|
|
Rank = LowRanking
|
|
|
|
|
|
|
|
def initialize
|
|
|
|
super(
|
|
|
|
'Name' => 'Generic ${IFS} Substitution Command Encoder',
|
|
|
|
'Description' => %q{
|
|
|
|
This encoder uses standard Bourne shell variable substitution
|
|
|
|
to avoid spaces without being overly fancy.
|
|
|
|
},
|
|
|
|
'Author' => 'egypt',
|
2014-02-04 20:34:11 +00:00
|
|
|
'Arch' => ARCH_CMD,
|
2014-07-22 18:27:12 +00:00
|
|
|
'Platform' => 'unix',
|
2014-10-06 23:42:21 +00:00
|
|
|
'EncoderType' => Msf::Encoder::Type::CmdUnixIfs)
|
2013-08-30 21:28:54 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# Encodes the payload
|
|
|
|
#
|
|
|
|
def encode_block(state, buf)
|
2014-07-22 18:27:12 +00:00
|
|
|
# Skip encoding for empty badchars
|
|
|
|
if state.badchars.length == 0
|
|
|
|
return buf
|
|
|
|
end
|
|
|
|
|
|
|
|
# Skip encoding unless space is a badchar
|
|
|
|
unless state.badchars.include?(" ")
|
|
|
|
return buf
|
2014-07-22 15:27:45 +00:00
|
|
|
end
|
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
buf.gsub!(/\s/, '${IFS}')
|
|
|
|
return buf
|
|
|
|
end
|
2009-11-17 00:00:08 +00:00
|
|
|
|
|
|
|
end
|