使用nodejs Telnet登录时不能输入密码
can't enter password in telnet login with nodejs
如果我从windows命令行远程登录,没有问题:
> telnet telehack.com
(... wait until a '.' appears)
. login
username? example
password? (examplepass) * * * * * * *
Logged...
(...)
@ (This is the prompt when you are logged)
因此,有了shell,我可以登录并做所有事情,并且使用为nodejs编写的javascript代码,我可以做所有事情,但输入密码。然后我能够:连接到主机+端口,输入"login"命令,输入"示例"用户名(实际存在),当我尝试输入"examplepass"(实际上也存在)时,telnet服务器用"* * * * * * *"回答我,但我无法通过该步骤。我将提供代码,任何帮助都是感激的。
var net = require('net');
var conn = net.createConnection(23, 'telehack.com');
conn.setEncoding('utf-8');
conn.on('connect', function() {
console.log('connected to the server');
conn.on('data', function(data) {
console.log('' + data);
if (data.indexOf('username') != -1) {
conn.write('example'r'n');
}
if (data.indexOf('pass') != -1) {
conn.write('examplepass'r'n');
}
if (data.indexOf("@") != -1) {
conn.write('date'r'n');
}
if (data.slice(-1) == '.'){
console.log('slice: '+data.slice(-1));
//conn.emit('login');
conn.write('login'r'n');
}
});
});
看看这个
var net = require('net');
var client = net.connect(parseInt(process.argv[3]),process.argv[2],function(){
client.setEncoding('utf8');
console.log('Connected!!');
client.on('data',function(chunk){
console.log(chunk);
});
process.stdin.resume(); // Activate STDIN
process.stdin.setEncoding('utf8'); // Set it to string encoding
process.stdin.on('data',function(chunk){ // Pipe STDIN to Socket.out
client.write(chunk);
});
});
您必须重新启用stdin并从stdin发送任何数据到套接字。
相关文章:
- JqueryUI对话框没有'不能使用特定的输入名称
- 用户名输入如果其他块不能正常工作/Javascript-jQuery-AJAX
- Javascript/Php聊天-输入is'不能在一个文本框中工作
- 使输入不可聚焦,tabindex=“-1〃;不会'Don’我不能做这项工作
- 在我限制输入字母后,不能退格或键入任何内容
- 在输入字段上使用它-can'我不能从函数中取出变量,这样我就可以使用它了
- 如何验证文本框,使我不能输入零作为第一个数字
- 我不能在 JavaScript 生成的输入文本框中使用退格键
- Jquery 不能在表单内选择输入元素,但在表单外部选择输入元素
- 不能将 document.execCommand('copy') 与输入类型文件一起使用
- angular-UI select2 不能在同一控制器中使用 select2Options 进行多个输入
- 输入的第一个字母.value;t不能转换成大写字母
- 单选按钮的 OnChange 事件处理程序(输入类型=“单选”)不能作为一个值工作
- 为什么我不能在输入时清空文本区域?
- 流星-不能从输入字段收集信息
- 不能将更改事件绑定到ajax调用的文件输入
- 使用FB后,不能在iframe应用程序中编辑输入字段.登录Firefox浏览器
- 我不能在Angular2中设置一个必须的输入
- 不能输入async(同步)函数的回调/空结果
- 使用nodejs Telnet登录时不能输入密码