Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
SFTP client for node.js, mainly a sftp
wrapper.
This is a fork of the ftps
module. This fork only supports sftp, and uses the sftp
command instead of lftp
. This allows you to specify ssh-specific options such as private key file.
You need to have the executable sftp
installed on your computer.
If you are using password authentication, you also need to have the sshpass
utility installed.
npm install sftps
var SFTPS = require('sftps');
var sftp = new SFTPS({
host: 'domain.com', // required
username: 'Test', // required
password: 'Test', // required
port: 22 // optional
});
// Do some amazing things
sftp.cd('myDir').addFile(__dirname + '/test.txt').exec(console.log);
Here are chainable fonctions :
ftps.ls()
ftps.pwd()
ftps.cd(directory)
ftps.cat(pathToRemoteFiles)
ftps.put(pathToLocalFile, [pathToRemoteFile]) // alias: addFile
ftps.get(pathToRemoteFile, [pathToLocalFile]) // download remote file and save to local path (if not given, use same name as remote file), alias: getFile
ftps.mv(from, to) // alias move
ftps.rm(file1, file2, ...) // alias remove
Execute a command on the remote server:
sftp.raw('ls -l')
For information, ls, pwd, ... rm are just some alias of raw() method.
Run the commands !
sftp.exec(function (err, res) {
// err will be null (to respect async convention)
// res is an hash with { error: stderr || null, data: stdout }
});
Also, take note that if a command fails it will not stop the next commands from executing, for example:
sftp.cd('non-existing-dir/').affFile('./test.txt').exec(console.log);
/*
Will add file on ~/ and give:
{
error: 'cd: non-existing-dir: No such file or directory\n',
data: ''
}
So...be cautious because ./test.txt has been added
*/
Just because I didn't found sftp and ftps module in node.js, it's pretty dirty to spawn sftp
command, but sorry, it does the work for me, maybe for you too :)
Ah and sorry for tests, it's a hack, so I just do some manual tests.
FAQs
SFTP client for node.js, wrapping the 'sftp' command
We found that sftps demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.