Trying to get property of non-object

Get help with using the PHP Secure Communications Library.

Moderator: Nuxius

Forum rules
The purpose of this forum is to provide support for phpseclib, a pure PHP SSH / SFTP / RSA library.

Posts by new users are held in a moderation queue and are not publicly visible until the post is approved.

Trying to get property of non-object

Postby dan » Sun Nov 24, 2013 10:06 pm

When connecting throw SSH2 using a private key at some systems a fatal error is returned. There is no line number.

Fatal error: Trying to get property of non-object at lib/Math/BigInteger.php line 0

Tried a lot of things but I'm not able to find why this is happening. Maybe some fresh look will add some light into this issue

Code: Select all
Error!
Trying to get property of non-object

array(13) {
  [0]=>
  array(4) {
    ["file"]=>
    string(90) "lib/Math/BigInteger.php"
    ["line"]=>
    int(0)
    ["function"]=>
    string(16) "CUSTOM_handleError"
    ["args"]=>
    array(5) {
      [0]=>
      int(8)
      [1]=>
      string(36) "Trying to get property of non-object"
      [2]=>
      string(90) "lib/Math/BigInteger.php"
      [3]=>
      int(0)
      [4]=>
      array(1) {
        ["x"]=>
        bool(false)
      }
    }
  }
  [1]=>
  array(5) {
    ["file"]=>
    string(84) "lib/Crypt/RSA.php"
    ["line"]=>
    int(0)
    ["function"]=>
    string(8) "multiply"
    ["class"]=>
    string(15) "Math_BigInteger"
    ["type"]=>
    string(2) "->"
  }
  [2]=>
  array(5) {
    ["file"]=>
    string(84) "lib/Crypt/RSA.php"
    ["line"]=>
    int(0)
    ["function"]=>
    string(6) "_blind"
    ["class"]=>
    string(9) "Crypt_RSA"
    ["type"]=>
    string(2) "->"
  }
  [3]=>
  array(5) {
    ["file"]=>
    string(84) "lib/Crypt/RSA.php"
    ["line"]=>
    int(0)
    ["function"]=>
    string(13) "_exponentiate"
    ["class"]=>
    string(9) "Crypt_RSA"
    ["type"]=>
    string(2) "->"
  }
  [4]=>
  array(5) {
    ["file"]=>
    string(84) "lib/Crypt/RSA.php"
    ["line"]=>
    int(0)
    ["function"]=>
    string(7) "_rsasp1"
    ["class"]=>
    string(9) "Crypt_RSA"
    ["type"]=>
    string(2) "->"
  }
  [5]=>
  array(5) {
    ["file"]=>
    string(84) "lib/Crypt/RSA.php"
    ["line"]=>
    int(0)
    ["function"]=>
    string(23) "_rsassa_pkcs1_v1_5_sign"
    ["class"]=>
    string(9) "Crypt_RSA"
    ["type"]=>
    string(2) "->"
  }
  [6]=>
  array(5) {
    ["file"]=>
    string(83) "lib/Net/SSH2.php"
    ["line"]=>
    int(0)
    ["function"]=>
    string(4) "sign"
    ["class"]=>
    string(9) "Crypt_RSA"
    ["type"]=>
    string(2) "->"
  }
  [7]=>
  array(5) {
    ["file"]=>
    string(83) "lib/Net/SSH2.php"
    ["line"]=>
    int(0)
    ["function"]=>
    string(17) "_privatekey_login"
    ["class"]=>
    string(8) "Net_SSH2"
    ["type"]=>
    string(2) "->"
  }
  [8]=>
  array(5) {
    ["file"]=>
    string(83) "lib/Net/SSH2.php"
    ["line"]=>
    int(0)
    ["function"]=>
    string(13) "_login_helper"
    ["class"]=>
    string(8) "Net_SSH2"
    ["type"]=>
    string(2) "->"
  }
  [9]=>
  array(5) {
    ["file"]=>
    string(77) "custom.php"
    ["line"]=>
    int(0)
    ["function"]=>
    string(5) "login"
    ["class"]=>
    string(8) "Net_SSH2"
    ["type"]=>
    string(2) "->"
  }


Thanks!
dan
Traveler
 
Posts: 5
Joined: Sun Nov 24, 2013 9:56 pm

Re: Trying to get property of non-object

Postby TerraFrost » Mon Nov 25, 2013 12:18 am

My expectation is that the latest Git version will fix this for you, if you want to give that a go!
TerraFrost
Legendary Guard
 
Posts: 12357
Joined: Wed Dec 04, 2002 6:37 am

Re: Trying to get property of non-object

Postby dan » Tue Nov 26, 2013 10:03 pm

Thanks for your reply!

I downloaded the latest github files, unfortunately this did not solve the error.

My used code:
Code: Select all
      $ssh_hostname = $hostname;
      $ssh_port = $port;
      $ssh_user = $user

      $ssh_password = new Crypt_RSA();
      $ssh_password->loadKey($ssh_login['password']);
            
      try {
         $ssh = new Net_SSH2($ssh_hostname, $ssh_port, 10);
         if (!$ssh->login($ssh_user , $ssh_password)) {
            exit('Login Failed');
         }
         
         $ssh_result = $ssh->exec('time');

         $ssh->getExitStatus();
         $ssh->setTimeout(5);
      }
      catch (ErrorException $e) {
         var_dump($e->getTrace());
      }


Remote SSH error:
error: RSA_public_decrypt failed:
error:0407006A:lib(4):func(112):reason(106)
dan
Traveler
 
Posts: 5
Joined: Sun Nov 24, 2013 9:56 pm

Re: Trying to get property of non-object

Postby TerraFrost » Thu Nov 28, 2013 7:33 pm

What if you do this?:

Code: Select all
      $ssh_password = new Crypt_RSA();
      $ssh_password->loadKey($ssh_login['password']);

    echo $ssh_password;

Does anything output out?
TerraFrost
Legendary Guard
 
Posts: 12357
Joined: Wed Dec 04, 2002 6:37 am

Re: Trying to get property of non-object

Postby dan » Mon Dec 02, 2013 10:28 am

Yes this outputs the decrypted private key.
dan
Traveler
 
Posts: 5
Joined: Sun Nov 24, 2013 9:56 pm

Re: Trying to get property of non-object

Postby TerraFrost » Tue Dec 03, 2013 5:31 pm

What if you do this?:

Code: Select all
      $ssh_password = new Crypt_RSA();
      $ssh_password->loadKey($ssh_login['password']);

echo base64_encode($ssh_password->encrypt('hello world!'));
TerraFrost
Legendary Guard
 
Posts: 12357
Joined: Wed Dec 04, 2002 6:37 am

Re: Trying to get property of non-object

Postby dan » Thu Dec 05, 2013 11:28 am

Oke, well there is a base64 hash returned.

However the first time the property error was also returned beside the hash.

The second attempt it returned 'Unable to login to the ssh service'.

On both attempts there was a hash key, however they were different from each other.
dan
Traveler
 
Posts: 5
Joined: Sun Nov 24, 2013 9:56 pm

Re: Trying to get property of non-object

Postby TerraFrost » Fri Dec 06, 2013 12:08 am

The "hash key", in the same code I posted, is going to be different because, by default, the encrypt() method uses RSA OAEP padding, which is randomized to protect against chosen plaintext attacks.

Anyway, could you post your key?

Also, can you post a copy of your RSA.php file?

Thanks!
TerraFrost
Legendary Guard
 
Posts: 12357
Joined: Wed Dec 04, 2002 6:37 am

Re: Trying to get property of non-object

Postby dan » Fri Dec 06, 2013 6:32 pm

I see!

I've send the key to your inbox, and attached the file in this post.

Thanks!
Attachments
RSA.zip
rsa.php
(18.29 KiB) Downloaded 100 times
dan
Traveler
 
Posts: 5
Joined: Sun Nov 24, 2013 9:56 pm


Return to phpseclib support

Who is online

Users browsing this forum: No registered users and 3 guests

cron