Net_SSH1()
__destruct()
_crc()
_define_array()
_disconnect()
_format_log()
_get_binary_packet()
_initShell()
_rsa_crypt()
_send_binary_packet()
_string_shift()
disconnect()
exec()
getHostKeyPublicExponent()
getHostKeyPublicModulus()
getLog()
getServerIdentification()
getServerKeyPublicExponent()
getServerKeyPublicModulus()
getSupportedAuthentications()
getSupportedCiphers()
interactiveRead()
interactiveWrite()
login()
read()
write()
$bitmap
$crypto
$fsock
$host_key_public_exponent
$host_key_public_modulus
$identifier
$interactive_buffer
$message_log
$protocol_flag_log
$protocol_flags
$server_identification
$server_key_public_exponent
$server_key_public_modulus
$supported_authentications
$supported_ciphers
Pure-PHP implementation of SSHv1.
author | Jim Wigginton |
---|---|
version | 0.1.0 |
access | public |
package | Net_SSH1 |
Net_SSH1(String $host, \optional $port, \optional $timeout, \optional $cipher) : \Net_SSH1
Connects to an SSHv1 server
access | public |
---|
String
\optional
Integer $port
\optional
Integer $timeout
\optional
Integer $cipher
__destruct()
Will be called, automatically, if you're supporting just PHP5. If you're supporting PHP4, you'll need to call disconnect().
access | public |
---|
_crc(String $data) : Integer
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.
see | \global\Net_SSH1::_get_binary_packet() |
---|---|
see | \global\Net_SSH1::_send_binary_packet() |
access | private |
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.
access | private |
---|
_disconnect(String $msg)
access | private |
---|
String
_format_log(Array $message_log, Array $message_number_log) : String
access | private |
---|
Array
Array
String
_get_binary_packet() : Array
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
see | \global\Net_SSH1::_send_binary_packet() |
---|---|
access | private |
Array
_initShell() : Boolean
see | \global\Net_SSH1::interactiveRead() |
---|---|
see | \global\Net_SSH1::interactiveWrite() |
access | private |
Boolean
_rsa_crypt(\Math_BigInteger $m, Array $key) : \Math_BigInteger
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...
see | \global\Net_SSH1::Net_SSH1() |
---|---|
access | private |
Array
_send_binary_packet(String $data) : Boolean
Returns true on success, false on failure.
see | \global\Net_SSH1::_get_binary_packet() |
---|---|
access | private |
String
Boolean
_string_shift(String $string, \optional $index) : String
Inspired by array_shift
access | private |
---|
String
\optional
Integer $index
String
disconnect()
access | public |
---|
exec(String $cmd, $block) : mixed
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:
http://www.faqs.org/docs/bashman/bashref_65.html http://www.faqs.org/docs/bashman/bashref_62.html
To execute further commands, a new Net_SSH1 object will need to be created.
Returns false on failure and the output, otherwise.
see | \global\Net_SSH1::interactiveRead() |
---|---|
see | \global\Net_SSH1::interactiveWrite() |
access | public |
String
mixed
getHostKeyPublicExponent(\optional $raw_output) : String
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.
access | public |
---|
\optional
Boolean $raw_output
String
getHostKeyPublicModulus(\optional $raw_output) : String
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.
access | public |
---|
\optional
Boolean $raw_output
String
getLog() : String
Returns a string if NET_SSH2_LOGGING == NET_SSH2_LOG_COMPLEX, an array if NET_SSH2_LOGGING == NET_SSH2_LOG_SIMPLE and false if !defined('NET_SSH2_LOGGING')
access | public |
---|
String
or ArraygetServerIdentification() : String
access | public |
---|
String
getServerKeyPublicExponent(\optional $raw_output) : String
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.
access | public |
---|
\optional
Boolean $raw_output
String
getServerKeyPublicModulus(\optional $raw_output) : String
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.
access | public |
---|
\optional
Boolean $raw_output
String
getSupportedAuthentications(\optional $raw_output) : Array
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(NET_SSH1_AUTH_PASSWORD).
access | public |
---|
\optional
Boolean $raw_output
Array
getSupportedCiphers(\optional $raw_output) : Array
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(NET_SSH1_CIPHER_3DES).
access | public |
---|
\optional
Boolean $raw_output
Array
interactiveRead() : String
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 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.
see | \global\Net_SSH1::interactiveRead() |
---|---|
access | public |
String
interactiveWrite(String $cmd) : Boolean
see | \global\Net_SSH1::interactiveRead() |
---|---|
access | public |
String
Boolean
login(String $username, \optional $password) : Boolean
access | public |
---|
String
\optional
String $password
Boolean
read(String $expect, Integer $mode) : Boolean
$expect can take the form of a string literal or, if $mode == NET_SSH1_READ_REGEX, a regular expression.
see | \global\Net_SSH1::write() |
---|---|
access | public |
String
Integer
Boolean
write(String $cmd) : Boolean
see | \global\Net_SSH1::interactiveWrite() |
---|---|
access | public |
String
Boolean
$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.
access | private |
---|
$crypto : Object
access | private |
---|
$fsock : Object
access | private |
---|
$host_key_public_exponent : String
Logged for debug purposes
see | \global\Net_SSH1::getHostKeyPublicExponent() |
---|---|
access | private |
$host_key_public_modulus : String
Logged for debug purposes
see | \global\Net_SSH1::getHostKeyPublicModulus() |
---|---|
access | private |
$identifier : String
access | private |
---|
$interactive_buffer : Array
see | \global\Net_SSH1::read() |
---|---|
access | private |
$protocol_flag_log : Array
see | \global\Net_SSH1::getLog() |
---|---|
access | private |
$protocol_flags : Array
see | \global\Net_SSH1::Net_SSH1() |
---|---|
access | private |
$server_identification : String
see | \global\Net_SSH1::getServerIdentification() |
---|---|
access | private |
$server_key_public_exponent : String
Logged for debug purposes
see | \global\Net_SSH1::getServerKeyPublicExponent() |
---|---|
access | private |
$server_key_public_modulus : String
Logged for debug purposes
see | \global\Net_SSH1::getServerKeyPublicModulus() |
---|---|
access | private |
$supported_authentications : Array
Logged for debug purposes
see | \global\Net_SSH1::getSupportedAuthentications() |
---|---|
access | private |
$supported_ciphers : Array
Logged for debug purposes
see | \global\Net_SSH1::getSupportedCiphers() |
---|---|
access | private |