Path: blob/master/modules/encoders/cmd/brace.rb
19850 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Encoder67# This may produce incorrect code due to minimal escaping8Rank = LowRanking910def initialize11super(12'Name' => 'Bash Brace Expansion Command Encoder',13'Description' => %q{14This encoder uses brace expansion in Bash and other shells15to avoid whitespace without being overly fancy.16},17'Author' => ['wvu', 'egypt'],18'Platform' => %w[linux unix],19'Arch' => ARCH_CMD,20'EncoderType' => Msf::Encoder::Type::CmdPosixBrace21)22end2324def encode_block(state, buf)25# Skip encoding if there are no badchars26return buf if state.badchars !~ /\s/2728# Perform brace expansion encoding29"{#{buf.gsub(/([{,}])/, '\\\\\1').gsub(/\s+/, ',')}}"30end3132end333435