phpseclib SSH2 hangs at Math_BigInteger::modPow()

别等时光非礼了梦想. 提交于 2019-12-11 10:07:40

问题


I've tried the basic example of SSH2 but it hangs.

<?php
ini_set('display_errors', 1);

include('Net/SSH2.php');
$host = '192.168.100.101';
$ssh = new Net_SSH2($host);

If I set the time limit, for example, 1000 seconds:

<?php
ini_set('display_errors', 1);
set_time_limit(1000);

include('Net/SSH2.php');
$host = '192.168.100.101';
$ssh = new Net_SSH2($host);

I'd get:

Fatal error: Maximum execution time of 1000 seconds exceeded in /path/to/Math/BigInteger.php on line 1060
Stack trace:
#  Time      Memory  Function                           Location
1  0.0014    647704  {main}( )                          ../index.php:0
2  0.0219    2203280 Net_SSH2->Net_SSH2( )              ../index.php:14
3  0.1114    4439056 Net_SSH2->_key_exchange( )         ../SSH2.php:952
4  0.1837    4520224 Math_BigInteger->modPow( )         ../SSH2.php:1309
5  0.1840    4521888 Math_BigInteger->_slidingWindow( ) ../BigInteger.php:1723
6  0.1842    4523144 Math_BigInteger->_prepareReduce( ) ../BigInteger.php:1817
7  0.1842    4523144 Math_BigInteger->_reduce( )        ../BigInteger.php:1912
8  0.1842    4523144 Math_BigInteger->_barrett( )       ../BigInteger.php:1876
9  0.1844    4536024 Math_BigInteger->divide( )         ../BigInteger.php:2032
10 1001.4549 4577384 Math_BigInteger->subtract( )       ../BigInteger.php:1497
11 1001.4549 4586584 Math_BigInteger->_subtract( )      ../BigInteger.php:991

Does anyone have an idea of what caused that?

Thanks in advance.

More info: I'm using PHP 5.3.28 as a module of Apache 2.2.10 on Linux x86_64.


回答1:


You're using the slowest possible mode of phpseclib, so that's not going to help. But, that said...

Try the latest git version. In particular, this commit should result in a slight speedup:

https://github.com/phpseclib/phpseclib/commit/e4ff01f05475e81a56681ebfdb5473a07099e5ea



来源:https://stackoverflow.com/questions/23606859/phpseclib-ssh2-hangs-at-math-bigintegermodpow

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!