Path: blob/master/modules/encoders/php/minify.rb
19850 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Encoder6Rank = GreatRanking78def initialize9super(10'Name' => 'PHP Minify Encoder',11'Description' => %q{12This encoder minifies a PHP payload by removing leasing spaces, trailing13new lines, comments, ...14},15'Author' => 'Julien Voisin',16'License' => BSD_LICENSE,17'Arch' => ARCH_PHP)18end1920def encode_block(_, buf)21# Remove comments22buf.gsub!(/^\s*#.*$/, '')2324# Remove spaces after keywords25buf.gsub!(/^\s*(if|else|elsif|while|for|foreach)\s*\(/, '\1(')2627# Remove spaces before block opening28buf.gsub!(/\s*{$/, '{')2930# Remove empty lines31buf.squeeze!("\n")3233# Remove leading/trailing spaces34buf.gsub!(/^[ \t]+/, '')3536# Remove new lines37buf.gsub!(/([;{}])\n/, '\1')3839return buf40end41end424344