From 535104cb842271eb9c76c3739c910477bf16ae75 Mon Sep 17 00:00:00 2001 From: terrafrost Date: Tue, 8 Nov 2016 09:11:57 -0600 Subject: [PATCH] SSH2: send the identifier first, before reading it --- phpseclib/Net/SSH2.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/phpseclib/Net/SSH2.php b/phpseclib/Net/SSH2.php index 8281e73a..12741c73 100644 --- a/phpseclib/Net/SSH2.php +++ b/phpseclib/Net/SSH2.php @@ -1056,6 +1056,10 @@ class Net_SSH2 } } + $this->identifier = $this->_generate_identifier(); + + fputs($this->fsock, $this->identifier . "\r\n"); + /* According to the SSH2 specs, "The server MAY send other lines of data before sending the version @@ -1099,8 +1103,6 @@ class Net_SSH2 return false; } - $this->identifier = $this->_generate_identifier(); - if (defined('NET_SSH2_LOGGING')) { $this->_append_log('<-', $extra . $temp); $this->_append_log('->', $this->identifier . "\r\n"); @@ -1116,8 +1118,6 @@ class Net_SSH2 return false; } - fputs($this->fsock, $this->identifier . "\r\n"); - $response = $this->_get_binary_packet(); if ($response === false) { user_error('Connection closed by server');