Skip to content

Commit

Permalink
Merge branch '3.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
terrafrost committed Feb 26, 2024
2 parents b55fdb5 + c2fb513 commit 2b3bf71
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 3 deletions.
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## 3.0.36 - 2024-02-25

- BigInteger: put guardrails on isPrime() and randomPrime() (CVE-2024-27354)
- ASN1: limit OID length (CVE-2024-27355)
- EC: when using openssl to do signing use unencrypted key (#1979)
- SSH2: add different options to isConnected() (#1983)

## 3.0.35 - 2023-12-18

- SSH2: implement terrapin attack countermeasures (#1972)
Expand Down Expand Up @@ -237,6 +244,12 @@
- Salsa20 / ChaCha20
- namespace changed from `phpseclib\` to `\phpseclib3` to facilitate phpseclib 2 shim (phpseclib2_compat)

## 2.0.47 - 2024-02-25

- BigInteger: add getLength() and getLengthInBytes() methods
- BigInteger: put guardrails on isPrime() and randomPrime() (CVE-2024-27354)
- ASN1: limit OID length (CVE-2024-27355)

## 2.0.46 - 2023-12-28

- SSH2: implement terrapin attack countermeasures (#1972)
Expand Down Expand Up @@ -603,6 +616,12 @@
- Classes were renamed and namespaced ([#243](https://github.com/phpseclib/phpseclib/issues/243))
- The use of an autoloader is now required (e.g. Composer)

## 1.0.23 - 2024-02-25

- BigInteger: add getLength() and getLengthInBytes() methods
- BigInteger: put guardrails on isPrime() and randomPrime() (CVE-2024-27354)
- ASN1: limit OID length (CVE-2024-27355)

## 1.0.22 - 2023-12-28

- SFTP: fix issue with get() downloading to files / streams (#1934)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ SSH-2, SFTP, X.509, an arbitrary-precision integer arithmetic library, Ed25519 /
* PHP4 compatible
* Composer compatible (PSR-0 autoloading)
* Install using Composer: `composer require phpseclib/phpseclib:~1.0`
* [Download 1.0.22 as ZIP](http://sourceforge.net/projects/phpseclib/files/phpseclib1.0.22.zip/download)
* [Download 1.0.23 as ZIP](http://sourceforge.net/projects/phpseclib/files/phpseclib1.0.23.zip/download)

## Security contact information

Expand Down
34 changes: 32 additions & 2 deletions phpseclib/Net/SSH2.php
Original file line number Diff line number Diff line change
Expand Up @@ -3023,9 +3023,39 @@ public function __destruct()
/**
* Is the connection still active?
*/
public function isConnected(): bool
*
* $level has 3x possible values:
* 0 (default): phpseclib takes a passive approach to see if the connection is still active by calling feof()
* on the socket
* 1: phpseclib takes an active approach to see if the connection is still active by sending an SSH_MSG_IGNORE
* packet that doesn't require a response
* 2: phpseclib takes an active approach to see if the connection is still active by sending an SSH_MSG_CHANNEL_OPEN
* packet and imediately trying to close that channel. some routers, in particular, however, will only let you
* open one channel, so this approach could yield false positives
*
* @param int $level
* @return bool
*/
public function isConnected(int $level = 0): bool
{
return ($this->bitmap & self::MASK_CONNECTED) && is_resource($this->fsock) && !feof($this->fsock);
if ($level < 0 || $level > 2) {
throw new InvalidArgumentException('$level must be 0, 1 or 2');
}
if ($level == 0) {
return ($this->bitmap & self::MASK_CONNECTED) && is_resource($this->fsock) && !feof($this->fsock);
}
try {
if ($level == 1) {
$this->send_binary_packet(pack('CN', NET_SSH2_MSG_IGNORE, 0));
} else {
$this->openChannel(self::CHANNEL_KEEP_ALIVE);
$this->close_channel(self::CHANNEL_KEEP_ALIVE);
}
return true;
} catch (\Exception $e) {
return false;
}
}

/**
Expand Down

0 comments on commit 2b3bf71

Please sign in to comment.