Questions tagged [phpseclib]

phpseclib is a PHP library that provides pure-PHP implementations of: - BigIntegers - ECDSA / ECDH (66 curves supported) - Ed25519 / Ed448 - Curve25519 / Curve448 - RSA - DSA - DH - SSH2 - SFTP - X.509 - Symmetric key encryption - AES - Rijndael - DES - 3DES - RC4 - Blowfish - Twofish - ChaCha20 - GCM - Poly1305

Filter by
Sorted by
Tagged with
0 votes
1 answer
24 views

Validate RSA key against password without PHPSeclib

I try to validate if a passphrase works with a private key in PHP. Right now the solution is simply to use phpseclib and do this: $rsa = new \phpseclib\Crypt\RSA(); $rsa->setPassword($passphrase); $...
4thfloorstudios's user avatar
1 vote
1 answer
117 views

Connection with Net/SSH2.php to Huawei Olt MA5680T is very slow

I implemented a php script to communicate with my Huawei Olt MA5680T through the phpseclib SSH2.php library but the execution time of any remote operation on the Olt is extremely slow, about 40 ...
Sincerbex's user avatar
3 votes
1 answer
56 views

SFTP in PHP (phpseclib3\Net\SFTP) – filtering directory listing results server side possible?

I'm trying to look for specific files on an SFTP server using PHP. The file listing is quite large, so I'm hoping to filter the results using wildcards rather than iterating through every file, if ...
MJC's user avatar
  • 89
0 votes
0 answers
69 views

I can´t connect with phpseclib

I have this code in a simple way to connect SFTP and upload files for a CMR, until php 7.4 everything works, now with PHP 8.0 or superior, it´s useless. I have this code below: set_include_path(...
ISCAG's user avatar
  • 1
0 votes
0 answers
31 views

Can I show all the directories and subdirectories exists in a remote server (SFTP) connected via phpseclib? [duplicate]

<?PHP $host = 'xxxxxxxxxx'; $user = 'xxxxxx'; $password = 'xxxxxxxx'; // Establish the connection $sftp = new SFTP($host); $sftp->login($user, $password); $sftp->...
Fathy's user avatar
  • 1
-1 votes
1 answer
77 views

phpseclib: Convert ECDSA PrivateKey to 64 character hexadecimal

I'm trying to generate an Ethereum address in PHP and part of the requirements is generating a 64 character hex private key. I'm using phpseclib already in my project, and decided to use it's classes ...
CodeWithKyrian's user avatar
3 votes
2 answers
91 views

How can I get the logging from phpseclib and SFTP?

I am using below code to transfer files to an SFTP server use phpseclib3\Net\SFTP; $sftp = new SFTP('localhost'); $sftp->login('user', 'password'); error_log($sftp->pwd()); foreach ($fileList ...
Max B's user avatar
  • 343
1 vote
0 answers
54 views

Digitally Sign request with PHP

I have a request to the API that needs to be signed with an electronic signature. I have an openssl command that generates this signature. openssl cms -noattr -sign -binary -nosmimecap -no certs -...
IronSide's user avatar
3 votes
1 answer
156 views

Verify RSA-PSS With phpseclib

So i tried to verify rsa-ps signature that signed in golang with php library phpseclib v3. The php verification keep getting me an error. But what makes me confuse is when i try sign the signature in ...
Devanser's user avatar
1 vote
0 answers
86 views

Ciphertext generated using PHP fails to be decrypted by a java backend with "RSA/ECB/OAEPWITHSHA-256ANDMGF1PADDING" transformation

I have PHP code that encrypts some plaintext, it looks something like the following function encryptSecretKeyWithCertificate($plainKey, $certFilePath) { $certContent = file_get_contents($...
Morpheus.47's user avatar
0 votes
1 answer
79 views

Display subjectAltName from a CSR in php

I got an issue on my end while displaying the CSR Subject Alternative Name using PHP. I run some research and found some interesting, but the problem is that, it was 10 years ago and no code for ...
lothux1987's user avatar
0 votes
0 answers
33 views

How to resolve 'zip extension and unzip/7z commands are both missing' error when installing 'phpseclib3' via Composer? [duplicate]

I am trying to install 'phpseclib3' PHP library via Composer but I am getting the following error: Failed to download paragonie/random_compat from dist: The zip extension and unzip/7z commands are ...
KWS's user avatar
  • 21
1 vote
1 answer
190 views

Verifying Signature in PHP

I need to verify a signature, I do have a sample code which I implemented in nodeJS and works like a charm. const crypto = require('crypto'); app.post('/api/verify', (req, res) => { const ...
Ala Shariaty's user avatar
0 votes
0 answers
65 views

phpseclib scp->get(remote_file_path [, $localFile]) ; returns 1 extra (NULL) character

It seems that phpseclib's scp get function returns an extra NULL at the end of file that was not in the original. I have written a script to demonstrate the problem. This script will use phpseclib ...
Dennis 's user avatar
  • 1,085
1 vote
1 answer
142 views

Golang to PHP Script for decryption

I'm trying to decrypt result from wallester encrypted card number. I've got an information how to decrypt from their support but in golang, and try to translate it using phpseclib but it failed. ...
cloudrider's user avatar
2 votes
0 answers
159 views

Uploading a directory using phpseclib3

I'm trying to use phpseclib3 to upload a directory and its contents to a remote server. Perhaps its just not possible, but I've tried to do the following: $sftp = new SFTP('ip'); $sftp->login('...
Asis's user avatar
  • 339
0 votes
1 answer
158 views

Class "phpseclib3\File\ASN1" not found

I try to work with phpseclib library, but got an error message when I call method ASN1::decodeBER($ber); local.ERROR: Class "phpseclib3\File\ASN1" not found {"exception":"[...
Tolkin Rakhmatullayev's user avatar
0 votes
1 answer
965 views

How to encrypt data with a public key using RSA method from phpseclib3?

I want to encrpypt some data with phpseclib3 with a public key. The example I found on the RSA.php file doesn't showing how to do encryption with a given public key. here is the code example on the ...
Mp. Dev's user avatar
0 votes
1 answer
425 views

unable to connect to remote server using phpseclib

I have an odd issue on our inhouse backup app when I try to access one of the severs. I have taken out the code that our connectivity test uses and placed it in a test file so as to see what is ...
ThurstonLevi's user avatar
0 votes
0 answers
357 views

Uncaught Error: Class 'phpseclib\phpseclib\Crypt\RSA' not found

When tring to use/import the phpseclib RSA class unable to find out the class, could you help me please. ` require "/vendor/autoload.php"; use phpseclib\Crypt\RSA; // INPUT DATA $privkey = &...
Ebsa Teklu's user avatar
0 votes
1 answer
439 views

Phpseclib PHP Fatal error: Uncaught Error: Class

I followed the installation instructions. I created the folder and ran the composer. I got the lock file and the vendor directory. I placed the JSON, lock files, and vendor directory on the server (...
Clint Garrity's user avatar
0 votes
0 answers
117 views

Using PHP PDO with phpseclib3

I am using phpseclib3 to successfully establish a connection to a remote server with ssh2 / public key $key = PublicKeyLoader::load(file_get_contents($keyFile), $password); $ssh2 = new SSH2($host); if ...
neucassi's user avatar
1 vote
0 answers
20 views

Getting empty string when using git shortlog -sen in phpseclib [duplicate]

I'm using the php lib phpseclib to ssh into the server and get some data output from commands. When I use the command $sftp->exec('git shortlog -sen') it returns an empty string. Using git shortlog ...
bartpulse's user avatar
1 vote
0 answers
174 views

How to generate a x509 certificate using phpseclib 3?

I'm really new to this certificates world. Is it possible to generate a x509 v2 certificate using phpseclib 3?
Carlos Souza's user avatar
1 vote
0 answers
76 views

How to add a new OID to a x509 using phpseclib?

I'm really new to this certificates world. I need to add a custom OID to a x509 certificate using phpseclib. This one will be just a string value. Ex.: 2.16.76.1.10.1 = SOME_STRING_VALUE Sorry if I'm ...
Carlos Souza's user avatar
0 votes
0 answers
139 views

PHP ssh->exec() Keep Alive util code completes its job

For sending campaign email we are using ssh->exec but if mails are more than 10k means without any message its stops working So I need to keep alive file running. How to fix?. $ssh = new SSH2('...
Maheskumar's user avatar
0 votes
1 answer
213 views

php - phpseclib - how to connect to ssh host via socks5 proxy (proxy with basic authentication user:password)

php - phpseclib - how to connect to ssh host via socks5 proxy (proxy with basic authentication user:password) we know method for ssh login via socks5 , but who knows how to connect via socks5 with ...
Grzegorz Porada's user avatar
1 vote
1 answer
395 views

Is phpseclib AES-GCM encryption compatible with javascript WebCrypto?

I'm trying to encrypt/decrypt symmetrically from php/phpseclib to js/WebCrypto(SubtleCrypto). The algorithm is AES-GCM with PBKDF2 derivation and also with plain key. I had no success. The error ...
stk's user avatar
  • 55
0 votes
2 answers
207 views

The phpseclib $sftp->chdir('//ARTDONE.G9876TT1') fails on z/OS sftp server. The windows psftp command line of "CD //ARTDONE.G9876TT1" works

I get a valid connection with phpseclib but because of the server's requirements I must issue a change remote directory command, $sftp->chdir($dir="//ARTDONE.G9876TT1"), to this directory,...
Chicago9's user avatar
1 vote
0 answers
42 views

Can you SFTP a directory to a remote server with phpseclib library [duplicate]

Does anyone know if you can move directories from a local environment to a remote environment with sftp phpseclib library. I have this: $ssh->put('/logs/file6.text', 'bfiles/file.text', SFTP::...
Jellybean's user avatar
2 votes
1 answer
628 views

phpseclib 2 RSA decryption works fine but phpseclib 3 RSA decryption not work properly

phpseclib2 sample - working use phpseclib\Crypt\RSA; $rsa = new RSA(); $rsa->loadKey($PRIVATE_KEY); $key = $rsa->decrypt(base64_decode($a)); phpseclib3 sample - not working use phpseclib3\Crypt\...
Jayendra Matarage's user avatar
1 vote
0 answers
493 views

PHP SECLIB fails to connect to server

I'm working on a project that parses servers to find websites hosted on them. I'm using flysystem (which uses seclib) on a symfony 5 application. Works fine with 28 of the 29 servers I added, but one ...
Paul's user avatar
  • 11
1 vote
1 answer
155 views

PHPSeclib Unable to Download File even tho it exist

I can't seem to understand why the file is not downloading while it really exists. Here's my code. fileDownload.PHP use \Logic\FTPConnection; $ftpPath= 'path/to/file.txt'; $localPath = 'temp/file.txt';...
Demonyowh's user avatar
  • 1,673
0 votes
0 answers
119 views

How to avoid executing commands as root using phpseclib's library?

Currently I'm executing all commands as root, which is a very bad idea and unsafe as I read. I want to execute the commands in a secure way. An example of currently using command: use \phpseclib3\Net\...
benyo's user avatar
  • 73
2 votes
1 answer
340 views

virtctl works when executed via command line but not from php exec()

I am trying to run kubectl virt commands to manage my virtual machine via PHP. First, I log in to my server with phpseclib with the following code: $ssh = new SSH2('localhost'); if (!$ssh->login('...
iristhennars's user avatar
0 votes
1 answer
210 views

How to convert ssh command 'df -h' result in json format?

I am using phpseclib SSH2 to connect ec2 server. I want to get disk space details in json format. I run the command as below: $command = "df -h"; echo $ssh->exec($command); Output is: ...
Sreedevi's user avatar
  • 107
1 vote
1 answer
777 views

Upgrading from phpseclib 2 to 3

I inherited a project years ago and and we started randomly having issues with phpseclib 2.x not decrypting anymore just a few days ago and I'm pulling my hair out on this one. No code changed in our ...
Jestep's user avatar
  • 984
1 vote
1 answer
311 views

What's the PHP equivalent of Java RSA Decryption?

What I'm trying to do here is implement Samsung Pay on PHP but so far I haven't been able to get the decryption process correctly. Below is the Java code sample that I'm trying to port in PHP: import ...
Abdush Shakoor Mohamed Nazeer's user avatar
0 votes
1 answer
696 views

How do I upload files to Amazon EC2 server in php?

I have installed Apache server on one EC2 instance to serve files in Amazon EFS file system. Then I mount EFS under apache root /var/www/html. I have created subfolders under this path. Now I would ...
Sreedevi's user avatar
  • 107
1 vote
2 answers
768 views

Message: Class 'PublicKeyLoader' not found (phpseclib)

I am trying to connect SSH to EC2 server with privatekey using php (phpseclib). I've downloaded phpseclib from GitHub and added into libraries folder. My code: /* $dir --- contains my library folder ...
Sreedevi's user avatar
  • 107
0 votes
0 answers
167 views

phpseclib : Display output of SSH command from multiple servers in HTML table

I am trying to build a dashboard to see Exim mail queue stats in one place. I want to open one page and see the mail queue count for several servers. I am using PHPSecLib to connect and run the ...
Cylon's user avatar
  • 1
0 votes
0 answers
89 views

phpseclib 3.0 : Must be connected to a terminal. bash: line 1: ./file.sh: No such file or directory

I have a problem. Indeed, I made a connection system via SSH, with phpseclib3. I can connect, take a screen of the console. But the problem, I can't execute with, commands like: screen -x 394987.bot ....
Matéo M.'s user avatar
0 votes
0 answers
232 views

Getting extra garbage with AES 256 decrypt (php, phpseclilb, openssl)

I have the following PHP code: require('/var/www/third_party_plugins/phpseclib/vendor/autoload.php'); use phpseclib3\Crypt\PublicKeyLoader; use phpseclib3\Crypt\RSA; use phpseclib3\Math\BigInteger; ...
PHPisMyFavLol's user avatar
1 vote
0 answers
209 views

Am I decrypting this correctly?

Given the following inputs: CLIENT RANDOM : 61fc160e0a6e96db43aebcca55da7fbccb97cc04d59fcc105490b4396a915ab9 SERVER RANDOM : f0ecb127db6e353a2985894c123532a8d092fafcf7cdce3a444f574e47524401 PREMASTER ...
PHPisMyFavLol's user avatar
1 vote
1 answer
972 views

"Class name must be a valid object or a string" When Installing PHPSecLib Without Composer

I'm trying to do RSA encryption using PHPSecLib, with a manual install (ie not using Composer). I'm following these manual installation instructions I found here: https://davescripts.com/manual-...
azoundria's user avatar
  • 956
2 votes
1 answer
1k views

Decrypt - PHPSECLIB

I'm trying to decrypt a string using phpseclib. My hashed string is being generated from a javascript library called jsencrypt. The result of the encryption is saved in a database. Afterwards I'm ...
Brian Moreno's user avatar
2 votes
1 answer
294 views

Sign in phpseclib and Verify in C#

I am trying to verify the authenticity of a message across PHP (phpseclib) and C#. However, there seem to be some issues with the verification on the C# side. What I have tried : Provide the public ...
Majx's user avatar
  • 151
0 votes
1 answer
358 views

SSH2 (PHP ext) long command gets malformed. (escaping code issue?)

[1D gets into long commands and break them. I have same issue in phpseclib and SSH2 PHP extension. Putty works without issue. Here is SSH2 code: $stream = ssh2_shell($session, "vt100", ...
Harrier's user avatar
-1 votes
1 answer
195 views

DangerousPhp inside phpseclib when checking with YARA [closed]

When doing malware scanning inside the PHP app using YARA, yara -r ./php.yar -s /myapp DangerousPhp /myapp/phpseclib/Net/SSH2.php 0x1140c:$system: system 0x1083a:$: call_user_func 0x1671f:$: ...
mujuonly's user avatar
  • 11.5k
-2 votes
1 answer
757 views

PHPSeclib Public Key Authentication Successful on Localhost; Failing when deployed

I've created a script which connects to a server using the phpseclib extension, using public key autentication (as you see here), by generating a key pair using ssh-keygen. What I'm facing now is that ...
DevelJoe's user avatar
  • 916

1
2 3 4 5
17