📄 pythontelnet.py
字号:
# -*- coding: utf-8 -*-
'''程序的目的:您只要将下面内容中的IP地址、用户名和密码替换成您想登录的计算机
就可以访问这台计算机,并且执行相关命令'''
import telnetlib
host = {'ip': '0.0.0.0', 'user': 'username', 'password':'password','commands':'commands'}
host['ip']='10.10.10.10'
host['user']='username'
host['password']='yourpassword'
#下面一行是3个命令,可以根据需要进行编辑
host['commands']=['cd ', 'pwd','ls']
def do(host):
#print host
tn = telnetlib.Telnet(host['ip'])
#tn.set_debuglevel(2)
tn.read_until("帐号: ",2)
tn.write(host['user'] + "\n")
tn.read_until("密码: ",2)
tn.write(host['password'] + "\n")
for command in host['commands']:
tn.write(command+'\n')
tn.write("exit\n")
print tn.read_all()
print '远程执行任务结束!!!'
do(host)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -