?? 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 + -