Telnet以用户名和密码登录到邮件服务器 [英] Telnet to login with username and password to mail Server

查看:493
本文介绍了Telnet以用户名和密码登录到邮件服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试通过telnet连接到邮件服务器时遇到一些问题.我遇到的主要问题是我需要创建一个脚本来将我登录到目的地,但找不到找到回应的方法.密码.

I am having some issues trying to connect through telnet to a mail server.The main problem that I am having is that I need to create a script that logs me to the destination and I can't find a way to echo the password.

我尝试过的事情:

telnet host -l username ; echo 'password'

它仍然要求输入密码.有什么办法可以解决这个问题,或者我做错了什么?

And still it asks for my password.Is there any way to fix this or I am doing something wrong?

推荐答案

首先,您可以使用eval:

eval "{ echo user_name; sleep 1; echo pass; sleep 1; echo '?'; sleep 5; }" | telnet host_address

请确保替换要运行的命令user_namepass?和telnet主机正在侦听的host_address;对我来说是本地IP.

Make sure to replace user_name, pass, ? which is the command you want to run and host_address where your telnet host is listening; for me it is a local IP.

编写一组命令并将其通过管道传输到telnet应用程序中非常容易.您需要做的就是这样:

It’s surprisingly easy to script a set of command and pipe them into the telnet application. All you need to do is something like this:

(echo commandname;echo anothercommand) | telnet host_address

唯一的问题是您必须先完成登录,而该登录并不会立即显示.因此,如果您先输入"echo admin"然后输入"echo password",它会发生得太快,并且不会发送到服务器.解决方案?使用sleep命令!

The only problem is the nagging login that you have to get through… it doesn’t show up right away. So if you pipe in an "echo admin" and then "echo password," it will happen too quickly and won’t be sent to the server. The solution? Use the sleep command!

添加几个sleep 3命令,等待三秒钟,即可解决此问题.首先,我们回显用户名和密码,然后回显重新启动命令,每次之间等待三秒钟.最终命令将立即重新启动服务器:

Adding in a couple of sleep 3 commands, to wait three seconds, solves the problem. First we’ll echo the username and password, and then we’ll echo the reboot command, and each time we’ll wait three seconds between. The final command will reboot the server immediately:

(sleep 3;echo admin;sleep 3;echo mypassword;sleep 3;echo system reboot;sleep 3;) | telnet host_address

您可以将其放入shell脚本中,并在需要时运行它.或者,您可以像这样(在OS X或Linux上)将其添加到您的cron中:

You can put this into a shell script and run it whenever you want. Or you can add it to your cron like this (on OS X or Linux):

crontab -e

将此行添加到某处:

1 7 * * * (sleep 3;echo admin;sleep 3;echo mypassword;sleep 3;echo system reboot;sleep 3;) | telnet host_address

这将在每天早上7:01重新启动路由器.

This will reboot your router at 7:01 AM each morning.

这篇关于Telnet以用户名和密码登录到邮件服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆