mirror of
https://github.com/phpseclib/phpseclib.git
synced 2024-11-11 08:10:58 +00:00
Namespaced classes
This commit is contained in:
parent
2871cce58d
commit
628949fb73
@ -5,7 +5,7 @@
|
|||||||
*
|
*
|
||||||
* PHP versions 4 and 5
|
* PHP versions 4 and 5
|
||||||
*
|
*
|
||||||
* If you call read() in Net_SSH2 you may get {@link http://en.wikipedia.org/wiki/ANSI_escape_code ANSI escape codes} back.
|
* If you call read() in \phpseclib\Net\SSH2 you may get {@link http://en.wikipedia.org/wiki/ANSI_escape_code ANSI escape codes} back.
|
||||||
* They'd look like chr(0x1B) . '[00m' or whatever (0x1B = ESC). They tell a
|
* They'd look like chr(0x1B) . '[00m' or whatever (0x1B = ESC). They tell a
|
||||||
* {@link http://en.wikipedia.org/wiki/Terminal_emulator terminal emulator} how to format the characters, what
|
* {@link http://en.wikipedia.org/wiki/Terminal_emulator terminal emulator} how to format the characters, what
|
||||||
* color to display them in, etc. \phpseclib\File\ANSI is a {@link http://en.wikipedia.org/wiki/VT100 VT100} terminal emulator.
|
* color to display them in, etc. \phpseclib\File\ANSI is a {@link http://en.wikipedia.org/wiki/VT100 VT100} terminal emulator.
|
||||||
|
@ -10,39 +10,43 @@
|
|||||||
* Here's a short example of how to use this library:
|
* Here's a short example of how to use this library:
|
||||||
* <code>
|
* <code>
|
||||||
* <?php
|
* <?php
|
||||||
* include 'Net/SCP.php';
|
* include 'vendor/autoload.php';
|
||||||
* include 'Net/SSH2.php';
|
|
||||||
*
|
*
|
||||||
* $ssh = new Net_SSH2('www.domain.tld');
|
* $ssh = new \phpseclib\Net\SSH2('www.domain.tld');
|
||||||
* if (!$ssh->login('username', 'password')) {
|
* if (!$ssh->login('username', 'password')) {
|
||||||
* exit('bad login');
|
* exit('bad login');
|
||||||
* }
|
* }
|
||||||
|
|
||||||
* $scp = new Net_SCP($ssh);
|
* $scp = new \phpseclib\Net\SCP($ssh);
|
||||||
* $scp->put('abcd', str_repeat('x', 1024*1024));
|
* $scp->put('abcd', str_repeat('x', 1024*1024));
|
||||||
* ?>
|
* ?>
|
||||||
* </code>
|
* </code>
|
||||||
*
|
*
|
||||||
* @category Net
|
* @category Net
|
||||||
* @package Net_SCP
|
* @package SCP
|
||||||
* @author Jim Wigginton <terrafrost@php.net>
|
* @author Jim Wigginton <terrafrost@php.net>
|
||||||
* @copyright 2010 Jim Wigginton
|
* @copyright 2010 Jim Wigginton
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
* @link http://phpseclib.sourceforge.net
|
* @link http://phpseclib.sourceforge.net
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
namespace phpseclib\Net;
|
||||||
|
|
||||||
|
use phpseclib\Net\SSH1;
|
||||||
|
use phpseclib\Net\SSH2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pure-PHP implementations of SCP.
|
* Pure-PHP implementations of SCP.
|
||||||
*
|
*
|
||||||
* @package Net_SCP
|
* @package SCP
|
||||||
* @author Jim Wigginton <terrafrost@php.net>
|
* @author Jim Wigginton <terrafrost@php.net>
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
class Net_SCP
|
class SCP
|
||||||
{
|
{
|
||||||
/**#@+
|
/**#@+
|
||||||
* @access public
|
* @access public
|
||||||
* @see Net_SCP::put()
|
* @see \phpseclib\Net\SCP::put()
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* Reads data from a local file.
|
* Reads data from a local file.
|
||||||
@ -56,8 +60,8 @@ class Net_SCP
|
|||||||
|
|
||||||
/**#@+
|
/**#@+
|
||||||
* @access private
|
* @access private
|
||||||
* @see Net_SCP::_send()
|
* @see \phpseclib\Net\SCP::_send()
|
||||||
* @see Net_SCP::_receive()
|
* @see \phpseclib\Net\SCP::_receive()
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* SSH1 is being used.
|
* SSH1 is being used.
|
||||||
@ -101,7 +105,7 @@ class Net_SCP
|
|||||||
* @param String $host
|
* @param String $host
|
||||||
* @param optional Integer $port
|
* @param optional Integer $port
|
||||||
* @param optional Integer $timeout
|
* @param optional Integer $timeout
|
||||||
* @return Net_SCP
|
* @return \phpseclib\Net\SCP
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function __construct($ssh)
|
function __construct($ssh)
|
||||||
@ -110,11 +114,11 @@ class Net_SCP
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (strtolower(get_class($ssh))) {
|
switch (get_class($ssh)) {
|
||||||
case 'net_ssh2':
|
case 'phpseclib\Net\SSH2':
|
||||||
$this->mode = self::MODE_SSH2;
|
$this->mode = self::MODE_SSH2;
|
||||||
break;
|
break;
|
||||||
case 'net_ssh1':
|
case 'phpseclib\Net\SSH1':
|
||||||
$this->packet_size = 50000;
|
$this->packet_size = 50000;
|
||||||
$this->mode = self::MODE_SSH1;
|
$this->mode = self::MODE_SSH1;
|
||||||
break;
|
break;
|
||||||
@ -128,8 +132,8 @@ class Net_SCP
|
|||||||
/**
|
/**
|
||||||
* Uploads a file to the SCP server.
|
* Uploads a file to the SCP server.
|
||||||
*
|
*
|
||||||
* By default, Net_SCP::put() does not read from the local filesystem. $data is dumped directly into $remote_file.
|
* By default, \phpseclib\Net\SCP::put() does not read from the local filesystem. $data is dumped directly into $remote_file.
|
||||||
* So, for example, if you set $data to 'filename.ext' and then do Net_SCP::get(), you will get a file, twelve bytes
|
* So, for example, if you set $data to 'filename.ext' and then do \phpseclib\Net\SCP::get(), you will get a file, twelve bytes
|
||||||
* long, containing 'filename.ext' as its contents.
|
* long, containing 'filename.ext' as its contents.
|
||||||
*
|
*
|
||||||
* Setting $mode to self::SOURCE_LOCAL_FILE will change the above behavior. With self::SOURCE_LOCAL_FILE, $remote_file will
|
* Setting $mode to self::SOURCE_LOCAL_FILE will change the above behavior. With self::SOURCE_LOCAL_FILE, $remote_file will
|
||||||
@ -162,7 +166,7 @@ class Net_SCP
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($this->mode == self::MODE_SSH2) {
|
if ($this->mode == self::MODE_SSH2) {
|
||||||
$this->packet_size = $this->ssh->packet_size_client_to_server[Net_SSH2::CHANNEL_EXEC] - 4;
|
$this->packet_size = $this->ssh->packet_size_client_to_server[SSH2::CHANNEL_EXEC] - 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
$remote_file = basename($remote_file);
|
$remote_file = basename($remote_file);
|
||||||
@ -280,7 +284,7 @@ class Net_SCP
|
|||||||
{
|
{
|
||||||
switch ($this->mode) {
|
switch ($this->mode) {
|
||||||
case self::MODE_SSH2:
|
case self::MODE_SSH2:
|
||||||
$this->ssh->_send_channel_packet(Net_SSH2::CHANNEL_EXEC, $data);
|
$this->ssh->_send_channel_packet(SSH2::CHANNEL_EXEC, $data);
|
||||||
break;
|
break;
|
||||||
case self::MODE_SSH1:
|
case self::MODE_SSH1:
|
||||||
$data = pack('CNa*', NET_SSH1_CMSG_STDIN_DATA, strlen($data), $data);
|
$data = pack('CNa*', NET_SSH1_CMSG_STDIN_DATA, strlen($data), $data);
|
||||||
@ -298,17 +302,17 @@ class Net_SCP
|
|||||||
{
|
{
|
||||||
switch ($this->mode) {
|
switch ($this->mode) {
|
||||||
case self::MODE_SSH2:
|
case self::MODE_SSH2:
|
||||||
return $this->ssh->_get_channel_packet(Net_SSH2::CHANNEL_EXEC, true);
|
return $this->ssh->_get_channel_packet(SSH2::CHANNEL_EXEC, true);
|
||||||
case self::MODE_SSH1:
|
case self::MODE_SSH1:
|
||||||
if (!$this->ssh->bitmap) {
|
if (!$this->ssh->bitmap) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
while (true) {
|
while (true) {
|
||||||
$response = $this->ssh->_get_binary_packet();
|
$response = $this->ssh->_get_binary_packet();
|
||||||
switch ($response[Net_SSH1::RESPONSE_TYPE]) {
|
switch ($response[SSH1::RESPONSE_TYPE]) {
|
||||||
case NET_SSH1_SMSG_STDOUT_DATA:
|
case NET_SSH1_SMSG_STDOUT_DATA:
|
||||||
extract(unpack('Nlength', $response[Net_SSH1::RESPONSE_DATA]));
|
extract(unpack('Nlength', $response[SSH1::RESPONSE_DATA]));
|
||||||
return $this->ssh->_string_shift($response[Net_SSH1::RESPONSE_DATA], $length);
|
return $this->ssh->_string_shift($response[SSH1::RESPONSE_DATA], $length);
|
||||||
case NET_SSH1_SMSG_STDERR_DATA:
|
case NET_SSH1_SMSG_STDERR_DATA:
|
||||||
break;
|
break;
|
||||||
case NET_SSH1_SMSG_EXITSTATUS:
|
case NET_SSH1_SMSG_EXITSTATUS:
|
||||||
@ -333,7 +337,7 @@ class Net_SCP
|
|||||||
{
|
{
|
||||||
switch ($this->mode) {
|
switch ($this->mode) {
|
||||||
case self::MODE_SSH2:
|
case self::MODE_SSH2:
|
||||||
$this->ssh->_close_channel(Net_SSH2::CHANNEL_EXEC, true);
|
$this->ssh->_close_channel(SSH2::CHANNEL_EXEC, true);
|
||||||
break;
|
break;
|
||||||
case self::MODE_SSH1:
|
case self::MODE_SSH1:
|
||||||
$this->ssh->disconnect();
|
$this->ssh->disconnect();
|
||||||
|
@ -14,9 +14,9 @@
|
|||||||
* Here's a short example of how to use this library:
|
* Here's a short example of how to use this library:
|
||||||
* <code>
|
* <code>
|
||||||
* <?php
|
* <?php
|
||||||
* include 'Net/SFTP.php';
|
* include 'vendor/autoload.php';
|
||||||
*
|
*
|
||||||
* $sftp = new Net_SFTP('www.domain.tld');
|
* $sftp = new \phpseclib\Net\SFTP('www.domain.tld');
|
||||||
* if (!$sftp->login('username', 'password')) {
|
* if (!$sftp->login('username', 'password')) {
|
||||||
* exit('Login Failed');
|
* exit('Login Failed');
|
||||||
* }
|
* }
|
||||||
@ -28,43 +28,40 @@
|
|||||||
* </code>
|
* </code>
|
||||||
*
|
*
|
||||||
* @category Net
|
* @category Net
|
||||||
* @package Net_SFTP
|
* @package SFTP
|
||||||
* @author Jim Wigginton <terrafrost@php.net>
|
* @author Jim Wigginton <terrafrost@php.net>
|
||||||
* @copyright 2009 Jim Wigginton
|
* @copyright 2009 Jim Wigginton
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
* @link http://phpseclib.sourceforge.net
|
* @link http://phpseclib.sourceforge.net
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
namespace phpseclib\Net;
|
||||||
* Include Net_SSH2
|
|
||||||
*/
|
use phpseclib\Net\SSH2;
|
||||||
if (!class_exists('Net_SSH2')) {
|
|
||||||
include_once 'SSH2.php';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pure-PHP implementations of SFTP.
|
* Pure-PHP implementations of SFTP.
|
||||||
*
|
*
|
||||||
* @package Net_SFTP
|
* @package SFTP
|
||||||
* @author Jim Wigginton <terrafrost@php.net>
|
* @author Jim Wigginton <terrafrost@php.net>
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
class Net_SFTP extends Net_SSH2
|
class SFTP extends SSH2
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* SFTP channel constant
|
* SFTP channel constant
|
||||||
*
|
*
|
||||||
* Net_SSH2::exec() uses 0 and Net_SSH2::read() / Net_SSH2::write() use 1.
|
* \phpseclib\Net\SSH2::exec() uses 0 and \phpseclib\Net\SSH2::read() / \phpseclib\Net\SSH2::write() use 1.
|
||||||
*
|
*
|
||||||
* @see Net_SSH2::_send_channel_packet()
|
* @see \phpseclib\Net\SSH2::_send_channel_packet()
|
||||||
* @see Net_SSH2::_get_channel_packet()
|
* @see \phpseclib\Net\SSH2::_get_channel_packet()
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
const CHANNEL = 0x100;
|
const CHANNEL = 0x100;
|
||||||
|
|
||||||
/**#@+
|
/**#@+
|
||||||
* @access public
|
* @access public
|
||||||
* @see Net_SFTP::put()
|
* @see \phpseclib\Net\SFTP::put()
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* Reads data from a local file.
|
* Reads data from a local file.
|
||||||
@ -88,7 +85,7 @@ class Net_SFTP extends Net_SSH2
|
|||||||
/**
|
/**
|
||||||
* Packet Types
|
* Packet Types
|
||||||
*
|
*
|
||||||
* @see Net_SFTP::__construct()
|
* @see \phpseclib\Net\SFTP::__construct()
|
||||||
* @var Array
|
* @var Array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -97,7 +94,7 @@ class Net_SFTP extends Net_SSH2
|
|||||||
/**
|
/**
|
||||||
* Status Codes
|
* Status Codes
|
||||||
*
|
*
|
||||||
* @see Net_SFTP::__construct()
|
* @see \phpseclib\Net\SFTP::__construct()
|
||||||
* @var Array
|
* @var Array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -110,7 +107,7 @@ class Net_SFTP extends Net_SSH2
|
|||||||
* concurrent actions, so it's somewhat academic, here.
|
* concurrent actions, so it's somewhat academic, here.
|
||||||
*
|
*
|
||||||
* @var Integer
|
* @var Integer
|
||||||
* @see Net_SFTP::_send_sftp_packet()
|
* @see \phpseclib\Net\SFTP::_send_sftp_packet()
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $request_id = false;
|
var $request_id = false;
|
||||||
@ -122,7 +119,7 @@ class Net_SFTP extends Net_SSH2
|
|||||||
* concurrent actions, so it's somewhat academic, here.
|
* concurrent actions, so it's somewhat academic, here.
|
||||||
*
|
*
|
||||||
* @var Integer
|
* @var Integer
|
||||||
* @see Net_SFTP::_get_sftp_packet()
|
* @see \phpseclib\Net\SFTP::_get_sftp_packet()
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $packet_type = -1;
|
var $packet_type = -1;
|
||||||
@ -131,7 +128,7 @@ class Net_SFTP extends Net_SSH2
|
|||||||
* Packet Buffer
|
* Packet Buffer
|
||||||
*
|
*
|
||||||
* @var String
|
* @var String
|
||||||
* @see Net_SFTP::_get_sftp_packet()
|
* @see \phpseclib\Net\SFTP::_get_sftp_packet()
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $packet_buffer = '';
|
var $packet_buffer = '';
|
||||||
@ -140,7 +137,7 @@ class Net_SFTP extends Net_SSH2
|
|||||||
* Extensions supported by the server
|
* Extensions supported by the server
|
||||||
*
|
*
|
||||||
* @var Array
|
* @var Array
|
||||||
* @see Net_SFTP::_initChannel()
|
* @see \phpseclib\Net\SFTP::_initChannel()
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $extensions = array();
|
var $extensions = array();
|
||||||
@ -149,7 +146,7 @@ class Net_SFTP extends Net_SSH2
|
|||||||
* Server SFTP version
|
* Server SFTP version
|
||||||
*
|
*
|
||||||
* @var Integer
|
* @var Integer
|
||||||
* @see Net_SFTP::_initChannel()
|
* @see \phpseclib\Net\SFTP::_initChannel()
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $version;
|
var $version;
|
||||||
@ -158,8 +155,8 @@ class Net_SFTP extends Net_SSH2
|
|||||||
* Current working directory
|
* Current working directory
|
||||||
*
|
*
|
||||||
* @var String
|
* @var String
|
||||||
* @see Net_SFTP::_realpath()
|
* @see \phpseclib\Net\SFTP::_realpath()
|
||||||
* @see Net_SFTP::chdir()
|
* @see \phpseclib\Net\SFTP::chdir()
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $pwd = false;
|
var $pwd = false;
|
||||||
@ -167,7 +164,7 @@ class Net_SFTP extends Net_SSH2
|
|||||||
/**
|
/**
|
||||||
* Packet Type Log
|
* Packet Type Log
|
||||||
*
|
*
|
||||||
* @see Net_SFTP::getLog()
|
* @see \phpseclib\Net\SFTP::getLog()
|
||||||
* @var Array
|
* @var Array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -176,7 +173,7 @@ class Net_SFTP extends Net_SSH2
|
|||||||
/**
|
/**
|
||||||
* Packet Log
|
* Packet Log
|
||||||
*
|
*
|
||||||
* @see Net_SFTP::getLog()
|
* @see \phpseclib\Net\SFTP::getLog()
|
||||||
* @var Array
|
* @var Array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -185,8 +182,8 @@ class Net_SFTP extends Net_SSH2
|
|||||||
/**
|
/**
|
||||||
* Error information
|
* Error information
|
||||||
*
|
*
|
||||||
* @see Net_SFTP::getSFTPErrors()
|
* @see \phpseclib\Net\SFTP::getSFTPErrors()
|
||||||
* @see Net_SFTP::getLastSFTPError()
|
* @see \phpseclib\Net\SFTP::getLastSFTPError()
|
||||||
* @var String
|
* @var String
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -198,9 +195,9 @@ class Net_SFTP extends Net_SSH2
|
|||||||
* Rather than always having to open a directory and close it immediately there after to see if a file is a directory
|
* Rather than always having to open a directory and close it immediately there after to see if a file is a directory
|
||||||
* we'll cache the results.
|
* we'll cache the results.
|
||||||
*
|
*
|
||||||
* @see Net_SFTP::_update_stat_cache()
|
* @see \phpseclib\Net\SFTP::_update_stat_cache()
|
||||||
* @see Net_SFTP::_remove_from_stat_cache()
|
* @see \phpseclib\Net\SFTP::_remove_from_stat_cache()
|
||||||
* @see Net_SFTP::_query_stat_cache()
|
* @see \phpseclib\Net\SFTP::_query_stat_cache()
|
||||||
* @var Array
|
* @var Array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -209,8 +206,8 @@ class Net_SFTP extends Net_SSH2
|
|||||||
/**
|
/**
|
||||||
* Max SFTP Packet Size
|
* Max SFTP Packet Size
|
||||||
*
|
*
|
||||||
* @see Net_SFTP::__construct()
|
* @see \phpseclib\Net\SFTP::__construct()
|
||||||
* @see Net_SFTP::get()
|
* @see \phpseclib\Net\SFTP::get()
|
||||||
* @var Array
|
* @var Array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -219,8 +216,8 @@ class Net_SFTP extends Net_SSH2
|
|||||||
/**
|
/**
|
||||||
* Stat Cache Flag
|
* Stat Cache Flag
|
||||||
*
|
*
|
||||||
* @see Net_SFTP::disableStatCache()
|
* @see \phpseclib\Net\SFTP::disableStatCache()
|
||||||
* @see Net_SFTP::enableStatCache()
|
* @see \phpseclib\Net\SFTP::enableStatCache()
|
||||||
* @var Boolean
|
* @var Boolean
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -229,8 +226,8 @@ class Net_SFTP extends Net_SSH2
|
|||||||
/**
|
/**
|
||||||
* Sort Options
|
* Sort Options
|
||||||
*
|
*
|
||||||
* @see Net_SFTP::_comparator()
|
* @see \phpseclib\Net\SFTP::_comparator()
|
||||||
* @see Net_SFTP::setListOrder()
|
* @see \phpseclib\Net\SFTP::setListOrder()
|
||||||
* @var Array
|
* @var Array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -244,7 +241,7 @@ class Net_SFTP extends Net_SSH2
|
|||||||
* @param String $host
|
* @param String $host
|
||||||
* @param optional Integer $port
|
* @param optional Integer $port
|
||||||
* @param optional Integer $timeout
|
* @param optional Integer $timeout
|
||||||
* @return Net_SFTP
|
* @return \phpseclib\Net\SFTP
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function __construct($host, $port = 22, $timeout = 10)
|
function __construct($host, $port = 22, $timeout = 10)
|
||||||
@ -325,7 +322,7 @@ class Net_SFTP extends Net_SSH2
|
|||||||
31 => 'NET_SFTP_STATUS_NO_MATCHING_BYTE_RANGE_LOCK'
|
31 => 'NET_SFTP_STATUS_NO_MATCHING_BYTE_RANGE_LOCK'
|
||||||
);
|
);
|
||||||
// http://tools.ietf.org/html/draft-ietf-secsh-filexfer-13#section-7.1
|
// http://tools.ietf.org/html/draft-ietf-secsh-filexfer-13#section-7.1
|
||||||
// the order, in this case, matters quite a lot - see Net_SFTP::_parseAttributes() to understand why
|
// the order, in this case, matters quite a lot - see \phpseclib\Net\SFTP::_parseAttributes() to understand why
|
||||||
$this->attributes = array(
|
$this->attributes = array(
|
||||||
0x00000001 => 'NET_SFTP_ATTR_SIZE',
|
0x00000001 => 'NET_SFTP_ATTR_SIZE',
|
||||||
0x00000002 => 'NET_SFTP_ATTR_UIDGID', // defined in SFTPv3, removed in SFTPv4+
|
0x00000002 => 'NET_SFTP_ATTR_UIDGID', // defined in SFTPv3, removed in SFTPv4+
|
||||||
@ -349,7 +346,7 @@ class Net_SFTP extends Net_SSH2
|
|||||||
0x00000020 => 'NET_SFTP_OPEN_EXCL'
|
0x00000020 => 'NET_SFTP_OPEN_EXCL'
|
||||||
);
|
);
|
||||||
// http://tools.ietf.org/html/draft-ietf-secsh-filexfer-04#section-5.2
|
// http://tools.ietf.org/html/draft-ietf-secsh-filexfer-04#section-5.2
|
||||||
// see Net_SFTP::_parseLongname() for an explanation
|
// see \phpseclib\Net\SFTP::_parseLongname() for an explanation
|
||||||
$this->file_types = array(
|
$this->file_types = array(
|
||||||
1 => 'NET_SFTP_TYPE_REGULAR',
|
1 => 'NET_SFTP_TYPE_REGULAR',
|
||||||
2 => 'NET_SFTP_TYPE_DIRECTORY',
|
2 => 'NET_SFTP_TYPE_DIRECTORY',
|
||||||
@ -495,7 +492,7 @@ class Net_SFTP extends Net_SSH2
|
|||||||
So what do you do if you have a client whose initial SSH_FXP_INIT packet says it implements v3 and
|
So what do you do if you have a client whose initial SSH_FXP_INIT packet says it implements v3 and
|
||||||
a server whose initial SSH_FXP_VERSION reply says it implements v4 and only v4? If it only implements
|
a server whose initial SSH_FXP_VERSION reply says it implements v4 and only v4? If it only implements
|
||||||
v4, the "versions" extension is likely not going to have been sent so version re-negotiation as discussed
|
v4, the "versions" extension is likely not going to have been sent so version re-negotiation as discussed
|
||||||
in draft-ietf-secsh-filexfer-13 would be quite impossible. As such, what Net_SFTP would do is close the
|
in draft-ietf-secsh-filexfer-13 would be quite impossible. As such, what \phpseclib\Net\SFTP would do is close the
|
||||||
channel and reopen it with a new and updated SSH_FXP_INIT packet.
|
channel and reopen it with a new and updated SSH_FXP_INIT packet.
|
||||||
*/
|
*/
|
||||||
switch ($this->version) {
|
switch ($this->version) {
|
||||||
@ -583,7 +580,7 @@ class Net_SFTP extends Net_SSH2
|
|||||||
* SFTP doesn't provide a mechanism by which the current working directory can be changed, so we'll emulate it. Returns
|
* SFTP doesn't provide a mechanism by which the current working directory can be changed, so we'll emulate it. Returns
|
||||||
* the absolute (canonicalized) path.
|
* the absolute (canonicalized) path.
|
||||||
*
|
*
|
||||||
* @see Net_SFTP::chdir()
|
* @see \phpseclib\Net\SFTP::chdir()
|
||||||
* @param String $path
|
* @param String $path
|
||||||
* @return Mixed
|
* @return Mixed
|
||||||
* @access private
|
* @access private
|
||||||
@ -646,7 +643,7 @@ class Net_SFTP extends Net_SSH2
|
|||||||
*/
|
*/
|
||||||
function chdir($dir)
|
function chdir($dir)
|
||||||
{
|
{
|
||||||
if (!($this->bitmap & Net_SSH2::MASK_LOGIN)) {
|
if (!($this->bitmap & SSH2::MASK_LOGIN)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -675,7 +672,7 @@ class Net_SFTP extends Net_SSH2
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// see Net_SFTP::nlist() for a more thorough explanation of the following
|
// see \phpseclib\Net\SFTP::nlist() for a more thorough explanation of the following
|
||||||
$response = $this->_get_sftp_packet();
|
$response = $this->_get_sftp_packet();
|
||||||
switch ($this->packet_type) {
|
switch ($this->packet_type) {
|
||||||
case NET_SFTP_HANDLE:
|
case NET_SFTP_HANDLE:
|
||||||
@ -792,7 +789,7 @@ class Net_SFTP extends Net_SSH2
|
|||||||
*/
|
*/
|
||||||
function _list($dir, $raw = true)
|
function _list($dir, $raw = true)
|
||||||
{
|
{
|
||||||
if (!($this->bitmap & Net_SSH2::MASK_LOGIN)) {
|
if (!($this->bitmap & SSH2::MASK_LOGIN)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1001,7 +998,7 @@ class Net_SFTP extends Net_SSH2
|
|||||||
*/
|
*/
|
||||||
function size($filename)
|
function size($filename)
|
||||||
{
|
{
|
||||||
if (!($this->bitmap & Net_SSH2::MASK_LOGIN)) {
|
if (!($this->bitmap & SSH2::MASK_LOGIN)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1097,7 +1094,7 @@ class Net_SFTP extends Net_SSH2
|
|||||||
*/
|
*/
|
||||||
function stat($filename)
|
function stat($filename)
|
||||||
{
|
{
|
||||||
if (!($this->bitmap & Net_SSH2::MASK_LOGIN)) {
|
if (!($this->bitmap & SSH2::MASK_LOGIN)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1154,7 +1151,7 @@ class Net_SFTP extends Net_SSH2
|
|||||||
*/
|
*/
|
||||||
function lstat($filename)
|
function lstat($filename)
|
||||||
{
|
{
|
||||||
if (!($this->bitmap & Net_SSH2::MASK_LOGIN)) {
|
if (!($this->bitmap & SSH2::MASK_LOGIN)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1211,7 +1208,7 @@ class Net_SFTP extends Net_SSH2
|
|||||||
/**
|
/**
|
||||||
* Returns general information about a file or symbolic link
|
* Returns general information about a file or symbolic link
|
||||||
*
|
*
|
||||||
* Determines information without calling Net_SFTP::_realpath().
|
* Determines information without calling \phpseclib\Net\SFTP::_realpath().
|
||||||
* The second parameter can be either NET_SFTP_STAT or NET_SFTP_LSTAT.
|
* The second parameter can be either NET_SFTP_STAT or NET_SFTP_LSTAT.
|
||||||
*
|
*
|
||||||
* @param String $filename
|
* @param String $filename
|
||||||
@ -1268,7 +1265,7 @@ class Net_SFTP extends Net_SSH2
|
|||||||
*/
|
*/
|
||||||
function touch($filename, $time = null, $atime = null)
|
function touch($filename, $time = null, $atime = null)
|
||||||
{
|
{
|
||||||
if (!($this->bitmap & Net_SSH2::MASK_LOGIN)) {
|
if (!($this->bitmap & SSH2::MASK_LOGIN)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1405,7 +1402,7 @@ class Net_SFTP extends Net_SSH2
|
|||||||
*/
|
*/
|
||||||
function _setstat($filename, $attr, $recursive)
|
function _setstat($filename, $attr, $recursive)
|
||||||
{
|
{
|
||||||
if (!($this->bitmap & Net_SSH2::MASK_LOGIN)) {
|
if (!($this->bitmap & SSH2::MASK_LOGIN)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1532,7 +1529,7 @@ class Net_SFTP extends Net_SSH2
|
|||||||
*/
|
*/
|
||||||
function readlink($link)
|
function readlink($link)
|
||||||
{
|
{
|
||||||
if (!($this->bitmap & Net_SSH2::MASK_LOGIN)) {
|
if (!($this->bitmap & SSH2::MASK_LOGIN)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1576,7 +1573,7 @@ class Net_SFTP extends Net_SSH2
|
|||||||
*/
|
*/
|
||||||
function symlink($target, $link)
|
function symlink($target, $link)
|
||||||
{
|
{
|
||||||
if (!($this->bitmap & Net_SSH2::MASK_LOGIN)) {
|
if (!($this->bitmap & SSH2::MASK_LOGIN)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1612,7 +1609,7 @@ class Net_SFTP extends Net_SSH2
|
|||||||
*/
|
*/
|
||||||
function mkdir($dir, $mode = -1, $recursive = false)
|
function mkdir($dir, $mode = -1, $recursive = false)
|
||||||
{
|
{
|
||||||
if (!($this->bitmap & Net_SSH2::MASK_LOGIN)) {
|
if (!($this->bitmap & SSH2::MASK_LOGIN)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1675,7 +1672,7 @@ class Net_SFTP extends Net_SSH2
|
|||||||
*/
|
*/
|
||||||
function rmdir($dir)
|
function rmdir($dir)
|
||||||
{
|
{
|
||||||
if (!($this->bitmap & Net_SSH2::MASK_LOGIN)) {
|
if (!($this->bitmap & SSH2::MASK_LOGIN)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1713,8 +1710,8 @@ class Net_SFTP extends Net_SSH2
|
|||||||
/**
|
/**
|
||||||
* Uploads a file to the SFTP server.
|
* Uploads a file to the SFTP server.
|
||||||
*
|
*
|
||||||
* By default, Net_SFTP::put() does not read from the local filesystem. $data is dumped directly into $remote_file.
|
* By default, \phpseclib\Net\SFTP::put() does not read from the local filesystem. $data is dumped directly into $remote_file.
|
||||||
* So, for example, if you set $data to 'filename.ext' and then do Net_SFTP::get(), you will get a file, twelve bytes
|
* So, for example, if you set $data to 'filename.ext' and then do \phpseclib\Net\SFTP::get(), you will get a file, twelve bytes
|
||||||
* long, containing 'filename.ext' as its contents.
|
* long, containing 'filename.ext' as its contents.
|
||||||
*
|
*
|
||||||
* Setting $mode to self::SOURCE_LOCAL_FILE will change the above behavior. With self::SOURCE_LOCAL_FILE, $remote_file will
|
* Setting $mode to self::SOURCE_LOCAL_FILE will change the above behavior. With self::SOURCE_LOCAL_FILE, $remote_file will
|
||||||
@ -1750,11 +1747,11 @@ class Net_SFTP extends Net_SSH2
|
|||||||
* @param optional Integer $local_start
|
* @param optional Integer $local_start
|
||||||
* @return Boolean
|
* @return Boolean
|
||||||
* @access public
|
* @access public
|
||||||
* @internal ASCII mode for SFTPv4/5/6 can be supported by adding a new function - Net_SFTP::setMode().
|
* @internal ASCII mode for SFTPv4/5/6 can be supported by adding a new function - \phpseclib\Net\SFTP::setMode().
|
||||||
*/
|
*/
|
||||||
function put($remote_file, $data, $mode = self::SOURCE_STRING, $start = -1, $local_start = -1)
|
function put($remote_file, $data, $mode = self::SOURCE_STRING, $start = -1, $local_start = -1)
|
||||||
{
|
{
|
||||||
if (!($this->bitmap & Net_SSH2::MASK_LOGIN)) {
|
if (!($this->bitmap & SSH2::MASK_LOGIN)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1953,7 +1950,7 @@ class Net_SFTP extends Net_SSH2
|
|||||||
*/
|
*/
|
||||||
function get($remote_file, $local_file = false, $offset = 0, $length = -1)
|
function get($remote_file, $local_file = false, $offset = 0, $length = -1)
|
||||||
{
|
{
|
||||||
if (!($this->bitmap & Net_SSH2::MASK_LOGIN)) {
|
if (!($this->bitmap & SSH2::MASK_LOGIN)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2067,7 +2064,7 @@ class Net_SFTP extends Net_SSH2
|
|||||||
*/
|
*/
|
||||||
function delete($path, $recursive = true)
|
function delete($path, $recursive = true)
|
||||||
{
|
{
|
||||||
if (!($this->bitmap & Net_SSH2::MASK_LOGIN)) {
|
if (!($this->bitmap & SSH2::MASK_LOGIN)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2382,7 +2379,7 @@ class Net_SFTP extends Net_SSH2
|
|||||||
*/
|
*/
|
||||||
function rename($oldname, $newname)
|
function rename($oldname, $newname)
|
||||||
{
|
{
|
||||||
if (!($this->bitmap & Net_SSH2::MASK_LOGIN)) {
|
if (!($this->bitmap & SSH2::MASK_LOGIN)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2557,8 +2554,8 @@ class Net_SFTP extends Net_SSH2
|
|||||||
*
|
*
|
||||||
* @param Integer $type
|
* @param Integer $type
|
||||||
* @param String $data
|
* @param String $data
|
||||||
* @see Net_SFTP::_get_sftp_packet()
|
* @see \phpseclib\Net\SFTP::_get_sftp_packet()
|
||||||
* @see Net_SSH2::_send_channel_packet()
|
* @see \phpseclib\Net\SSH2::_send_channel_packet()
|
||||||
* @return Boolean
|
* @return Boolean
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -2599,7 +2596,7 @@ class Net_SFTP extends Net_SSH2
|
|||||||
* There can be one SSH_MSG_CHANNEL_DATA messages containing two SFTP packets or there can be two SSH_MSG_CHANNEL_DATA
|
* There can be one SSH_MSG_CHANNEL_DATA messages containing two SFTP packets or there can be two SSH_MSG_CHANNEL_DATA
|
||||||
* messages containing one SFTP packet.
|
* messages containing one SFTP packet.
|
||||||
*
|
*
|
||||||
* @see Net_SFTP::_send_sftp_packet()
|
* @see \phpseclib\Net\SFTP::_send_sftp_packet()
|
||||||
* @return String
|
* @return String
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
|
@ -8,21 +8,25 @@
|
|||||||
* PHP version 5
|
* PHP version 5
|
||||||
*
|
*
|
||||||
* @category Net
|
* @category Net
|
||||||
* @package Net_SFTP_Stream
|
* @package SFTP
|
||||||
* @author Jim Wigginton <terrafrost@php.net>
|
* @author Jim Wigginton <terrafrost@php.net>
|
||||||
* @copyright 2013 Jim Wigginton
|
* @copyright 2013 Jim Wigginton
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
* @link http://phpseclib.sourceforge.net
|
* @link http://phpseclib.sourceforge.net
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
namespace phpseclib\Net\SFTP;
|
||||||
|
|
||||||
|
use phpseclib\Net\SFTP;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SFTP Stream Wrapper
|
* SFTP Stream Wrapper
|
||||||
*
|
*
|
||||||
* @package Net_SFTP_Stream
|
* @package SFTP
|
||||||
* @author Jim Wigginton <terrafrost@php.net>
|
* @author Jim Wigginton <terrafrost@php.net>
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
class Net_SFTP_Stream
|
class Stream
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* SFTP instances
|
* SFTP instances
|
||||||
@ -133,10 +137,6 @@ class Net_SFTP_Stream
|
|||||||
if (defined('NET_SFTP_STREAM_LOGGING')) {
|
if (defined('NET_SFTP_STREAM_LOGGING')) {
|
||||||
echo "__construct()\r\n";
|
echo "__construct()\r\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!class_exists('Net_SFTP')) {
|
|
||||||
include_once 'Net/SFTP.php';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -169,7 +169,7 @@ class Net_SFTP_Stream
|
|||||||
if ($host[0] == '$') {
|
if ($host[0] == '$') {
|
||||||
$host = substr($host, 1);
|
$host = substr($host, 1);
|
||||||
global $$host;
|
global $$host;
|
||||||
if (!is_object($$host) || get_class($$host) != 'Net_SFTP') {
|
if (!is_object($$host) || get_class($$host) != 'phpseclib\Net\SFTP') {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$this->sftp = $$host;
|
$this->sftp = $$host;
|
||||||
@ -183,7 +183,7 @@ class Net_SFTP_Stream
|
|||||||
if (isset($context[$scheme]['sftp'])) {
|
if (isset($context[$scheme]['sftp'])) {
|
||||||
$sftp = $context[$scheme]['sftp'];
|
$sftp = $context[$scheme]['sftp'];
|
||||||
}
|
}
|
||||||
if (isset($sftp) && is_object($sftp) && get_class($sftp) == 'Net_SFTP') {
|
if (isset($sftp) && is_object($sftp) && get_class($sftp) == 'phpseclib\Net\SFTP') {
|
||||||
$this->sftp = $sftp;
|
$this->sftp = $sftp;
|
||||||
return $path;
|
return $path;
|
||||||
}
|
}
|
||||||
@ -205,7 +205,7 @@ class Net_SFTP_Stream
|
|||||||
if (isset(self::$instances[$host][$port][$user][(string) $pass])) {
|
if (isset(self::$instances[$host][$port][$user][(string) $pass])) {
|
||||||
$this->sftp = self::$instances[$host][$port][$user][(string) $pass];
|
$this->sftp = self::$instances[$host][$port][$user][(string) $pass];
|
||||||
} else {
|
} else {
|
||||||
$this->sftp = new Net_SFTP($host, $port);
|
$this->sftp = new SFTP($host, $port);
|
||||||
$this->sftp->disableStatCache();
|
$this->sftp->disableStatCache();
|
||||||
if (isset($this->notification) && is_callable($this->notification)) {
|
if (isset($this->notification) && is_callable($this->notification)) {
|
||||||
/* if !is_callable($this->notification) we could do this:
|
/* if !is_callable($this->notification) we could do this:
|
||||||
@ -334,7 +334,7 @@ class Net_SFTP_Stream
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $this->sftp->put($this->path, $data, Net_SFTP::SOURCE_STRING, $this->pos);
|
$result = $this->sftp->put($this->path, $data, SFTP::SOURCE_STRING, $this->pos);
|
||||||
if (isset($this->notification) && is_callable($this->notification)) {
|
if (isset($this->notification) && is_callable($this->notification)) {
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
call_user_func($this->notification, STREAM_NOTIFY_FAILURE, STREAM_NOTIFY_SEVERITY_ERR, $this->sftp->getLastSFTPError(), NET_SFTP_OPEN, 0, 0);
|
call_user_func($this->notification, STREAM_NOTIFY_FAILURE, STREAM_NOTIFY_SEVERITY_ERR, $this->sftp->getLastSFTPError(), NET_SFTP_OPEN, 0, 0);
|
||||||
@ -474,7 +474,7 @@ class Net_SFTP_Stream
|
|||||||
* Renames a file or directory
|
* Renames a file or directory
|
||||||
*
|
*
|
||||||
* Attempts to rename oldname to newname, moving it between directories if necessary.
|
* Attempts to rename oldname to newname, moving it between directories if necessary.
|
||||||
* If newname exists, it will be overwritten. This is a departure from what Net_SFTP
|
* If newname exists, it will be overwritten. This is a departure from what \phpseclib\Net\SFTP
|
||||||
* does.
|
* does.
|
||||||
*
|
*
|
||||||
* @param String $path_from
|
* @param String $path_from
|
||||||
@ -630,7 +630,7 @@ class Net_SFTP_Stream
|
|||||||
/**
|
/**
|
||||||
* Flushes the output
|
* Flushes the output
|
||||||
*
|
*
|
||||||
* See <http://php.net/fflush>. Always returns true because Net_SFTP doesn't cache stuff before writing
|
* See <http://php.net/fflush>. Always returns true because \phpseclib\Net\SFTP doesn't cache stuff before writing
|
||||||
*
|
*
|
||||||
* @return Boolean
|
* @return Boolean
|
||||||
* @access public
|
* @access public
|
||||||
@ -675,7 +675,7 @@ class Net_SFTP_Stream
|
|||||||
/**
|
/**
|
||||||
* Retrieve information about a file
|
* Retrieve information about a file
|
||||||
*
|
*
|
||||||
* Ignores the STREAM_URL_STAT_QUIET flag because the entirety of Net_SFTP_Stream is quiet by default
|
* Ignores the STREAM_URL_STAT_QUIET flag because the entirety of \phpseclib\Net\SFTP\Stream is quiet by default
|
||||||
* might be worthwhile to reconstruct bits 12-16 (ie. the file type) if mode doesn't have them but we'll
|
* might be worthwhile to reconstruct bits 12-16 (ie. the file type) if mode doesn't have them but we'll
|
||||||
* cross that bridge when and if it's reached
|
* cross that bridge when and if it's reached
|
||||||
*
|
*
|
||||||
@ -722,7 +722,7 @@ class Net_SFTP_Stream
|
|||||||
* Change stream options
|
* Change stream options
|
||||||
*
|
*
|
||||||
* STREAM_OPTION_WRITE_BUFFER isn't supported for the same reason stream_flush isn't.
|
* STREAM_OPTION_WRITE_BUFFER isn't supported for the same reason stream_flush isn't.
|
||||||
* The other two aren't supported because of limitations in Net_SFTP.
|
* The other two aren't supported because of limitations in \phpseclib\Net\SFTP.
|
||||||
*
|
*
|
||||||
* @param Integer $option
|
* @param Integer $option
|
||||||
* @param Integer $arg1
|
* @param Integer $arg1
|
||||||
|
@ -8,9 +8,9 @@
|
|||||||
* Here's a short example of how to use this library:
|
* Here's a short example of how to use this library:
|
||||||
* <code>
|
* <code>
|
||||||
* <?php
|
* <?php
|
||||||
* include 'Net/SSH1.php';
|
* include 'vendor/autoload.php';
|
||||||
*
|
*
|
||||||
* $ssh = new Net_SSH1('www.domain.tld');
|
* $ssh = new \phpseclib\Net\SSH1('www.domain.tld');
|
||||||
* if (!$ssh->login('username', 'password')) {
|
* if (!$ssh->login('username', 'password')) {
|
||||||
* exit('Login Failed');
|
* exit('Login Failed');
|
||||||
* }
|
* }
|
||||||
@ -22,9 +22,9 @@
|
|||||||
* Here's another short example:
|
* Here's another short example:
|
||||||
* <code>
|
* <code>
|
||||||
* <?php
|
* <?php
|
||||||
* include 'Net/SSH1.php';
|
* include 'vendor/autoload.php';
|
||||||
*
|
*
|
||||||
* $ssh = new Net_SSH1('www.domain.tld');
|
* $ssh = new \phpseclib\Net\SSH1('www.domain.tld');
|
||||||
* if (!$ssh->login('username', 'password')) {
|
* if (!$ssh->login('username', 'password')) {
|
||||||
* exit('Login Failed');
|
* exit('Login Failed');
|
||||||
* }
|
* }
|
||||||
@ -39,29 +39,36 @@
|
|||||||
* {@link http://www.snailbook.com/docs/protocol-1.5.txt protocol-1.5.txt}.
|
* {@link http://www.snailbook.com/docs/protocol-1.5.txt protocol-1.5.txt}.
|
||||||
*
|
*
|
||||||
* @category Net
|
* @category Net
|
||||||
* @package Net_SSH1
|
* @package SSH1
|
||||||
* @author Jim Wigginton <terrafrost@php.net>
|
* @author Jim Wigginton <terrafrost@php.net>
|
||||||
* @copyright 2007 Jim Wigginton
|
* @copyright 2007 Jim Wigginton
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
* @link http://phpseclib.sourceforge.net
|
* @link http://phpseclib.sourceforge.net
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use \phpseclib\Crypt\Random;
|
namespace phpseclib\Net;
|
||||||
use \phpseclib\Math\BigInteger;
|
|
||||||
|
// These should be removed once the Crypt package is fully namespaced
|
||||||
|
use Crypt_DES;
|
||||||
|
use Crypt_TripleDES;
|
||||||
|
// End unnecessary Use Statements
|
||||||
|
|
||||||
|
use phpseclib\Crypt\Random;
|
||||||
|
use phpseclib\Math\BigInteger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pure-PHP implementation of SSHv1.
|
* Pure-PHP implementation of SSHv1.
|
||||||
*
|
*
|
||||||
* @package Net_SSH1
|
* @package SSH1
|
||||||
* @author Jim Wigginton <terrafrost@php.net>
|
* @author Jim Wigginton <terrafrost@php.net>
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
class Net_SSH1
|
class SSH1
|
||||||
{
|
{
|
||||||
/**#@+
|
/**#@+
|
||||||
* Encryption Methods
|
* Encryption Methods
|
||||||
*
|
*
|
||||||
* @see Net_SSH1::getSupportedCiphers()
|
* @see \phpseclib\Net\SSH1::getSupportedCiphers()
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
@ -121,7 +128,7 @@ class Net_SSH1
|
|||||||
/**#@+
|
/**#@+
|
||||||
* Authentication Methods
|
* Authentication Methods
|
||||||
*
|
*
|
||||||
* @see Net_SSH1::getSupportedAuthentications()
|
* @see \phpseclib\Net\SSH1::getSupportedAuthentications()
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
@ -156,7 +163,7 @@ class Net_SSH1
|
|||||||
/**
|
/**
|
||||||
* The Response Type
|
* The Response Type
|
||||||
*
|
*
|
||||||
* @see Net_SSH1::_get_binary_packet()
|
* @see \phpseclib\Net\SSH1::_get_binary_packet()
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
const RESPONSE_TYPE = 1;
|
const RESPONSE_TYPE = 1;
|
||||||
@ -164,7 +171,7 @@ class Net_SSH1
|
|||||||
/**
|
/**
|
||||||
* The Response Data
|
* The Response Data
|
||||||
*
|
*
|
||||||
* @see Net_SSH1::_get_binary_packet()
|
* @see \phpseclib\Net\SSH1::_get_binary_packet()
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
const RESPONSE_DATA = 2;
|
const RESPONSE_DATA = 2;
|
||||||
@ -172,7 +179,7 @@ class Net_SSH1
|
|||||||
/**#@+
|
/**#@+
|
||||||
* Execution Bitmap Masks
|
* Execution Bitmap Masks
|
||||||
*
|
*
|
||||||
* @see Net_SSH1::bitmap
|
* @see \phpseclib\Net\SSH1::bitmap
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
const MASK_CONSTRUCTOR = 0x00000001;
|
const MASK_CONSTRUCTOR = 0x00000001;
|
||||||
@ -183,7 +190,7 @@ class Net_SSH1
|
|||||||
|
|
||||||
/**#@+
|
/**#@+
|
||||||
* @access public
|
* @access public
|
||||||
* @see Net_SSH1::getLog()
|
* @see \phpseclib\Net\SSH1::getLog()
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* Returns the message numbers
|
* Returns the message numbers
|
||||||
@ -205,7 +212,7 @@ class Net_SSH1
|
|||||||
|
|
||||||
/**#@+
|
/**#@+
|
||||||
* @access public
|
* @access public
|
||||||
* @see Net_SSH1::read()
|
* @see \phpseclib\Net\SSH1::read()
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* Returns when a string matching $expect exactly is found
|
* Returns when a string matching $expect exactly is found
|
||||||
@ -257,7 +264,7 @@ class Net_SSH1
|
|||||||
*
|
*
|
||||||
* Logged for debug purposes
|
* Logged for debug purposes
|
||||||
*
|
*
|
||||||
* @see Net_SSH1::getServerKeyPublicExponent()
|
* @see \phpseclib\Net\SSH1::getServerKeyPublicExponent()
|
||||||
* @var String
|
* @var String
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -268,7 +275,7 @@ class Net_SSH1
|
|||||||
*
|
*
|
||||||
* Logged for debug purposes
|
* Logged for debug purposes
|
||||||
*
|
*
|
||||||
* @see Net_SSH1::getServerKeyPublicModulus()
|
* @see \phpseclib\Net\SSH1::getServerKeyPublicModulus()
|
||||||
* @var String
|
* @var String
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -279,7 +286,7 @@ class Net_SSH1
|
|||||||
*
|
*
|
||||||
* Logged for debug purposes
|
* Logged for debug purposes
|
||||||
*
|
*
|
||||||
* @see Net_SSH1::getHostKeyPublicExponent()
|
* @see \phpseclib\Net\SSH1::getHostKeyPublicExponent()
|
||||||
* @var String
|
* @var String
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -290,7 +297,7 @@ class Net_SSH1
|
|||||||
*
|
*
|
||||||
* Logged for debug purposes
|
* Logged for debug purposes
|
||||||
*
|
*
|
||||||
* @see Net_SSH1::getHostKeyPublicModulus()
|
* @see \phpseclib\Net\SSH1::getHostKeyPublicModulus()
|
||||||
* @var String
|
* @var String
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -301,7 +308,7 @@ class Net_SSH1
|
|||||||
*
|
*
|
||||||
* Logged for debug purposes
|
* Logged for debug purposes
|
||||||
*
|
*
|
||||||
* @see Net_SSH1::getSupportedCiphers()
|
* @see \phpseclib\Net\SSH1::getSupportedCiphers()
|
||||||
* @var Array
|
* @var Array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -320,7 +327,7 @@ class Net_SSH1
|
|||||||
*
|
*
|
||||||
* Logged for debug purposes
|
* Logged for debug purposes
|
||||||
*
|
*
|
||||||
* @see Net_SSH1::getSupportedAuthentications()
|
* @see \phpseclib\Net\SSH1::getSupportedAuthentications()
|
||||||
* @var Array
|
* @var Array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -334,7 +341,7 @@ class Net_SSH1
|
|||||||
/**
|
/**
|
||||||
* Server Identification
|
* Server Identification
|
||||||
*
|
*
|
||||||
* @see Net_SSH1::getServerIdentification()
|
* @see \phpseclib\Net\SSH1::getServerIdentification()
|
||||||
* @var String
|
* @var String
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -343,7 +350,7 @@ class Net_SSH1
|
|||||||
/**
|
/**
|
||||||
* Protocol Flags
|
* Protocol Flags
|
||||||
*
|
*
|
||||||
* @see Net_SSH1::__construct()
|
* @see \phpseclib\Net\SSH1::__construct()
|
||||||
* @var Array
|
* @var Array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -352,7 +359,7 @@ class Net_SSH1
|
|||||||
/**
|
/**
|
||||||
* Protocol Flag Log
|
* Protocol Flag Log
|
||||||
*
|
*
|
||||||
* @see Net_SSH1::getLog()
|
* @see \phpseclib\Net\SSH1::getLog()
|
||||||
* @var Array
|
* @var Array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -361,7 +368,7 @@ class Net_SSH1
|
|||||||
/**
|
/**
|
||||||
* Message Log
|
* Message Log
|
||||||
*
|
*
|
||||||
* @see Net_SSH1::getLog()
|
* @see \phpseclib\Net\SSH1::getLog()
|
||||||
* @var Array
|
* @var Array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -370,7 +377,7 @@ class Net_SSH1
|
|||||||
/**
|
/**
|
||||||
* Real-time log file pointer
|
* Real-time log file pointer
|
||||||
*
|
*
|
||||||
* @see Net_SSH1::_append_log()
|
* @see \phpseclib\Net\SSH1::_append_log()
|
||||||
* @var Resource
|
* @var Resource
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -379,7 +386,7 @@ class Net_SSH1
|
|||||||
/**
|
/**
|
||||||
* Real-time log file size
|
* Real-time log file size
|
||||||
*
|
*
|
||||||
* @see Net_SSH1::_append_log()
|
* @see \phpseclib\Net\SSH1::_append_log()
|
||||||
* @var Integer
|
* @var Integer
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -388,7 +395,7 @@ class Net_SSH1
|
|||||||
/**
|
/**
|
||||||
* Real-time log file wrap boolean
|
* Real-time log file wrap boolean
|
||||||
*
|
*
|
||||||
* @see Net_SSH1::_append_log()
|
* @see \phpseclib\Net\SSH1::_append_log()
|
||||||
* @var Boolean
|
* @var Boolean
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -397,7 +404,7 @@ class Net_SSH1
|
|||||||
/**
|
/**
|
||||||
* Interactive Buffer
|
* Interactive Buffer
|
||||||
*
|
*
|
||||||
* @see Net_SSH1::read()
|
* @see \phpseclib\Net\SSH1::read()
|
||||||
* @var Array
|
* @var Array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -406,7 +413,7 @@ class Net_SSH1
|
|||||||
/**
|
/**
|
||||||
* Timeout
|
* Timeout
|
||||||
*
|
*
|
||||||
* @see Net_SSH1::setTimeout()
|
* @see \phpseclib\Net\SSH1::setTimeout()
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $timeout;
|
var $timeout;
|
||||||
@ -414,7 +421,7 @@ class Net_SSH1
|
|||||||
/**
|
/**
|
||||||
* Current Timeout
|
* Current Timeout
|
||||||
*
|
*
|
||||||
* @see Net_SSH1::_get_channel_packet()
|
* @see \phpseclib\Net\SSH1::_get_channel_packet()
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $curTimeout;
|
var $curTimeout;
|
||||||
@ -422,7 +429,7 @@ class Net_SSH1
|
|||||||
/**
|
/**
|
||||||
* Log Boundary
|
* Log Boundary
|
||||||
*
|
*
|
||||||
* @see Net_SSH1::_format_log
|
* @see \phpseclib\Net\SSH1::_format_log
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $log_boundary = ':';
|
var $log_boundary = ':';
|
||||||
@ -430,7 +437,7 @@ class Net_SSH1
|
|||||||
/**
|
/**
|
||||||
* Log Long Width
|
* Log Long Width
|
||||||
*
|
*
|
||||||
* @see Net_SSH1::_format_log
|
* @see \phpseclib\Net\SSH1::_format_log
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $log_long_width = 65;
|
var $log_long_width = 65;
|
||||||
@ -438,7 +445,7 @@ class Net_SSH1
|
|||||||
/**
|
/**
|
||||||
* Log Short Width
|
* Log Short Width
|
||||||
*
|
*
|
||||||
* @see Net_SSH1::_format_log
|
* @see \phpseclib\Net\SSH1::_format_log
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $log_short_width = 16;
|
var $log_short_width = 16;
|
||||||
@ -446,8 +453,8 @@ class Net_SSH1
|
|||||||
/**
|
/**
|
||||||
* Hostname
|
* Hostname
|
||||||
*
|
*
|
||||||
* @see Net_SSH1::__construct()
|
* @see \phpseclib\Net\SSH1::__construct()
|
||||||
* @see Net_SSH1::_connect()
|
* @see \phpseclib\Net\SSH1::_connect()
|
||||||
* @var String
|
* @var String
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -456,8 +463,8 @@ class Net_SSH1
|
|||||||
/**
|
/**
|
||||||
* Port Number
|
* Port Number
|
||||||
*
|
*
|
||||||
* @see Net_SSH1::__construct()
|
* @see \phpseclib\Net\SSH1::__construct()
|
||||||
* @see Net_SSH1::_connect()
|
* @see \phpseclib\Net\SSH1::_connect()
|
||||||
* @var Integer
|
* @var Integer
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -471,8 +478,8 @@ class Net_SSH1
|
|||||||
* however, is non-optional. There will be a timeout, whether or not you set it. If you don't it'll be
|
* however, is non-optional. There will be a timeout, whether or not you set it. If you don't it'll be
|
||||||
* 10 seconds. It is used by fsockopen() in that function.
|
* 10 seconds. It is used by fsockopen() in that function.
|
||||||
*
|
*
|
||||||
* @see Net_SSH1::__construct()
|
* @see \phpseclib\Net\SSH1::__construct()
|
||||||
* @see Net_SSH1::_connect()
|
* @see \phpseclib\Net\SSH1::_connect()
|
||||||
* @var Integer
|
* @var Integer
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -481,8 +488,8 @@ class Net_SSH1
|
|||||||
/**
|
/**
|
||||||
* Default cipher
|
* Default cipher
|
||||||
*
|
*
|
||||||
* @see Net_SSH1::__construct()
|
* @see \phpseclib\Net\SSH1::__construct()
|
||||||
* @see Net_SSH1::_connect()
|
* @see \phpseclib\Net\SSH1::_connect()
|
||||||
* @var Integer
|
* @var Integer
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -497,7 +504,7 @@ class Net_SSH1
|
|||||||
* @param optional Integer $port
|
* @param optional Integer $port
|
||||||
* @param optional Integer $timeout
|
* @param optional Integer $timeout
|
||||||
* @param optional Integer $cipher
|
* @param optional Integer $cipher
|
||||||
* @return Net_SSH1
|
* @return \phpseclib\Net\SSH1
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function __construct($host, $port = 22, $timeout = 10, $cipher = self::CIPHER_3DES)
|
function __construct($host, $port = 22, $timeout = 10, $cipher = self::CIPHER_3DES)
|
||||||
@ -789,12 +796,12 @@ class Net_SSH1
|
|||||||
* {@link http://www.faqs.org/docs/bashman/bashref_65.html http://www.faqs.org/docs/bashman/bashref_65.html}
|
* {@link http://www.faqs.org/docs/bashman/bashref_65.html http://www.faqs.org/docs/bashman/bashref_65.html}
|
||||||
* {@link http://www.faqs.org/docs/bashman/bashref_62.html http://www.faqs.org/docs/bashman/bashref_62.html}
|
* {@link http://www.faqs.org/docs/bashman/bashref_62.html http://www.faqs.org/docs/bashman/bashref_62.html}
|
||||||
*
|
*
|
||||||
* To execute further commands, a new Net_SSH1 object will need to be created.
|
* To execute further commands, a new \phpseclib\Net\SSH1 object will need to be created.
|
||||||
*
|
*
|
||||||
* Returns false on failure and the output, otherwise.
|
* Returns false on failure and the output, otherwise.
|
||||||
*
|
*
|
||||||
* @see Net_SSH1::interactiveRead()
|
* @see \phpseclib\Net\SSH1::interactiveRead()
|
||||||
* @see Net_SSH1::interactiveWrite()
|
* @see \phpseclib\Net\SSH1::interactiveWrite()
|
||||||
* @param String $cmd
|
* @param String $cmd
|
||||||
* @return mixed
|
* @return mixed
|
||||||
* @access public
|
* @access public
|
||||||
@ -834,7 +841,7 @@ class Net_SSH1
|
|||||||
|
|
||||||
fclose($this->fsock);
|
fclose($this->fsock);
|
||||||
|
|
||||||
// reset the execution bitmap - a new Net_SSH1 object needs to be created.
|
// reset the execution bitmap - a new \phpseclib\Net\SSH1 object needs to be created.
|
||||||
$this->bitmap = 0;
|
$this->bitmap = 0;
|
||||||
|
|
||||||
return $output;
|
return $output;
|
||||||
@ -843,8 +850,8 @@ class Net_SSH1
|
|||||||
/**
|
/**
|
||||||
* Creates an interactive shell
|
* Creates an interactive shell
|
||||||
*
|
*
|
||||||
* @see Net_SSH1::interactiveRead()
|
* @see \phpseclib\Net\SSH1::interactiveRead()
|
||||||
* @see Net_SSH1::interactiveWrite()
|
* @see \phpseclib\Net\SSH1::interactiveWrite()
|
||||||
* @return Boolean
|
* @return Boolean
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -887,7 +894,7 @@ class Net_SSH1
|
|||||||
/**
|
/**
|
||||||
* Inputs a command into an interactive shell.
|
* Inputs a command into an interactive shell.
|
||||||
*
|
*
|
||||||
* @see Net_SSH1::interactiveWrite()
|
* @see \phpseclib\Net\SSH1::interactiveWrite()
|
||||||
* @param String $cmd
|
* @param String $cmd
|
||||||
* @return Boolean
|
* @return Boolean
|
||||||
* @access public
|
* @access public
|
||||||
@ -903,7 +910,7 @@ class Net_SSH1
|
|||||||
* $expect can take the form of a string literal or, if $mode == self::READ__REGEX,
|
* $expect can take the form of a string literal or, if $mode == self::READ__REGEX,
|
||||||
* a regular expression.
|
* a regular expression.
|
||||||
*
|
*
|
||||||
* @see Net_SSH1::write()
|
* @see \phpseclib\Net\SSH1::write()
|
||||||
* @param String $expect
|
* @param String $expect
|
||||||
* @param Integer $mode
|
* @param Integer $mode
|
||||||
* @return Boolean
|
* @return Boolean
|
||||||
@ -943,7 +950,7 @@ class Net_SSH1
|
|||||||
/**
|
/**
|
||||||
* Inputs a command into an interactive shell.
|
* Inputs a command into an interactive shell.
|
||||||
*
|
*
|
||||||
* @see Net_SSH1::interactiveRead()
|
* @see \phpseclib\Net\SSH1::interactiveRead()
|
||||||
* @param String $cmd
|
* @param String $cmd
|
||||||
* @return Boolean
|
* @return Boolean
|
||||||
* @access public
|
* @access public
|
||||||
@ -979,7 +986,7 @@ class Net_SSH1
|
|||||||
* does not support ANSI escape sequences in Win32 Console applications", so if you're a Windows user,
|
* does not support ANSI escape sequences in Win32 Console applications", so if you're a Windows user,
|
||||||
* there's not going to be much recourse.
|
* there's not going to be much recourse.
|
||||||
*
|
*
|
||||||
* @see Net_SSH1::interactiveRead()
|
* @see \phpseclib\Net\SSH1::interactiveRead()
|
||||||
* @return String
|
* @return String
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
@ -1068,7 +1075,7 @@ class Net_SSH1
|
|||||||
* Also, this function could be improved upon by adding detection for the following exploit:
|
* Also, this function could be improved upon by adding detection for the following exploit:
|
||||||
* http://www.securiteam.com/securitynews/5LP042K3FY.html
|
* http://www.securiteam.com/securitynews/5LP042K3FY.html
|
||||||
*
|
*
|
||||||
* @see Net_SSH1::_send_binary_packet()
|
* @see \phpseclib\Net\SSH1::_send_binary_packet()
|
||||||
* @return Array
|
* @return Array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -1143,7 +1150,7 @@ class Net_SSH1
|
|||||||
*
|
*
|
||||||
* Returns true on success, false on failure.
|
* Returns true on success, false on failure.
|
||||||
*
|
*
|
||||||
* @see Net_SSH1::_get_binary_packet()
|
* @see \phpseclib\Net\SSH1::_get_binary_packet()
|
||||||
* @param String $data
|
* @param String $data
|
||||||
* @return Boolean
|
* @return Boolean
|
||||||
* @access private
|
* @access private
|
||||||
@ -1190,8 +1197,8 @@ class Net_SSH1
|
|||||||
* we've reimplemented it. A more detailed discussion of the differences can be found after
|
* we've reimplemented it. A more detailed discussion of the differences can be found after
|
||||||
* $crc_lookup_table's initialization.
|
* $crc_lookup_table's initialization.
|
||||||
*
|
*
|
||||||
* @see Net_SSH1::_get_binary_packet()
|
* @see \phpseclib\Net\SSH1::_get_binary_packet()
|
||||||
* @see Net_SSH1::_send_binary_packet()
|
* @see \phpseclib\Net\SSH1::_send_binary_packet()
|
||||||
* @param String $data
|
* @param String $data
|
||||||
* @return Integer
|
* @return Integer
|
||||||
* @access private
|
* @access private
|
||||||
@ -1307,7 +1314,7 @@ class Net_SSH1
|
|||||||
* should be a number with the property that gcd($e, ($p - 1) * ($q - 1)) == 1. Could just make anything that
|
* should be a number with the property that gcd($e, ($p - 1) * ($q - 1)) == 1. Could just make anything that
|
||||||
* calls this call modexp, instead, but I think this makes things clearer, maybe...
|
* calls this call modexp, instead, but I think this makes things clearer, maybe...
|
||||||
*
|
*
|
||||||
* @see Net_SSH1::__construct()
|
* @see \phpseclib\Net\SSH1::__construct()
|
||||||
* @param BigInteger $m
|
* @param BigInteger $m
|
||||||
* @param Array $key
|
* @param Array $key
|
||||||
* @return BigInteger
|
* @return BigInteger
|
||||||
|
@ -8,9 +8,9 @@
|
|||||||
* Here are some examples of how to use this library:
|
* Here are some examples of how to use this library:
|
||||||
* <code>
|
* <code>
|
||||||
* <?php
|
* <?php
|
||||||
* include 'Net/SSH2.php';
|
* include 'vendor/autoload.php';
|
||||||
*
|
*
|
||||||
* $ssh = new Net_SSH2('www.domain.tld');
|
* $ssh = new \phpseclib\Net\SSH2('www.domain.tld');
|
||||||
* if (!$ssh->login('username', 'password')) {
|
* if (!$ssh->login('username', 'password')) {
|
||||||
* exit('Login Failed');
|
* exit('Login Failed');
|
||||||
* }
|
* }
|
||||||
@ -23,13 +23,13 @@
|
|||||||
* <code>
|
* <code>
|
||||||
* <?php
|
* <?php
|
||||||
* include 'Crypt/RSA.php';
|
* include 'Crypt/RSA.php';
|
||||||
* include 'Net/SSH2.php';
|
* include 'vendor/autoload.php';
|
||||||
*
|
*
|
||||||
* $key = new Crypt_RSA();
|
* $key = new Crypt_RSA();
|
||||||
* //$key->setPassword('whatever');
|
* //$key->setPassword('whatever');
|
||||||
* $key->loadKey(file_get_contents('privatekey'));
|
* $key->loadKey(file_get_contents('privatekey'));
|
||||||
*
|
*
|
||||||
* $ssh = new Net_SSH2('www.domain.tld');
|
* $ssh = new \phpseclib\Net\SSH2('www.domain.tld');
|
||||||
* if (!$ssh->login('username', $key)) {
|
* if (!$ssh->login('username', $key)) {
|
||||||
* exit('Login Failed');
|
* exit('Login Failed');
|
||||||
* }
|
* }
|
||||||
@ -41,30 +41,41 @@
|
|||||||
* </code>
|
* </code>
|
||||||
*
|
*
|
||||||
* @category Net
|
* @category Net
|
||||||
* @package Net_SSH2
|
* @package SSH2
|
||||||
* @author Jim Wigginton <terrafrost@php.net>
|
* @author Jim Wigginton <terrafrost@php.net>
|
||||||
* @copyright 2007 Jim Wigginton
|
* @copyright 2007 Jim Wigginton
|
||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
* @link http://phpseclib.sourceforge.net
|
* @link http://phpseclib.sourceforge.net
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use \phpseclib\Crypt\Random;
|
namespace phpseclib\Net;
|
||||||
|
|
||||||
|
// These should be removed once the Crypt package is fully namespaced
|
||||||
|
use Crypt_Blowfish;
|
||||||
|
use Crypt_Hash;
|
||||||
|
use Crypt_RC4;
|
||||||
|
use Crypt_Rijndael;
|
||||||
|
use Crypt_TripleDES;
|
||||||
|
use Crypt_Twofish;
|
||||||
|
// End unnecessary Use Statements
|
||||||
|
|
||||||
|
use phpseclib\Crypt\Random;
|
||||||
// Used to do Diffie-Hellman key exchange and DSA/RSA signature verification.
|
// Used to do Diffie-Hellman key exchange and DSA/RSA signature verification.
|
||||||
use \phpseclib\Math\BigInteger;
|
use phpseclib\Math\BigInteger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pure-PHP implementation of SSHv2.
|
* Pure-PHP implementation of SSHv2.
|
||||||
*
|
*
|
||||||
* @package Net_SSH2
|
* @package SSH2
|
||||||
* @author Jim Wigginton <terrafrost@php.net>
|
* @author Jim Wigginton <terrafrost@php.net>
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
class Net_SSH2
|
class SSH2
|
||||||
{
|
{
|
||||||
/**#@+
|
/**#@+
|
||||||
* Execution Bitmap Masks
|
* Execution Bitmap Masks
|
||||||
*
|
*
|
||||||
* @see Net_SSH2::bitmap
|
* @see \phpseclib\Net\SSH2::bitmap
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
const MASK_CONSTRUCTOR = 0x00000001;
|
const MASK_CONSTRUCTOR = 0x00000001;
|
||||||
@ -87,8 +98,8 @@ class Net_SSH2
|
|||||||
* open request, and 'sender channel' is the channel number allocated by
|
* open request, and 'sender channel' is the channel number allocated by
|
||||||
* the other side.
|
* the other side.
|
||||||
*
|
*
|
||||||
* @see Net_SSH2::_send_channel_packet()
|
* @see \phpseclib\Net\SSH2::_send_channel_packet()
|
||||||
* @see Net_SSH2::_get_channel_packet()
|
* @see \phpseclib\Net\SSH2::_get_channel_packet()
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
const CHANNEL_EXEC = 0; // PuTTy uses 0x100
|
const CHANNEL_EXEC = 0; // PuTTy uses 0x100
|
||||||
@ -98,7 +109,7 @@ class Net_SSH2
|
|||||||
|
|
||||||
/**#@+
|
/**#@+
|
||||||
* @access public
|
* @access public
|
||||||
* @see Net_SSH2::getLog()
|
* @see \phpseclib\Net\SSH2::getLog()
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* Returns the message numbers
|
* Returns the message numbers
|
||||||
@ -120,7 +131,7 @@ class Net_SSH2
|
|||||||
|
|
||||||
/**#@+
|
/**#@+
|
||||||
* @access public
|
* @access public
|
||||||
* @see Net_SSH2::read()
|
* @see \phpseclib\Net\SSH2::read()
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* Returns when a string matching $expect exactly is found
|
* Returns when a string matching $expect exactly is found
|
||||||
@ -166,8 +177,8 @@ class Net_SSH2
|
|||||||
/**
|
/**
|
||||||
* Error information
|
* Error information
|
||||||
*
|
*
|
||||||
* @see Net_SSH2::getErrors()
|
* @see \phpseclib\Net\SSH2::getErrors()
|
||||||
* @see Net_SSH2::getLastError()
|
* @see \phpseclib\Net\SSH2::getLastError()
|
||||||
* @var String
|
* @var String
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -176,7 +187,7 @@ class Net_SSH2
|
|||||||
/**
|
/**
|
||||||
* Server Identifier
|
* Server Identifier
|
||||||
*
|
*
|
||||||
* @see Net_SSH2::getServerIdentification()
|
* @see \phpseclib\Net\SSH2::getServerIdentification()
|
||||||
* @var mixed false or Array
|
* @var mixed false or Array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -185,7 +196,7 @@ class Net_SSH2
|
|||||||
/**
|
/**
|
||||||
* Key Exchange Algorithms
|
* Key Exchange Algorithms
|
||||||
*
|
*
|
||||||
* @see Net_SSH2::getKexAlgorithims()
|
* @see \phpseclib\Net\SSH2::getKexAlgorithims()
|
||||||
* @var mixed false or Array
|
* @var mixed false or Array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -194,7 +205,7 @@ class Net_SSH2
|
|||||||
/**
|
/**
|
||||||
* Server Host Key Algorithms
|
* Server Host Key Algorithms
|
||||||
*
|
*
|
||||||
* @see Net_SSH2::getServerHostKeyAlgorithms()
|
* @see \phpseclib\Net\SSH2::getServerHostKeyAlgorithms()
|
||||||
* @var mixed false or Array
|
* @var mixed false or Array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -203,7 +214,7 @@ class Net_SSH2
|
|||||||
/**
|
/**
|
||||||
* Encryption Algorithms: Client to Server
|
* Encryption Algorithms: Client to Server
|
||||||
*
|
*
|
||||||
* @see Net_SSH2::getEncryptionAlgorithmsClient2Server()
|
* @see \phpseclib\Net\SSH2::getEncryptionAlgorithmsClient2Server()
|
||||||
* @var mixed false or Array
|
* @var mixed false or Array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -212,7 +223,7 @@ class Net_SSH2
|
|||||||
/**
|
/**
|
||||||
* Encryption Algorithms: Server to Client
|
* Encryption Algorithms: Server to Client
|
||||||
*
|
*
|
||||||
* @see Net_SSH2::getEncryptionAlgorithmsServer2Client()
|
* @see \phpseclib\Net\SSH2::getEncryptionAlgorithmsServer2Client()
|
||||||
* @var mixed false or Array
|
* @var mixed false or Array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -221,7 +232,7 @@ class Net_SSH2
|
|||||||
/**
|
/**
|
||||||
* MAC Algorithms: Client to Server
|
* MAC Algorithms: Client to Server
|
||||||
*
|
*
|
||||||
* @see Net_SSH2::getMACAlgorithmsClient2Server()
|
* @see \phpseclib\Net\SSH2::getMACAlgorithmsClient2Server()
|
||||||
* @var mixed false or Array
|
* @var mixed false or Array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -230,7 +241,7 @@ class Net_SSH2
|
|||||||
/**
|
/**
|
||||||
* MAC Algorithms: Server to Client
|
* MAC Algorithms: Server to Client
|
||||||
*
|
*
|
||||||
* @see Net_SSH2::getMACAlgorithmsServer2Client()
|
* @see \phpseclib\Net\SSH2::getMACAlgorithmsServer2Client()
|
||||||
* @var mixed false or Array
|
* @var mixed false or Array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -239,7 +250,7 @@ class Net_SSH2
|
|||||||
/**
|
/**
|
||||||
* Compression Algorithms: Client to Server
|
* Compression Algorithms: Client to Server
|
||||||
*
|
*
|
||||||
* @see Net_SSH2::getCompressionAlgorithmsClient2Server()
|
* @see \phpseclib\Net\SSH2::getCompressionAlgorithmsClient2Server()
|
||||||
* @var mixed false or Array
|
* @var mixed false or Array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -248,7 +259,7 @@ class Net_SSH2
|
|||||||
/**
|
/**
|
||||||
* Compression Algorithms: Server to Client
|
* Compression Algorithms: Server to Client
|
||||||
*
|
*
|
||||||
* @see Net_SSH2::getCompressionAlgorithmsServer2Client()
|
* @see \phpseclib\Net\SSH2::getCompressionAlgorithmsServer2Client()
|
||||||
* @var mixed false or Array
|
* @var mixed false or Array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -257,7 +268,7 @@ class Net_SSH2
|
|||||||
/**
|
/**
|
||||||
* Languages: Server to Client
|
* Languages: Server to Client
|
||||||
*
|
*
|
||||||
* @see Net_SSH2::getLanguagesServer2Client()
|
* @see \phpseclib\Net\SSH2::getLanguagesServer2Client()
|
||||||
* @var mixed false or Array
|
* @var mixed false or Array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -266,7 +277,7 @@ class Net_SSH2
|
|||||||
/**
|
/**
|
||||||
* Languages: Client to Server
|
* Languages: Client to Server
|
||||||
*
|
*
|
||||||
* @see Net_SSH2::getLanguagesClient2Server()
|
* @see \phpseclib\Net\SSH2::getLanguagesClient2Server()
|
||||||
* @var mixed false or Array
|
* @var mixed false or Array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -282,8 +293,8 @@ class Net_SSH2
|
|||||||
*
|
*
|
||||||
* -- http://tools.ietf.org/html/rfc4253#section-6
|
* -- http://tools.ietf.org/html/rfc4253#section-6
|
||||||
*
|
*
|
||||||
* @see Net_SSH2::__construct()
|
* @see \phpseclib\Net\SSH2::__construct()
|
||||||
* @see Net_SSH2::_send_binary_packet()
|
* @see \phpseclib\Net\SSH2::_send_binary_packet()
|
||||||
* @var Integer
|
* @var Integer
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -292,8 +303,8 @@ class Net_SSH2
|
|||||||
/**
|
/**
|
||||||
* Block Size for Client to Server Encryption
|
* Block Size for Client to Server Encryption
|
||||||
*
|
*
|
||||||
* @see Net_SSH2::__construct()
|
* @see \phpseclib\Net\SSH2::__construct()
|
||||||
* @see Net_SSH2::_get_binary_packet()
|
* @see \phpseclib\Net\SSH2::_get_binary_packet()
|
||||||
* @var Integer
|
* @var Integer
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -302,7 +313,7 @@ class Net_SSH2
|
|||||||
/**
|
/**
|
||||||
* Server to Client Encryption Object
|
* Server to Client Encryption Object
|
||||||
*
|
*
|
||||||
* @see Net_SSH2::_get_binary_packet()
|
* @see \phpseclib\Net\SSH2::_get_binary_packet()
|
||||||
* @var Object
|
* @var Object
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -311,7 +322,7 @@ class Net_SSH2
|
|||||||
/**
|
/**
|
||||||
* Client to Server Encryption Object
|
* Client to Server Encryption Object
|
||||||
*
|
*
|
||||||
* @see Net_SSH2::_send_binary_packet()
|
* @see \phpseclib\Net\SSH2::_send_binary_packet()
|
||||||
* @var Object
|
* @var Object
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -320,7 +331,7 @@ class Net_SSH2
|
|||||||
/**
|
/**
|
||||||
* Client to Server HMAC Object
|
* Client to Server HMAC Object
|
||||||
*
|
*
|
||||||
* @see Net_SSH2::_send_binary_packet()
|
* @see \phpseclib\Net\SSH2::_send_binary_packet()
|
||||||
* @var Object
|
* @var Object
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -329,7 +340,7 @@ class Net_SSH2
|
|||||||
/**
|
/**
|
||||||
* Server to Client HMAC Object
|
* Server to Client HMAC Object
|
||||||
*
|
*
|
||||||
* @see Net_SSH2::_get_binary_packet()
|
* @see \phpseclib\Net\SSH2::_get_binary_packet()
|
||||||
* @var Object
|
* @var Object
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -342,7 +353,7 @@ class Net_SSH2
|
|||||||
* For the client to server side, the HMAC object will make the HMAC as long as it needs to be. All we need to do is
|
* For the client to server side, the HMAC object will make the HMAC as long as it needs to be. All we need to do is
|
||||||
* append it.
|
* append it.
|
||||||
*
|
*
|
||||||
* @see Net_SSH2::_get_binary_packet()
|
* @see \phpseclib\Net\SSH2::_get_binary_packet()
|
||||||
* @var Integer
|
* @var Integer
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -351,7 +362,7 @@ class Net_SSH2
|
|||||||
/**
|
/**
|
||||||
* Server Public Host Key
|
* Server Public Host Key
|
||||||
*
|
*
|
||||||
* @see Net_SSH2::getServerPublicHostKey()
|
* @see \phpseclib\Net\SSH2::getServerPublicHostKey()
|
||||||
* @var String
|
* @var String
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -366,7 +377,7 @@ class Net_SSH2
|
|||||||
*
|
*
|
||||||
* -- http://tools.ietf.org/html/rfc4253#section-7.2
|
* -- http://tools.ietf.org/html/rfc4253#section-7.2
|
||||||
*
|
*
|
||||||
* @see Net_SSH2::_key_exchange()
|
* @see \phpseclib\Net\SSH2::_key_exchange()
|
||||||
* @var String
|
* @var String
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -377,7 +388,7 @@ class Net_SSH2
|
|||||||
*
|
*
|
||||||
* The current exchange hash
|
* The current exchange hash
|
||||||
*
|
*
|
||||||
* @see Net_SSH2::_key_exchange()
|
* @see \phpseclib\Net\SSH2::_key_exchange()
|
||||||
* @var String
|
* @var String
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -386,7 +397,7 @@ class Net_SSH2
|
|||||||
/**
|
/**
|
||||||
* Message Numbers
|
* Message Numbers
|
||||||
*
|
*
|
||||||
* @see Net_SSH2::__construct()
|
* @see \phpseclib\Net\SSH2::__construct()
|
||||||
* @var Array
|
* @var Array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -395,7 +406,7 @@ class Net_SSH2
|
|||||||
/**
|
/**
|
||||||
* Disconnection Message 'reason codes' defined in RFC4253
|
* Disconnection Message 'reason codes' defined in RFC4253
|
||||||
*
|
*
|
||||||
* @see Net_SSH2::__construct()
|
* @see \phpseclib\Net\SSH2::__construct()
|
||||||
* @var Array
|
* @var Array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -404,7 +415,7 @@ class Net_SSH2
|
|||||||
/**
|
/**
|
||||||
* SSH_MSG_CHANNEL_OPEN_FAILURE 'reason codes', defined in RFC4254
|
* SSH_MSG_CHANNEL_OPEN_FAILURE 'reason codes', defined in RFC4254
|
||||||
*
|
*
|
||||||
* @see Net_SSH2::__construct()
|
* @see \phpseclib\Net\SSH2::__construct()
|
||||||
* @var Array
|
* @var Array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -414,7 +425,7 @@ class Net_SSH2
|
|||||||
* Terminal Modes
|
* Terminal Modes
|
||||||
*
|
*
|
||||||
* @link http://tools.ietf.org/html/rfc4254#section-8
|
* @link http://tools.ietf.org/html/rfc4254#section-8
|
||||||
* @see Net_SSH2::__construct()
|
* @see \phpseclib\Net\SSH2::__construct()
|
||||||
* @var Array
|
* @var Array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -424,7 +435,7 @@ class Net_SSH2
|
|||||||
* SSH_MSG_CHANNEL_EXTENDED_DATA's data_type_codes
|
* SSH_MSG_CHANNEL_EXTENDED_DATA's data_type_codes
|
||||||
*
|
*
|
||||||
* @link http://tools.ietf.org/html/rfc4254#section-5.2
|
* @link http://tools.ietf.org/html/rfc4254#section-5.2
|
||||||
* @see Net_SSH2::__construct()
|
* @see \phpseclib\Net\SSH2::__construct()
|
||||||
* @var Array
|
* @var Array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -435,7 +446,7 @@ class Net_SSH2
|
|||||||
*
|
*
|
||||||
* See 'Section 6.4. Data Integrity' of rfc4253 for more info.
|
* See 'Section 6.4. Data Integrity' of rfc4253 for more info.
|
||||||
*
|
*
|
||||||
* @see Net_SSH2::_send_binary_packet()
|
* @see \phpseclib\Net\SSH2::_send_binary_packet()
|
||||||
* @var Integer
|
* @var Integer
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -446,7 +457,7 @@ class Net_SSH2
|
|||||||
*
|
*
|
||||||
* See 'Section 6.4. Data Integrity' of rfc4253 for more info.
|
* See 'Section 6.4. Data Integrity' of rfc4253 for more info.
|
||||||
*
|
*
|
||||||
* @see Net_SSH2::_get_binary_packet()
|
* @see \phpseclib\Net\SSH2::_get_binary_packet()
|
||||||
* @var Integer
|
* @var Integer
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -457,8 +468,8 @@ class Net_SSH2
|
|||||||
*
|
*
|
||||||
* Maps client channels to server channels
|
* Maps client channels to server channels
|
||||||
*
|
*
|
||||||
* @see Net_SSH2::_get_channel_packet()
|
* @see \phpseclib\Net\SSH2::_get_channel_packet()
|
||||||
* @see Net_SSH2::exec()
|
* @see \phpseclib\Net\SSH2::exec()
|
||||||
* @var Array
|
* @var Array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -470,8 +481,8 @@ class Net_SSH2
|
|||||||
* If a client requests a packet from one channel but receives two packets from another those packets should
|
* If a client requests a packet from one channel but receives two packets from another those packets should
|
||||||
* be placed in a buffer
|
* be placed in a buffer
|
||||||
*
|
*
|
||||||
* @see Net_SSH2::_get_channel_packet()
|
* @see \phpseclib\Net\SSH2::_get_channel_packet()
|
||||||
* @see Net_SSH2::exec()
|
* @see \phpseclib\Net\SSH2::exec()
|
||||||
* @var Array
|
* @var Array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -482,7 +493,7 @@ class Net_SSH2
|
|||||||
*
|
*
|
||||||
* Contains the type of the last sent message
|
* Contains the type of the last sent message
|
||||||
*
|
*
|
||||||
* @see Net_SSH2::_get_channel_packet()
|
* @see \phpseclib\Net\SSH2::_get_channel_packet()
|
||||||
* @var Array
|
* @var Array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -493,7 +504,7 @@ class Net_SSH2
|
|||||||
*
|
*
|
||||||
* Maximum packet size indexed by channel
|
* Maximum packet size indexed by channel
|
||||||
*
|
*
|
||||||
* @see Net_SSH2::_send_channel_packet()
|
* @see \phpseclib\Net\SSH2::_send_channel_packet()
|
||||||
* @var Array
|
* @var Array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -502,7 +513,7 @@ class Net_SSH2
|
|||||||
/**
|
/**
|
||||||
* Message Number Log
|
* Message Number Log
|
||||||
*
|
*
|
||||||
* @see Net_SSH2::getLog()
|
* @see \phpseclib\Net\SSH2::getLog()
|
||||||
* @var Array
|
* @var Array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -511,7 +522,7 @@ class Net_SSH2
|
|||||||
/**
|
/**
|
||||||
* Message Log
|
* Message Log
|
||||||
*
|
*
|
||||||
* @see Net_SSH2::getLog()
|
* @see \phpseclib\Net\SSH2::getLog()
|
||||||
* @var Array
|
* @var Array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -523,8 +534,8 @@ class Net_SSH2
|
|||||||
* Bytes the other party can send before it must wait for the window to be adjusted (0x7FFFFFFF = 2GB)
|
* Bytes the other party can send before it must wait for the window to be adjusted (0x7FFFFFFF = 2GB)
|
||||||
*
|
*
|
||||||
* @var Integer
|
* @var Integer
|
||||||
* @see Net_SSH2::_send_channel_packet()
|
* @see \phpseclib\Net\SSH2::_send_channel_packet()
|
||||||
* @see Net_SSH2::exec()
|
* @see \phpseclib\Net\SSH2::exec()
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $window_size = 0x7FFFFFFF;
|
var $window_size = 0x7FFFFFFF;
|
||||||
@ -534,7 +545,7 @@ class Net_SSH2
|
|||||||
*
|
*
|
||||||
* Window size indexed by channel
|
* Window size indexed by channel
|
||||||
*
|
*
|
||||||
* @see Net_SSH2::_send_channel_packet()
|
* @see \phpseclib\Net\SSH2::_send_channel_packet()
|
||||||
* @var Array
|
* @var Array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -545,7 +556,7 @@ class Net_SSH2
|
|||||||
*
|
*
|
||||||
* Window size indexed by channel
|
* Window size indexed by channel
|
||||||
*
|
*
|
||||||
* @see Net_SSH2::_get_channel_packet()
|
* @see \phpseclib\Net\SSH2::_get_channel_packet()
|
||||||
* @var Array
|
* @var Array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -556,7 +567,7 @@ class Net_SSH2
|
|||||||
*
|
*
|
||||||
* Verified against $this->session_id
|
* Verified against $this->session_id
|
||||||
*
|
*
|
||||||
* @see Net_SSH2::getServerPublicHostKey()
|
* @see \phpseclib\Net\SSH2::getServerPublicHostKey()
|
||||||
* @var String
|
* @var String
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -567,7 +578,7 @@ class Net_SSH2
|
|||||||
*
|
*
|
||||||
* ssh-rsa or ssh-dss.
|
* ssh-rsa or ssh-dss.
|
||||||
*
|
*
|
||||||
* @see Net_SSH2::getServerPublicHostKey()
|
* @see \phpseclib\Net\SSH2::getServerPublicHostKey()
|
||||||
* @var String
|
* @var String
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -576,7 +587,7 @@ class Net_SSH2
|
|||||||
/**
|
/**
|
||||||
* Interactive Buffer
|
* Interactive Buffer
|
||||||
*
|
*
|
||||||
* @see Net_SSH2::read()
|
* @see \phpseclib\Net\SSH2::read()
|
||||||
* @var Array
|
* @var Array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -587,8 +598,8 @@ class Net_SSH2
|
|||||||
*
|
*
|
||||||
* Should never exceed self::LOG_MAX_SIZE
|
* Should never exceed self::LOG_MAX_SIZE
|
||||||
*
|
*
|
||||||
* @see Net_SSH2::_send_binary_packet()
|
* @see \phpseclib\Net\SSH2::_send_binary_packet()
|
||||||
* @see Net_SSH2::_get_binary_packet()
|
* @see \phpseclib\Net\SSH2::_get_binary_packet()
|
||||||
* @var Integer
|
* @var Integer
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -597,7 +608,7 @@ class Net_SSH2
|
|||||||
/**
|
/**
|
||||||
* Timeout
|
* Timeout
|
||||||
*
|
*
|
||||||
* @see Net_SSH2::setTimeout()
|
* @see \phpseclib\Net\SSH2::setTimeout()
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $timeout;
|
var $timeout;
|
||||||
@ -605,7 +616,7 @@ class Net_SSH2
|
|||||||
/**
|
/**
|
||||||
* Current Timeout
|
* Current Timeout
|
||||||
*
|
*
|
||||||
* @see Net_SSH2::_get_channel_packet()
|
* @see \phpseclib\Net\SSH2::_get_channel_packet()
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $curTimeout;
|
var $curTimeout;
|
||||||
@ -613,7 +624,7 @@ class Net_SSH2
|
|||||||
/**
|
/**
|
||||||
* Real-time log file pointer
|
* Real-time log file pointer
|
||||||
*
|
*
|
||||||
* @see Net_SSH2::_append_log()
|
* @see \phpseclib\Net\SSH2::_append_log()
|
||||||
* @var Resource
|
* @var Resource
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -622,7 +633,7 @@ class Net_SSH2
|
|||||||
/**
|
/**
|
||||||
* Real-time log file size
|
* Real-time log file size
|
||||||
*
|
*
|
||||||
* @see Net_SSH2::_append_log()
|
* @see \phpseclib\Net\SSH2::_append_log()
|
||||||
* @var Integer
|
* @var Integer
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -631,7 +642,7 @@ class Net_SSH2
|
|||||||
/**
|
/**
|
||||||
* Has the signature been validated?
|
* Has the signature been validated?
|
||||||
*
|
*
|
||||||
* @see Net_SSH2::getServerPublicHostKey()
|
* @see \phpseclib\Net\SSH2::getServerPublicHostKey()
|
||||||
* @var Boolean
|
* @var Boolean
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -640,7 +651,7 @@ class Net_SSH2
|
|||||||
/**
|
/**
|
||||||
* Real-time log file wrap boolean
|
* Real-time log file wrap boolean
|
||||||
*
|
*
|
||||||
* @see Net_SSH2::_append_log()
|
* @see \phpseclib\Net\SSH2::_append_log()
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $realtime_log_wrap;
|
var $realtime_log_wrap;
|
||||||
@ -648,7 +659,7 @@ class Net_SSH2
|
|||||||
/**
|
/**
|
||||||
* Flag to suppress stderr from output
|
* Flag to suppress stderr from output
|
||||||
*
|
*
|
||||||
* @see Net_SSH2::enableQuietMode()
|
* @see \phpseclib\Net\SSH2::enableQuietMode()
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $quiet_mode = false;
|
var $quiet_mode = false;
|
||||||
@ -673,7 +684,7 @@ class Net_SSH2
|
|||||||
* Flag to request a PTY when using exec()
|
* Flag to request a PTY when using exec()
|
||||||
*
|
*
|
||||||
* @var Boolean
|
* @var Boolean
|
||||||
* @see Net_SSH2::enablePTY()
|
* @see \phpseclib\Net\SSH2::enablePTY()
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $request_pty = false;
|
var $request_pty = false;
|
||||||
@ -705,7 +716,7 @@ class Net_SSH2
|
|||||||
/**
|
/**
|
||||||
* The Last Interactive Response
|
* The Last Interactive Response
|
||||||
*
|
*
|
||||||
* @see Net_SSH2::_keyboard_interactive_process()
|
* @see \phpseclib\Net\SSH2::_keyboard_interactive_process()
|
||||||
* @var String
|
* @var String
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -714,7 +725,7 @@ class Net_SSH2
|
|||||||
/**
|
/**
|
||||||
* Keyboard Interactive Request / Responses
|
* Keyboard Interactive Request / Responses
|
||||||
*
|
*
|
||||||
* @see Net_SSH2::_keyboard_interactive_process()
|
* @see \phpseclib\Net\SSH2::_keyboard_interactive_process()
|
||||||
* @var Array
|
* @var Array
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -726,8 +737,8 @@ class Net_SSH2
|
|||||||
* Quoting from the RFC, "in some jurisdictions, sending a warning message before
|
* Quoting from the RFC, "in some jurisdictions, sending a warning message before
|
||||||
* authentication may be relevant for getting legal protection."
|
* authentication may be relevant for getting legal protection."
|
||||||
*
|
*
|
||||||
* @see Net_SSH2::_filter()
|
* @see \phpseclib\Net\SSH2::_filter()
|
||||||
* @see Net_SSH2::getBannerMessage()
|
* @see \phpseclib\Net\SSH2::getBannerMessage()
|
||||||
* @var String
|
* @var String
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -736,7 +747,7 @@ class Net_SSH2
|
|||||||
/**
|
/**
|
||||||
* Did read() timeout or return normally?
|
* Did read() timeout or return normally?
|
||||||
*
|
*
|
||||||
* @see Net_SSH2::isTimeout()
|
* @see \phpseclib\Net\SSH2::isTimeout()
|
||||||
* @var Boolean
|
* @var Boolean
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -745,7 +756,7 @@ class Net_SSH2
|
|||||||
/**
|
/**
|
||||||
* Log Boundary
|
* Log Boundary
|
||||||
*
|
*
|
||||||
* @see Net_SSH2::_format_log()
|
* @see \phpseclib\Net\SSH2::_format_log()
|
||||||
* @var String
|
* @var String
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -754,7 +765,7 @@ class Net_SSH2
|
|||||||
/**
|
/**
|
||||||
* Log Long Width
|
* Log Long Width
|
||||||
*
|
*
|
||||||
* @see Net_SSH2::_format_log()
|
* @see \phpseclib\Net\SSH2::_format_log()
|
||||||
* @var Integer
|
* @var Integer
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -763,7 +774,7 @@ class Net_SSH2
|
|||||||
/**
|
/**
|
||||||
* Log Short Width
|
* Log Short Width
|
||||||
*
|
*
|
||||||
* @see Net_SSH2::_format_log()
|
* @see \phpseclib\Net\SSH2::_format_log()
|
||||||
* @var Integer
|
* @var Integer
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -772,8 +783,8 @@ class Net_SSH2
|
|||||||
/**
|
/**
|
||||||
* Hostname
|
* Hostname
|
||||||
*
|
*
|
||||||
* @see Net_SSH2::__construct()
|
* @see \phpseclib\Net\SSH2::__construct()
|
||||||
* @see Net_SSH2::_connect()
|
* @see \phpseclib\Net\SSH2::_connect()
|
||||||
* @var String
|
* @var String
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -782,8 +793,8 @@ class Net_SSH2
|
|||||||
/**
|
/**
|
||||||
* Port Number
|
* Port Number
|
||||||
*
|
*
|
||||||
* @see Net_SSH2::__construct()
|
* @see \phpseclib\Net\SSH2::__construct()
|
||||||
* @see Net_SSH2::_connect()
|
* @see \phpseclib\Net\SSH2::_connect()
|
||||||
* @var Integer
|
* @var Integer
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -797,8 +808,8 @@ class Net_SSH2
|
|||||||
* however, is non-optional. There will be a timeout, whether or not you set it. If you don't it'll be
|
* however, is non-optional. There will be a timeout, whether or not you set it. If you don't it'll be
|
||||||
* 10 seconds. It is used by fsockopen() and the initial stream_select in that function.
|
* 10 seconds. It is used by fsockopen() and the initial stream_select in that function.
|
||||||
*
|
*
|
||||||
* @see Net_SSH2::__construct()
|
* @see \phpseclib\Net\SSH2::__construct()
|
||||||
* @see Net_SSH2::_connect()
|
* @see \phpseclib\Net\SSH2::_connect()
|
||||||
* @var Integer
|
* @var Integer
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -807,9 +818,9 @@ class Net_SSH2
|
|||||||
/**
|
/**
|
||||||
* Number of columns for terminal window size
|
* Number of columns for terminal window size
|
||||||
*
|
*
|
||||||
* @see Net_SSH2::getWindowColumns()
|
* @see \phpseclib\Net\SSH2::getWindowColumns()
|
||||||
* @see Net_SSH2::setWindowColumns()
|
* @see \phpseclib\Net\SSH2::setWindowColumns()
|
||||||
* @see Net_SSH2::setWindowSize()
|
* @see \phpseclib\Net\SSH2::setWindowSize()
|
||||||
* @var Integer
|
* @var Integer
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -818,9 +829,9 @@ class Net_SSH2
|
|||||||
/**
|
/**
|
||||||
* Number of columns for terminal window size
|
* Number of columns for terminal window size
|
||||||
*
|
*
|
||||||
* @see Net_SSH2::getWindowRows()
|
* @see \phpseclib\Net\SSH2::getWindowRows()
|
||||||
* @see Net_SSH2::setWindowRows()
|
* @see \phpseclib\Net\SSH2::setWindowRows()
|
||||||
* @see Net_SSH2::setWindowSize()
|
* @see \phpseclib\Net\SSH2::setWindowSize()
|
||||||
* @var Integer
|
* @var Integer
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -832,8 +843,8 @@ class Net_SSH2
|
|||||||
* @param String $host
|
* @param String $host
|
||||||
* @param optional Integer $port
|
* @param optional Integer $port
|
||||||
* @param optional Integer $timeout
|
* @param optional Integer $timeout
|
||||||
* @see Net_SSH2::login()
|
* @see \phpseclib\Net\SSH2::login()
|
||||||
* @return Net_SSH2
|
* @return \phpseclib\Net\SSH2
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function __construct($host, $port = 22, $timeout = 10)
|
function __construct($host, $port = 22, $timeout = 10)
|
||||||
@ -2237,7 +2248,7 @@ class Net_SSH2
|
|||||||
/**
|
/**
|
||||||
* Execute Command
|
* Execute Command
|
||||||
*
|
*
|
||||||
* If $callback is set to false then Net_SSH2::_get_channel_packet(self::CHANNEL_EXEC) will need to be called manually.
|
* If $callback is set to false then \phpseclib\Net\SSH2::_get_channel_packet(self::CHANNEL_EXEC) will need to be called manually.
|
||||||
* In all likelihood, this is not a feature you want to be taking advantage of.
|
* In all likelihood, this is not a feature you want to be taking advantage of.
|
||||||
*
|
*
|
||||||
* @param String $command
|
* @param String $command
|
||||||
@ -2307,7 +2318,7 @@ class Net_SSH2
|
|||||||
}
|
}
|
||||||
|
|
||||||
// sending a pty-req SSH_MSG_CHANNEL_REQUEST message is unnecessary and, in fact, in most cases, slows things
|
// sending a pty-req SSH_MSG_CHANNEL_REQUEST message is unnecessary and, in fact, in most cases, slows things
|
||||||
// down. the one place where it might be desirable is if you're doing something like Net_SSH2::exec('ping localhost &').
|
// down. the one place where it might be desirable is if you're doing something like \phpseclib\Net\SSH2::exec('ping localhost &').
|
||||||
// with a pty-req SSH_MSG_CHANNEL_REQUEST, exec() will return immediately and the ping process will then
|
// with a pty-req SSH_MSG_CHANNEL_REQUEST, exec() will return immediately and the ping process will then
|
||||||
// then immediately terminate. without such a request exec() will loop indefinitely. the ping process won't end but
|
// then immediately terminate. without such a request exec() will loop indefinitely. the ping process won't end but
|
||||||
// neither will your script.
|
// neither will your script.
|
||||||
@ -2358,8 +2369,8 @@ class Net_SSH2
|
|||||||
/**
|
/**
|
||||||
* Creates an interactive shell
|
* Creates an interactive shell
|
||||||
*
|
*
|
||||||
* @see Net_SSH2::read()
|
* @see \phpseclib\Net\SSH2::read()
|
||||||
* @see Net_SSH2::write()
|
* @see \phpseclib\Net\SSH2::write()
|
||||||
* @return Boolean
|
* @return Boolean
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -2436,8 +2447,8 @@ class Net_SSH2
|
|||||||
/**
|
/**
|
||||||
* Return the channel to be used with read() / write()
|
* Return the channel to be used with read() / write()
|
||||||
*
|
*
|
||||||
* @see Net_SSH2::read()
|
* @see \phpseclib\Net\SSH2::read()
|
||||||
* @see Net_SSH2::write()
|
* @see \phpseclib\Net\SSH2::write()
|
||||||
* @return Integer
|
* @return Integer
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
@ -2459,7 +2470,7 @@ class Net_SSH2
|
|||||||
* Returns when there's a match for $expect, which can take the form of a string literal or,
|
* Returns when there's a match for $expect, which can take the form of a string literal or,
|
||||||
* if $mode == self::READ_REGEX, a regular expression.
|
* if $mode == self::READ_REGEX, a regular expression.
|
||||||
*
|
*
|
||||||
* @see Net_SSH2::write()
|
* @see \phpseclib\Net\SSH2::write()
|
||||||
* @param String $expect
|
* @param String $expect
|
||||||
* @param Integer $mode
|
* @param Integer $mode
|
||||||
* @return String
|
* @return String
|
||||||
@ -2505,7 +2516,7 @@ class Net_SSH2
|
|||||||
/**
|
/**
|
||||||
* Inputs a command into an interactive shell.
|
* Inputs a command into an interactive shell.
|
||||||
*
|
*
|
||||||
* @see Net_SSH2::read()
|
* @see \phpseclib\Net\SSH2::read()
|
||||||
* @param String $cmd
|
* @param String $cmd
|
||||||
* @return Boolean
|
* @return Boolean
|
||||||
* @access public
|
* @access public
|
||||||
@ -2534,7 +2545,7 @@ class Net_SSH2
|
|||||||
* returns that and then that that was passed into stopSubsystem() but that'll be saved for a future date and implemented
|
* returns that and then that that was passed into stopSubsystem() but that'll be saved for a future date and implemented
|
||||||
* if there's sufficient demand for such a feature.
|
* if there's sufficient demand for such a feature.
|
||||||
*
|
*
|
||||||
* @see Net_SSH2::stopSubsystem()
|
* @see \phpseclib\Net\SSH2::stopSubsystem()
|
||||||
* @param String $subsystem
|
* @param String $subsystem
|
||||||
* @return Boolean
|
* @return Boolean
|
||||||
* @access public
|
* @access public
|
||||||
@ -2582,7 +2593,7 @@ class Net_SSH2
|
|||||||
/**
|
/**
|
||||||
* Stops a subsystem.
|
* Stops a subsystem.
|
||||||
*
|
*
|
||||||
* @see Net_SSH2::startSubsystem()
|
* @see \phpseclib\Net\SSH2::startSubsystem()
|
||||||
* @return Boolean
|
* @return Boolean
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
@ -2659,7 +2670,7 @@ class Net_SSH2
|
|||||||
*
|
*
|
||||||
* See '6. Binary Packet Protocol' of rfc4253 for more info.
|
* See '6. Binary Packet Protocol' of rfc4253 for more info.
|
||||||
*
|
*
|
||||||
* @see Net_SSH2::_send_binary_packet()
|
* @see \phpseclib\Net\SSH2::_send_binary_packet()
|
||||||
* @return String
|
* @return String
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -2752,7 +2763,7 @@ class Net_SSH2
|
|||||||
*
|
*
|
||||||
* Because some binary packets need to be ignored...
|
* Because some binary packets need to be ignored...
|
||||||
*
|
*
|
||||||
* @see Net_SSH2::_get_binary_packet()
|
* @see \phpseclib\Net\SSH2::_get_binary_packet()
|
||||||
* @return String
|
* @return String
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -2865,8 +2876,8 @@ class Net_SSH2
|
|||||||
/**
|
/**
|
||||||
* Returns whether Quiet Mode is enabled or not
|
* Returns whether Quiet Mode is enabled or not
|
||||||
*
|
*
|
||||||
* @see Net_SSH2::enableQuietMode()
|
* @see \phpseclib\Net\SSH2::enableQuietMode()
|
||||||
* @see Net_SSH2::disableQuietMode()
|
* @see \phpseclib\Net\SSH2::disableQuietMode()
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @return boolean
|
* @return boolean
|
||||||
@ -2899,8 +2910,8 @@ class Net_SSH2
|
|||||||
/**
|
/**
|
||||||
* Returns whether request-pty is enabled or not
|
* Returns whether request-pty is enabled or not
|
||||||
*
|
*
|
||||||
* @see Net_SSH2::enablePTY()
|
* @see \phpseclib\Net\SSH2::enablePTY()
|
||||||
* @see Net_SSH2::disablePTY()
|
* @see \phpseclib\Net\SSH2::disablePTY()
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @return boolean
|
* @return boolean
|
||||||
@ -3109,7 +3120,7 @@ class Net_SSH2
|
|||||||
*
|
*
|
||||||
* @param String $data
|
* @param String $data
|
||||||
* @param optional String $logged
|
* @param optional String $logged
|
||||||
* @see Net_SSH2::_get_binary_packet()
|
* @see \phpseclib\Net\SSH2::_get_binary_packet()
|
||||||
* @return Boolean
|
* @return Boolean
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
@ -3287,7 +3298,7 @@ class Net_SSH2
|
|||||||
/**
|
/**
|
||||||
* Closes and flushes a channel
|
* Closes and flushes a channel
|
||||||
*
|
*
|
||||||
* Net_SSH2 doesn't properly close most channels. For exec() channels are normally closed by the server
|
* \phpseclib\Net\SSH2 doesn't properly close most channels. For exec() channels are normally closed by the server
|
||||||
* and for SFTP channels are presumably closed when the client disconnects. This functions is intended
|
* and for SFTP channels are presumably closed when the client disconnects. This functions is intended
|
||||||
* for SCP more than anything.
|
* for SCP more than anything.
|
||||||
*
|
*
|
||||||
|
@ -8,11 +8,11 @@
|
|||||||
* <code>
|
* <code>
|
||||||
* <?php
|
* <?php
|
||||||
* include 'System/SSH/Agent.php';
|
* include 'System/SSH/Agent.php';
|
||||||
* include 'Net/SSH2.php';
|
* include 'vendor/autoload.php';
|
||||||
*
|
*
|
||||||
* $agent = new \phpseclib\System\SSH\Agent();
|
* $agent = new \phpseclib\System\SSH\Agent();
|
||||||
*
|
*
|
||||||
* $ssh = new Net_SSH2('www.domain.tld');
|
* $ssh = new \phpseclib\Net\SSH2('www.domain.tld');
|
||||||
* if (!$ssh->login('username', $agent)) {
|
* if (!$ssh->login('username', $agent)) {
|
||||||
* exit('Login Failed');
|
* exit('Login Failed');
|
||||||
* }
|
* }
|
||||||
|
@ -6,6 +6,9 @@
|
|||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use phpseclib\Net\SCP;
|
||||||
|
use phpseclib\Net\SSH2;
|
||||||
|
|
||||||
class Functional_Net_SCPSSH2UserStoryTest extends PhpseclibFunctionalTestCase
|
class Functional_Net_SCPSSH2UserStoryTest extends PhpseclibFunctionalTestCase
|
||||||
{
|
{
|
||||||
static protected $remoteFile;
|
static protected $remoteFile;
|
||||||
@ -22,7 +25,7 @@ class Functional_Net_SCPSSH2UserStoryTest extends PhpseclibFunctionalTestCase
|
|||||||
|
|
||||||
public function testConstructSSH2()
|
public function testConstructSSH2()
|
||||||
{
|
{
|
||||||
$ssh = new Net_SSH2($this->getEnv('SSH_HOSTNAME'));
|
$ssh = new SSH2($this->getEnv('SSH_HOSTNAME'));
|
||||||
$this->assertTrue(
|
$this->assertTrue(
|
||||||
$ssh->login(
|
$ssh->login(
|
||||||
$this->getEnv('SSH_USERNAME'),
|
$this->getEnv('SSH_USERNAME'),
|
||||||
@ -32,18 +35,24 @@ class Functional_Net_SCPSSH2UserStoryTest extends PhpseclibFunctionalTestCase
|
|||||||
return $ssh;
|
return $ssh;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @depends testConstructSSH2 */
|
/**
|
||||||
|
* @depends testConstructSSH2
|
||||||
|
* @param \phpseclib\Net\SSH2 $ssh
|
||||||
|
*/
|
||||||
public function testConstructor($ssh)
|
public function testConstructor($ssh)
|
||||||
{
|
{
|
||||||
$scp = new Net_SCP($ssh);
|
$scp = new SCP($ssh);
|
||||||
$this->assertTrue(
|
$this->assertTrue(
|
||||||
is_object($scp),
|
is_object($scp),
|
||||||
'Could not construct Net_SCP object.'
|
'Could not construct \phpseclib\Net\SCP object.'
|
||||||
);
|
);
|
||||||
return $scp;
|
return $scp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @depends testConstructor */
|
/**
|
||||||
|
* @depends testConstructor
|
||||||
|
* @param \phpseclib\Net\SCP $scp
|
||||||
|
*/
|
||||||
public function testPutGetString($scp)
|
public function testPutGetString($scp)
|
||||||
{
|
{
|
||||||
$this->assertTrue(
|
$this->assertTrue(
|
||||||
@ -65,7 +74,10 @@ class Functional_Net_SCPSSH2UserStoryTest extends PhpseclibFunctionalTestCase
|
|||||||
return $scp;
|
return $scp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @depends testPutGetString */
|
/**
|
||||||
|
* @depends testPutGetString
|
||||||
|
* @param \phpseclib\Net\SCP $scp
|
||||||
|
*/
|
||||||
public function testGetFile($scp)
|
public function testGetFile($scp)
|
||||||
{
|
{
|
||||||
$localFilename = $this->createTempFile();
|
$localFilename = $this->createTempFile();
|
||||||
|
@ -6,6 +6,8 @@
|
|||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use phpseclib\Net\SFTP;
|
||||||
|
|
||||||
class Functional_Net_SFTPUserStoryTest extends PhpseclibFunctionalTestCase
|
class Functional_Net_SFTPUserStoryTest extends PhpseclibFunctionalTestCase
|
||||||
{
|
{
|
||||||
static protected $scratchDir;
|
static protected $scratchDir;
|
||||||
@ -30,7 +32,7 @@ class Functional_Net_SFTPUserStoryTest extends PhpseclibFunctionalTestCase
|
|||||||
|
|
||||||
public function testConstructor()
|
public function testConstructor()
|
||||||
{
|
{
|
||||||
$sftp = new Net_SFTP($this->getEnv('SSH_HOSTNAME'));
|
$sftp = new SFTP($this->getEnv('SSH_HOSTNAME'));
|
||||||
|
|
||||||
$this->assertTrue(
|
$this->assertTrue(
|
||||||
is_object($sftp),
|
is_object($sftp),
|
||||||
|
@ -6,6 +6,8 @@
|
|||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use phpseclib\Net\SSH2;
|
||||||
|
|
||||||
class Functional_Net_SSH2Test extends PhpseclibFunctionalTestCase
|
class Functional_Net_SSH2Test extends PhpseclibFunctionalTestCase
|
||||||
{
|
{
|
||||||
public function setUp()
|
public function setUp()
|
||||||
@ -20,7 +22,7 @@ class Functional_Net_SSH2Test extends PhpseclibFunctionalTestCase
|
|||||||
|
|
||||||
public function testConstructor()
|
public function testConstructor()
|
||||||
{
|
{
|
||||||
$ssh = new Net_SSH2($this->getEnv('SSH_HOSTNAME'));
|
$ssh = new SSH2($this->getEnv('SSH_HOSTNAME'));
|
||||||
|
|
||||||
$this->assertTrue(
|
$this->assertTrue(
|
||||||
is_object($ssh),
|
is_object($ssh),
|
||||||
@ -91,7 +93,7 @@ class Functional_Net_SSH2Test extends PhpseclibFunctionalTestCase
|
|||||||
|
|
||||||
public function testGetServerPublicHostKey()
|
public function testGetServerPublicHostKey()
|
||||||
{
|
{
|
||||||
$ssh = new Net_SSH2($this->getEnv('SSH_HOSTNAME'));
|
$ssh = new SSH2($this->getEnv('SSH_HOSTNAME'));
|
||||||
|
|
||||||
$this->assertInternalType('string', $ssh->getServerPublicHostKey());
|
$this->assertInternalType('string', $ssh->getServerPublicHostKey());
|
||||||
}
|
}
|
||||||
|
@ -5,11 +5,13 @@
|
|||||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
use phpseclib\Net\SFTP\Stream;
|
||||||
|
|
||||||
class Unit_Net_SFTPStreamTest extends PhpseclibTestCase
|
class Unit_Net_SFTPStreamTest extends PhpseclibTestCase
|
||||||
{
|
{
|
||||||
public function testRegisterWithoutArgument()
|
public function testRegisterWithoutArgument()
|
||||||
{
|
{
|
||||||
$this->assertTrue(Net_SFTP_Stream::register());
|
$this->assertTrue(Stream::register());
|
||||||
$this->assertContains('sftp', stream_get_wrappers());
|
$this->assertContains('sftp', stream_get_wrappers());
|
||||||
$this->assertTrue(stream_wrapper_unregister('sftp'));
|
$this->assertTrue(stream_wrapper_unregister('sftp'));
|
||||||
}
|
}
|
||||||
@ -17,7 +19,7 @@ class Unit_Net_SFTPStreamTest extends PhpseclibTestCase
|
|||||||
public function testRegisterWithArgument()
|
public function testRegisterWithArgument()
|
||||||
{
|
{
|
||||||
$protocol = 'sftptest';
|
$protocol = 'sftptest';
|
||||||
$this->assertTrue(Net_SFTP_Stream::register($protocol));
|
$this->assertTrue(Stream::register($protocol));
|
||||||
$this->assertContains($protocol, stream_get_wrappers());
|
$this->assertContains($protocol, stream_get_wrappers());
|
||||||
$this->assertTrue(stream_wrapper_unregister($protocol));
|
$this->assertTrue(stream_wrapper_unregister($protocol));
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ class Unit_Net_SSH1Test extends PhpseclibTestCase
|
|||||||
*/
|
*/
|
||||||
public function testFormatLog(array $message_log, array $message_number_log, $expected)
|
public function testFormatLog(array $message_log, array $message_number_log, $expected)
|
||||||
{
|
{
|
||||||
$ssh = $this->getMockBuilder('Net_SSH1')
|
$ssh = $this->getMockBuilder('phpseclib\Net\SSH1')
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->setMethods(null)
|
->setMethods(null)
|
||||||
->getMock();
|
->getMock();
|
||||||
|
@ -102,11 +102,11 @@ class Unit_Net_SSH2Test extends PhpseclibTestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Net_SSH2
|
* @return \phpseclib\Net\SSH2
|
||||||
*/
|
*/
|
||||||
protected function createSSHMock()
|
protected function createSSHMock()
|
||||||
{
|
{
|
||||||
return $this->getMockBuilder('Net_SSH2')
|
return $this->getMockBuilder('phpseclib\Net\SSH2')
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->setMethods(array('__destruct'))
|
->setMethods(array('__destruct'))
|
||||||
->getMock();
|
->getMock();
|
||||||
|
Loading…
Reference in New Issue
Block a user