mirror of
https://github.com/phpseclib/phpseclib.git
synced 2024-12-28 12:10:59 +00:00
Merge branch '2.0'
This commit is contained in:
commit
c66b31e698
@ -2742,7 +2742,7 @@ class SSH2
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$response = $this->get_binary_packet(true);
|
$response = $this->get_binary_packet();
|
||||||
if ($response === false) {
|
if ($response === false) {
|
||||||
throw new \RuntimeException('Connection closed by server');
|
throw new \RuntimeException('Connection closed by server');
|
||||||
}
|
}
|
||||||
@ -3224,7 +3224,7 @@ class SSH2
|
|||||||
* @return string
|
* @return string
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
private function get_binary_packet($filter_channel_packets = false)
|
private function get_binary_packet($skip_channel_filter = false)
|
||||||
{
|
{
|
||||||
if (!is_resource($this->fsock) || feof($this->fsock)) {
|
if (!is_resource($this->fsock) || feof($this->fsock)) {
|
||||||
$this->bitmap = 0;
|
$this->bitmap = 0;
|
||||||
@ -3305,7 +3305,7 @@ class SSH2
|
|||||||
$this->last_packet = $current;
|
$this->last_packet = $current;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->filter($payload, $filter_channel_packets);
|
return $this->filter($payload, $skip_channel_filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -3319,7 +3319,7 @@ class SSH2
|
|||||||
* @return string
|
* @return string
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
private function filter($payload, $filter_channel_packets)
|
private function filter($payload, $skip_channel_filter)
|
||||||
{
|
{
|
||||||
switch (ord($payload[0])) {
|
switch (ord($payload[0])) {
|
||||||
case NET_SSH2_MSG_DISCONNECT:
|
case NET_SSH2_MSG_DISCONNECT:
|
||||||
@ -3374,10 +3374,10 @@ class SSH2
|
|||||||
case NET_SSH2_MSG_CHANNEL_REQUEST:
|
case NET_SSH2_MSG_CHANNEL_REQUEST:
|
||||||
case NET_SSH2_MSG_CHANNEL_CLOSE:
|
case NET_SSH2_MSG_CHANNEL_CLOSE:
|
||||||
case NET_SSH2_MSG_CHANNEL_EOF:
|
case NET_SSH2_MSG_CHANNEL_EOF:
|
||||||
if ($filter_channel_packets) {
|
if (!$skip_channel_filter && !empty($this->server_channels)) {
|
||||||
$this->binary_packet_buffer = $payload;
|
$this->binary_packet_buffer = $payload;
|
||||||
$this->get_channel_packet(true);
|
$this->get_channel_packet(true);
|
||||||
$payload = $this->get_binary_packet(true);
|
$payload = $this->get_binary_packet();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case NET_SSH2_MSG_GLOBAL_REQUEST: // see http://tools.ietf.org/html/rfc4254#section-4
|
case NET_SSH2_MSG_GLOBAL_REQUEST: // see http://tools.ietf.org/html/rfc4254#section-4
|
||||||
@ -3391,7 +3391,7 @@ class SSH2
|
|||||||
return $this->disconnect_helper(NET_SSH2_DISCONNECT_BY_APPLICATION);
|
return $this->disconnect_helper(NET_SSH2_DISCONNECT_BY_APPLICATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
$payload = $this->get_binary_packet();
|
$payload = $this->get_binary_packet($skip_channel_filter);
|
||||||
break;
|
break;
|
||||||
case NET_SSH2_MSG_CHANNEL_OPEN: // see http://tools.ietf.org/html/rfc4254#section-5.1
|
case NET_SSH2_MSG_CHANNEL_OPEN: // see http://tools.ietf.org/html/rfc4254#section-5.1
|
||||||
Strings::shift($payload, 1);
|
Strings::shift($payload, 1);
|
||||||
@ -3454,7 +3454,8 @@ class SSH2
|
|||||||
return $this->disconnect_helper(NET_SSH2_DISCONNECT_BY_APPLICATION);
|
return $this->disconnect_helper(NET_SSH2_DISCONNECT_BY_APPLICATION);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$payload = $this->get_binary_packet();
|
|
||||||
|
$payload = $this->get_binary_packet($skip_channel_filter);
|
||||||
break;
|
break;
|
||||||
case NET_SSH2_MSG_CHANNEL_WINDOW_ADJUST:
|
case NET_SSH2_MSG_CHANNEL_WINDOW_ADJUST:
|
||||||
Strings::shift($payload, 1);
|
Strings::shift($payload, 1);
|
||||||
@ -3466,7 +3467,7 @@ class SSH2
|
|||||||
|
|
||||||
$this->window_size_client_to_server[$channel]+= $window_size;
|
$this->window_size_client_to_server[$channel]+= $window_size;
|
||||||
|
|
||||||
$payload = ($this->bitmap & self::MASK_WINDOW_ADJUST) ? true : $this->get_binary_packet();
|
$payload = ($this->bitmap & self::MASK_WINDOW_ADJUST) ? true : $this->get_binary_packet($skip_channel_filter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3590,7 +3591,7 @@ class SSH2
|
|||||||
$this->curTimeout-= $elapsed;
|
$this->curTimeout-= $elapsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
$response = $this->get_binary_packet();
|
$response = $this->get_binary_packet(true);
|
||||||
if ($response === false) {
|
if ($response === false) {
|
||||||
throw new \RuntimeException('Connection closed by server');
|
throw new \RuntimeException('Connection closed by server');
|
||||||
}
|
}
|
||||||
@ -3630,6 +3631,33 @@ class SSH2
|
|||||||
$this->window_size_server_to_client[$channel]+= $this->window_size;
|
$this->window_size_server_to_client[$channel]+= $this->window_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($type == NET_SSH2_MSG_CHANNEL_EXTENDED_DATA) {
|
||||||
|
/*
|
||||||
|
if ($client_channel == NET_SSH2_CHANNEL_EXEC) {
|
||||||
|
$this->_send_channel_packet($client_channel, chr(0));
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
// currently, there's only one possible value for $data_type_code: NET_SSH2_EXTENDED_DATA_STDERR
|
||||||
|
if (strlen($response) < 8) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
extract(unpack('Ndata_type_code/Nlength', $this->_string_shift($response, 8)));
|
||||||
|
$data = Strings::shift($response, $length);
|
||||||
|
$this->stdErrorLog.= $data;
|
||||||
|
if ($skip_extended || $this->quiet_mode) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if ($client_channel == $channel && $this->channel_status[$channel] == NET_SSH2_MSG_CHANNEL_DATA) {
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
if (!isset($this->channel_buffers[$channel])) {
|
||||||
|
$this->channel_buffers[$channel] = array();
|
||||||
|
}
|
||||||
|
$this->channel_buffers[$channel][] = $data;
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
switch ($this->channel_status[$channel]) {
|
switch ($this->channel_status[$channel]) {
|
||||||
case NET_SSH2_MSG_CHANNEL_OPEN:
|
case NET_SSH2_MSG_CHANNEL_OPEN:
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
@ -3706,31 +3734,6 @@ class SSH2
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($client_channel == $channel) {
|
|
||||||
return $data;
|
|
||||||
}
|
|
||||||
if (!isset($this->channel_buffers[$channel])) {
|
|
||||||
$this->channel_buffers[$channel] = [];
|
|
||||||
}
|
|
||||||
$this->channel_buffers[$channel][] = $data;
|
|
||||||
break;
|
|
||||||
case NET_SSH2_MSG_CHANNEL_EXTENDED_DATA:
|
|
||||||
/*
|
|
||||||
if ($client_channel == self::CHANNEL_EXEC) {
|
|
||||||
$this->send_channel_packet($client_channel, chr(0));
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
// currently, there's only one possible value for $data_type_code: NET_SSH2_EXTENDED_DATA_STDERR
|
|
||||||
if (strlen($response) < 8) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
extract(unpack('Ndata_type_code/Nlength', Strings::shift($response, 8)));
|
|
||||||
$data = Strings::shift($response, $length);
|
|
||||||
|
|
||||||
$this->stdErrorLog.= $data;
|
|
||||||
if ($skip_extended || $this->quiet_mode) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if ($client_channel == $channel) {
|
if ($client_channel == $channel) {
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user