"Segmentation error" when using phpseclib

I downloaded phpseclib-0.3.10 from http://phpseclib.sourceforge.net/

My php version: PHP 5.2.4

OS: CentOS 6.6 release

When I run the following, I get a “Segmentation Error” in this line $ssh->login('username', 'password')

 <?php set_include_path(get_include_path() . PATH_SEPARATOR . 'phpseclib'); include('Net/SSH2.php'); $ssh=new Net_SSH2('servername'); if (!$ssh->login('username', 'password')) { exit('Login Failed'); } echo $ssh->exec('pwd'); ?> 

I can not find the cause of this problem. Could you help me find the reason for this.

+6
source share
1 answer

My guess: either calling fsockopen () or calling stream_select (). You can understand this by putting die () in your code at consecutive points in login () and the functions called there.

Looking at it ... login () calls _login ():

https://github.com/phpseclib/phpseclib/blob/0.3.10/phpseclib/Net/SSH2.php#L1801

_login () calls _connect ():

https://github.com/phpseclib/phpseclib/blob/0.3.10/phpseclib/Net/SSH2.php#L1817

eg. before line 964 in Net / SSH2.php add die('this far') . If he says "this far," try adding it after. If you get a seg error when this happens, but not before, it probably means fsockopen is to blame.

And keep doing this until you get a seg error. Make die('this far'); before and after stream_select and anywhere. Then send the line where you type it.

0
source

Source: https://habr.com/ru/post/987103/


All Articles