From 6057a9da8f490a9bb41be06f13adee7ae4b326ee Mon Sep 17 00:00:00 2001 From: Jim Wigginton Date: Sat, 24 Apr 2010 06:40:49 +0000 Subject: [PATCH] - fixed a bug in Crypt_Random - SSH2 logging now more closely resembles the format of PuTTY logs git-svn-id: http://phpseclib.svn.sourceforge.net/svnroot/phpseclib/trunk@105 21d32557-59b3-4da0-833f-c5933fad653e --- phpseclib/Crypt/Random.php | 3 ++- phpseclib/Net/SSH2.php | 13 +++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/phpseclib/Crypt/Random.php b/phpseclib/Crypt/Random.php index f0a9814a..1ae6c5f0 100644 --- a/phpseclib/Crypt/Random.php +++ b/phpseclib/Crypt/Random.php @@ -35,7 +35,7 @@ * @author Jim Wigginton * @copyright MMVII Jim Wigginton * @license http://www.gnu.org/licenses/lgpl.txt - * @version $Id: Random.php,v 1.8 2010-04-13 12:41:14 terrafrost Exp $ + * @version $Id: Random.php,v 1.9 2010-04-24 06:40:48 terrafrost Exp $ * @link http://phpseclib.sourceforge.net */ @@ -121,6 +121,7 @@ function crypt_random($min = 0, $max = 0x7FFFFFFF) } $crypto->setKey($key); $crypto->setIV($iv); + $crypto->enableContinuousBuffer(); } extract(unpack('Nrandom', $crypto->encrypt("\0\0\0\0"))); diff --git a/phpseclib/Net/SSH2.php b/phpseclib/Net/SSH2.php index adce745b..c2fa951d 100644 --- a/phpseclib/Net/SSH2.php +++ b/phpseclib/Net/SSH2.php @@ -60,7 +60,7 @@ * @author Jim Wigginton * @copyright MMVII Jim Wigginton * @license http://www.gnu.org/licenses/lgpl.txt - * @version $Id: SSH2.php,v 1.43 2010-04-22 16:06:43 terrafrost Exp $ + * @version $Id: SSH2.php,v 1.44 2010-04-24 06:40:49 terrafrost Exp $ * @link http://phpseclib.sourceforge.net */ @@ -1581,7 +1581,7 @@ class Net_SSH2 { $this->message_number_log[] = '<- ' . $temp . ' (' . round($stop - $start, 4) . 's)'; if (NET_SSH2_LOGGING == NET_SSH2_LOG_COMPLEX) { - $this->message_log[] = $payload; + $this->message_log[] = substr($payload, 1); } } @@ -1848,7 +1848,7 @@ class Net_SSH2 { $this->message_number_log[] = '-> ' . $temp . ' (' . round($stop - $start, 4) . 's)'; if (NET_SSH2_LOGGING == NET_SSH2_LOG_COMPLEX) { - $this->message_log[] = $data; + $this->message_log[] = substr($data, 1); } } @@ -2002,13 +2002,17 @@ class Net_SSH2 { */ function _format_log($message_log, $message_number_log) { - static $boundary = ':', $long_width = 65, $short_width = 15; + static $boundary = ':', $long_width = 65, $short_width = 16; $output = ''; for ($i = 0; $i < count($message_log); $i++) { $output.= $message_number_log[$i] . "\r\n"; $current_log = $message_log[$i]; + $j = 0; do { + if (!empty($current_log)) { + $output.= str_pad(dechex($j), 7, '0', STR_PAD_LEFT) . '0 '; + } $fragment = $this->_string_shift($current_log, $short_width); $hex = substr( preg_replace( @@ -2021,6 +2025,7 @@ class Net_SSH2 { // http://en.wikipedia.org/wiki/ASCII#ASCII_printable_characters $raw = preg_replace('#[^\x20-\x7E]#', '.', $fragment); $output.= str_pad($hex, $long_width - $short_width, ' ') . $raw . "\r\n"; + $j++; } while (!empty($current_log)); $output.= "\r\n"; }