1
mirror of https://github.com/rapid7/metasploit-payloads synced 2025-01-26 23:38:35 +01:00

a little more simplification

This commit is contained in:
Brent Cook 2017-10-27 05:09:22 -07:00
parent f85caa2738
commit 0429040ff5

View File

@ -990,36 +990,29 @@ function connect($ipaddr, $port, $proto='tcp') {
if (is_callable('stream_socket_client')) {
my_print("stream_socket_client({$proto}://{$ipaddr}:{$port})");
if ($proto == 'ssl') {
$sock = stream_socket_client(
"{$proto}://{$ipaddr}:{$port}",
$errno,
$errstr,
5,
STREAM_CLIENT_ASYNC_CONNECT
);
$sock = stream_socket_client("ssl://{$ipaddr}:{$port}",
$errno, $errstr, 5, STREAM_CLIENT_ASYNC_CONNECT);
if (!$sock) { return false; }
register_stream($sock);
stream_set_blocking($sock, 0);
register_stream($sock);
} elseif ($proto == 'tcp') {
$sock = stream_socket_client("{$proto}://{$ipaddr}:{$port}");
$sock = stream_socket_client("tcp://{$ipaddr}:{$port}");
if (!$sock) { return false; }
register_stream($sock);
} elseif ($proto == 'udp') {
$sock = stream_socket_client("{$proto}://{$ipaddr}:{$port}");
$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 == 'ssl') {
$sock = fsockopen("{$proto}://{$ipaddr}:{$port}");
$sock = fsockopen("ssl://{$ipaddr}:{$port}");
stream_set_blocking($sock, 0);
register_stream($sock);
stream_set_blocking($sock,0);
} elseif ($proto == 'tcp') {
$sock = fsockopen($ipaddr,$port);
$sock = fsockopen($ipaddr, $port);
if (!$sock) { return false; }
if (is_callable('socket_set_timeout')) {
socket_set_timeout($sock, 2);