Python脚本如下:

 

import sys
import telnetlib
#import getpass
ip='192.168.'
bip=0
cip='1'
while bip<=254:
        try:
                HOST = ip + str(bip) + '.' + cip
                print ("ipis:%s"%HOST)
                user = 'msfadmin'
                password = 'msfadmin'
                tn = telnetlib.Telnet(HOST)
                tn.read_until("login:")
                tn.write(user+"\n")
                if password:
                        tn.read_until("Password:")
                        tn.write(password+"\n")
                tn.write("cat /a.txt\n")
                tn.write("exit\n")

                print (tn.read_all())
                bip=int(bip)
                bip+=1
        except:
                print('waring!! ip is:%s'% HOST)
                bip=int(bip)
                bip+=1
                continue
朱古力

By 朱古力

一条咸鱼

在 “python脚本实现telnet批量登录” 有 1 条评论

发表评论

电子邮件地址不会被公开。 必填项已用*标注