PHP Класс phpseclib\Net\SSH1

Автор: Jim Wigginton ([email protected])
Показать файл Открыть проект

Открытые свойства

Свойство Тип Описание
$bitmap integer The bits that are set represent functions that have been called already. This is used to determine if a requisite function has been successfully executed. If not, an error should be thrown.
$cipher integer Default cipher
$connectionTimeout integer Set by the constructor call. Calling setTimeout() is optional. If it's not called functions like exec() won't timeout unless some PHP setting forces it too. The timeout specified in the constructor, 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.
$crypto object The cryptography object
$curTimeout Current Timeout
$fsock object The Socket Object
$host string Hostname
$host_key_public_exponent string Logged for debug purposes
$host_key_public_modulus string Logged for debug purposes
$identifier string The SSH identifier
$interactiveBuffer array Interactive Buffer
$log_boundary Log Boundary
$log_long_width Log Long Width
$log_short_width Log Short Width
$message_log array Message Log
$port integer Port Number
$protocol_flag_log array Protocol Flag Log
$protocol_flags array Protocol Flags
$realtime_log_file resource Real-time log file pointer
$realtime_log_size integer Real-time log file size
$realtime_log_wrap boolean Real-time log file wrap boolean
$server_identification string Server Identification
$server_key_public_exponent string Logged for debug purposes
$server_key_public_modulus string Logged for debug purposes
$supported_authentications array Logged for debug purposes
$supported_ciphers array Logged for debug purposes
$timeout Timeout

Открытые методы

Метод Описание
__construct ( string $host, integer $port = 22, integer $timeout = 10, integer $cipher = self::CIPHER_3DES ) : SSH1 Default Constructor.
__destruct ( ) Destructor.
_append_log ( $protocol_flags, $message ) Logs data packets
_connect ( ) : boolean Connect to an SSHv1 server
_crc ( string $data ) : integer Cyclic Redundancy Check (CRC)
_define_array ( ) Define Array
_disconnect ( string $msg = 'Client Quit' ) Disconnect
_format_log ( array $message_log, array $message_number_log ) : string Formats a log for printing
_format_log_helper ( array $matches ) : string Helper function for _format_log
_get_binary_packet ( ) : array Gets Binary Packets
_initShell ( ) : boolean Creates an interactive shell
_rsa_crypt ( phpseclib\Math\BigInteger $m, array $key ) : phpseclib\Math\BigInteger RSA Encrypt
_send_binary_packet ( string $data ) : boolean Sends Binary Packets
disconnect ( ) Disconnect
exec ( string $cmd, $block = true ) : mixed Executes a command on a non-interactive shell, returns the output, and quits.
getHostKeyPublicExponent ( boolean $raw_output = false ) : string Return the host key public exponent
getHostKeyPublicModulus ( boolean $raw_output = false ) : string Return the host key public modulus
getLog ( ) : array | false | string Returns a log of the packets that have been sent and received.
getServerIdentification ( ) : string Return the server identification.
getServerKeyPublicExponent ( boolean $raw_output = false ) : string Return the server key public exponent
getServerKeyPublicModulus ( boolean $raw_output = false ) : string Return the server key public modulus
getSupportedAuthentications ( boolean $raw_output = false ) : array Return a list of authentications supported by SSH1 server.
getSupportedCiphers ( boolean $raw_output = false ) : array Return a list of ciphers supported by SSH1 server.
interactiveRead ( ) : string Returns the output of an interactive shell when no more output is available.
interactiveWrite ( string $cmd ) : boolean Inputs a command into an interactive shell.
login ( string $username, string $password = '' ) : boolean Login
read ( string $expect, integer $mode = self::READ__SIMPLE ) : boolean Returns the output of an interactive shell when there's a match for $expect
setTimeout ( mixed $timeout ) Set Timeout
write ( string $cmd ) : boolean Inputs a command into an interactive shell.

Описание методов

__construct() публичный Метод

Connects to an SSHv1 server
public __construct ( string $host, integer $port = 22, integer $timeout = 10, integer $cipher = self::CIPHER_3DES ) : SSH1
$host string
$port integer
$timeout integer
$cipher integer
Результат SSH1

__destruct() публичный Метод

Will be called, automatically, if you're supporting just PHP5. If you're supporting PHP4, you'll need to call disconnect().
public __destruct ( )

_append_log() публичный Метод

Makes sure that only the last 1MB worth of packets will be logged
public _append_log ( $protocol_flags, $message )

_connect() публичный Метод

Connect to an SSHv1 server
public _connect ( ) : boolean
Результат boolean

_crc() публичный Метод

PHP's crc32 function is implemented slightly differently than the one that SSH v1 uses, so we've reimplemented it. A more detailed discussion of the differences can be found after $crc_lookup_table's initialization.
См. также: self::_get_binary_packet()
См. также: self::_send_binary_packet()
public _crc ( string $data ) : integer
$data string
Результат integer

_define_array() публичный Метод

Takes any number of arrays whose indices are integers and whose values are strings and defines a bunch of named constants from it, using the value as the name of the constant and the index as the value of the constant. If any of the constants that would be defined already exists, none of the constants will be defined.
public _define_array ( )

_disconnect() публичный Метод

Disconnect
public _disconnect ( string $msg = 'Client Quit' )
$msg string

_format_log() публичный Метод

Formats a log for printing
public _format_log ( array $message_log, array $message_number_log ) : string
$message_log array
$message_number_log array
Результат string

_format_log_helper() публичный Метод

For use with preg_replace_callback()
public _format_log_helper ( array $matches ) : string
$matches array
Результат string

_get_binary_packet() публичный Метод

See 'The Binary Packet Protocol' of protocol-1.5.txt for more info. Also, this function could be improved upon by adding detection for the following exploit: http://www.securiteam.com/securitynews/5LP042K3FY.html
См. также: self::_send_binary_packet()
public _get_binary_packet ( ) : array
Результат array

_initShell() публичный Метод

Creates an interactive shell
См. также: self::interactiveRead()
См. также: self::interactiveWrite()
public _initShell ( ) : boolean
Результат boolean

_rsa_crypt() публичный Метод

Returns mod(pow($m, $e), $n), where $n should be the product of two (large) primes $p and $q and where $e 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...
См. также: self::__construct()
public _rsa_crypt ( phpseclib\Math\BigInteger $m, array $key ) : phpseclib\Math\BigInteger
$m phpseclib\Math\BigInteger
$key array
Результат phpseclib\Math\BigInteger

_send_binary_packet() публичный Метод

Returns true on success, false on failure.
См. также: self::_get_binary_packet()
public _send_binary_packet ( string $data ) : boolean
$data string
Результат boolean

disconnect() публичный Метод

Disconnect
public disconnect ( )

exec() публичный Метод

An SSH1 server will close the connection after a command has been executed on a non-interactive shell. SSH2 servers don't, however, this isn't an SSH2 client. The way this works, on the server, is by initiating a shell with the -s option, as discussed in the following links: {@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} To execute further commands, a new \phpseclib\Net\SSH1 object will need to be created. Returns false on failure and the output, otherwise.
См. также: self::interactiveRead()
См. также: self::interactiveWrite()
public exec ( string $cmd, $block = true ) : mixed
$cmd string
Результат mixed

getHostKeyPublicExponent() публичный Метод

Returns, by default, the base-10 representation. If $raw_output is set to true, returns, instead, the raw bytes. This behavior is similar to PHP's md5() function.
public getHostKeyPublicExponent ( boolean $raw_output = false ) : string
$raw_output boolean
Результат string

getHostKeyPublicModulus() публичный Метод

Returns, by default, the base-10 representation. If $raw_output is set to true, returns, instead, the raw bytes. This behavior is similar to PHP's md5() function.
public getHostKeyPublicModulus ( boolean $raw_output = false ) : string
$raw_output boolean
Результат string

getLog() публичный Метод

Returns a string if NET_SSH1_LOGGING == self::LOG_COMPLEX, an array if NET_SSH1_LOGGING == self::LOG_SIMPLE and false if !defined('NET_SSH1_LOGGING')
public getLog ( ) : array | false | string
Результат array | false | string

getServerIdentification() публичный Метод

Return the server identification.
public getServerIdentification ( ) : string
Результат string

getServerKeyPublicExponent() публичный Метод

Returns, by default, the base-10 representation. If $raw_output is set to true, returns, instead, the raw bytes. This behavior is similar to PHP's md5() function.
public getServerKeyPublicExponent ( boolean $raw_output = false ) : string
$raw_output boolean
Результат string

getServerKeyPublicModulus() публичный Метод

Returns, by default, the base-10 representation. If $raw_output is set to true, returns, instead, the raw bytes. This behavior is similar to PHP's md5() function.
public getServerKeyPublicModulus ( boolean $raw_output = false ) : string
$raw_output boolean
Результат string

getSupportedAuthentications() публичный Метод

Just because a cipher is supported by an SSH1 server doesn't mean it's supported by this library. If $raw_output is set to true, returns, instead, an array of constants. ie. instead of array('password authentication'), you'll get array(self::AUTH_PASSWORD).
public getSupportedAuthentications ( boolean $raw_output = false ) : array
$raw_output boolean
Результат array

getSupportedCiphers() публичный Метод

Just because a cipher is supported by an SSH1 server doesn't mean it's supported by this library. If $raw_output is set to true, returns, instead, an array of constants. ie. instead of array('Triple-DES in CBC mode'), you'll get array(self::CIPHER_3DES).
public getSupportedCiphers ( boolean $raw_output = false ) : array
$raw_output boolean
Результат array

interactiveRead() публичный Метод

Requires PHP 4.3.0 or later due to the use of the stream_select() function. If you see stuff like "^[[00m", you're seeing ANSI escape codes. According to {@link http://support.microsoft.com/kb/101875 How to Enable ANSI.SYS in a Command Window}, "Windows NT 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.
См. также: self::interactiveRead()
public interactiveRead ( ) : string
Результат string

interactiveWrite() публичный Метод

Inputs a command into an interactive shell.
См. также: self::interactiveRead()
public interactiveWrite ( string $cmd ) : boolean
$cmd string
Результат boolean

login() публичный Метод

Login
public login ( string $username, string $password = '' ) : boolean
$username string
$password string
Результат boolean

read() публичный Метод

$expect can take the form of a string literal or, if $mode == self::READ__REGEX, a regular expression.
См. также: self::write()
public read ( string $expect, integer $mode = self::READ__SIMPLE ) : boolean
$expect string
$mode integer
Результат boolean

setTimeout() публичный Метод

$ssh->exec('ping 127.0.0.1'); on a Linux host will never return and will run indefinitely. setTimeout() makes it so it'll timeout. Setting $timeout to false or 0 will mean there is no timeout.
public setTimeout ( mixed $timeout )
$timeout mixed

write() публичный Метод

Inputs a command into an interactive shell.
См. также: self::interactiveWrite()
public write ( string $cmd ) : boolean
$cmd string
Результат boolean

Описание свойств

$bitmap публичное свойство

The bits that are set represent functions that have been called already. This is used to determine if a requisite function has been successfully executed. If not, an error should be thrown.
public int $bitmap
Результат integer

$cipher публичное свойство

Default cipher
См. также: self::__construct()
См. также: self::_connect()
public int $cipher
Результат integer

$connectionTimeout публичное свойство

Set by the constructor call. Calling setTimeout() is optional. If it's not called functions like exec() won't timeout unless some PHP setting forces it too. The timeout specified in the constructor, 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.
См. также: self::__construct()
См. также: self::_connect()
public int $connectionTimeout
Результат integer

$crypto публичное свойство

The cryptography object
public object $crypto
Результат object

$curTimeout публичное свойство

Current Timeout
См. также: self::_get_channel_packet()
public $curTimeout

$fsock публичное свойство

The Socket Object
public object $fsock
Результат object

$host публичное свойство

Hostname
См. также: self::__construct()
См. также: self::_connect()
public string $host
Результат string

$host_key_public_exponent публичное свойство

Logged for debug purposes
См. также: self::getHostKeyPublicExponent()
public string $host_key_public_exponent
Результат string

$host_key_public_modulus публичное свойство

Logged for debug purposes
См. также: self::getHostKeyPublicModulus()
public string $host_key_public_modulus
Результат string

$identifier публичное свойство

The SSH identifier
public string $identifier
Результат string

$interactiveBuffer публичное свойство

Interactive Buffer
См. также: self::read()
public array $interactiveBuffer
Результат array

$log_boundary публичное свойство

Log Boundary
См. также: self::_format_log()
public $log_boundary

$log_long_width публичное свойство

Log Long Width
См. также: self::_format_log()
public $log_long_width

$log_short_width публичное свойство

Log Short Width
См. также: self::_format_log()
public $log_short_width

$message_log публичное свойство

Message Log
См. также: self::getLog()
public array $message_log
Результат array

$port публичное свойство

Port Number
См. также: self::__construct()
См. также: self::_connect()
public int $port
Результат integer

$protocol_flag_log публичное свойство

Protocol Flag Log
См. также: self::getLog()
public array $protocol_flag_log
Результат array

$protocol_flags публичное свойство

Protocol Flags
См. также: self::__construct()
public array $protocol_flags
Результат array

$realtime_log_file публичное свойство

Real-time log file pointer
См. также: self::_append_log()
public resource $realtime_log_file
Результат resource

$realtime_log_size публичное свойство

Real-time log file size
См. также: self::_append_log()
public int $realtime_log_size
Результат integer

$realtime_log_wrap публичное свойство

Real-time log file wrap boolean
См. также: self::_append_log()
public bool $realtime_log_wrap
Результат boolean

$server_identification публичное свойство

Server Identification
См. также: self::getServerIdentification()
public string $server_identification
Результат string

$server_key_public_exponent публичное свойство

Logged for debug purposes
См. также: self::getServerKeyPublicExponent()
public string $server_key_public_exponent
Результат string

$server_key_public_modulus публичное свойство

Logged for debug purposes
См. также: self::getServerKeyPublicModulus()
public string $server_key_public_modulus
Результат string

$supported_authentications публичное свойство

Logged for debug purposes
См. также: self::getSupportedAuthentications()
public array $supported_authentications
Результат array

$supported_ciphers публичное свойство

Logged for debug purposes
См. также: self::getSupportedCiphers()
public array $supported_ciphers
Результат array

$timeout публичное свойство

Timeout
См. также: self::setTimeout()
public $timeout