Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

telnet-client

Package Overview
Dependencies
Maintainers
1
Versions
108
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

telnet-client - npm Package Compare versions

Comparing version 0.12.0 to 0.12.1

test/005_login.js

80

app.js

@@ -1,72 +0,20 @@

var telnet = require('./lib/index')
var telnet_server = require('telnet')
var telnet = require('./lib')
var srv = telnet_server.createServer(function(c) {
c.write(new Buffer("BusyBox v1.19.2 () built-in shell (ash)\n"
+ "Enter 'help' for a list of built-in commands.\n\n/ # ", 'ascii'))
var connection = new telnet()
c.on('data', function() {
c.write(new Buffer("uptime\r\n23:14 up 1 day, 21:50, 6 users, "
+ "load averages: 1.41 1.43 1.41\r\n", 'ascii'))
c.write(new Buffer("/ # ", 'ascii'))
})
})
srv.listen(2323, function() {
var connection = new telnet()
var params = {
host: '127.0.0.1',
port: 2323,
shellPrompt: '/ # ',
timeout: 1500
}
connection.on('ready', function(prompt) {
connection.exec('uptime', function(err, resp) {
console.log(err, resp)
connection.end()
})
})
connection.connect(params);
})
/*
var params = {
connection.connect({
host: '127.0.0.1',
port: 8080,
port: 1337,
execTimeout: 1000,
negotiationMandatory: false
}
c.on('failedlogin', function() {
console.log('login failed')
})
c.on("connect", function() {
console.log('sending data')
c.send('something', {
ors: '\r\n',
waitfor: '\n'
}, function(error, data) {
console.log('received a response', data)
})
})
c.connect(params).then(function() {
setInterval(function() {
console.log('sending')
c.send('something', {
ors: '\r\n',
waitfor: '\n'
}, function(error, data) {
console.log('received a response:', error, data)
}).then(function() {
connection.send('hi')
.then(function(res) {
console.log(res)
}, function(error) {
console.log(error)
})
}, 2000)
.catch(function(error) {
console.log(error)
})
})
*/

@@ -27,2 +27,3 @@ // Node.js Telnet client

this.failedLoginMatch = opts.failedLoginMatch
this.loginPromptReceived = false

@@ -214,3 +215,18 @@ this.debug = (typeof opts.debug !== 'undefined' ? opts.debug : false)

if (typeof this.failedLoginMatch !== 'undefined' && utils.search(stringData, this.failedLoginMatch) !== -1) {
if (utils.search(stringData, this.loginPrompt) !== -1) {
// make sure we don't end up in an infinite loop
if (!this.loginPromptReceived) {
this.telnetState = 'login'
this._login('username')
this.loginPromptReceived = true;
} else {
this.emit('failedlogin', stringData)
this.destroy()
}
}
else if (utils.search(stringData, this.passwordPrompt) !== -1) {
this.telnetState = 'login'
this._login('password')
}
else if (typeof this.failedLoginMatch !== 'undefined' && utils.search(stringData, this.failedLoginMatch) !== -1) {
this.telnetState = 'failedlogin'

@@ -225,2 +241,3 @@

this.stringData = ''
this.loginPromptReceived = false;

@@ -231,10 +248,3 @@ this.emit('ready', this.shellPrompt)

}
else if (utils.search(stringData, this.loginPrompt) !== -1) {
this.telnetState = 'login'
this._login('username')
}
else if (utils.search(stringData, this.passwordPrompt) !== -1) {
this.telnetState = 'login'
this._login('password')
}
else return

@@ -241,0 +251,0 @@ }

@@ -8,3 +8,3 @@ {

},
"version": "0.12.0",
"version": "0.12.1",
"main": "./lib/index.js",

@@ -53,4 +53,7 @@ "engine": "node >= 6.9.1",

"email": "pghalliday@gmail.com"
},
{
"name": "kaYcee"
}
]
}

@@ -19,3 +19,3 @@ var telnet = process.env.NODETELNETCLIENT_COV

})
srv.listen(2323, function() {

@@ -48,5 +48,5 @@ callback()

})
connection.connect(params);
}
})
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc