import threading
import time
import telnetlib
def worker(host):
tn = telnetlib.Telnet(host)
tn.write(b'\r\n')
tn.read_until(b":")
tn.write('admin'.encode('utf-8')+b'\r\n')
tn.read_until(b":")
tn.write('admin'.encode('utf-8')+b'\r\n')
tn.read_until(b">")
tn.write('enable'.encode('utf-8')+b'\r\n')
tn.read_until(b":")
tn.write('admin'.encode('utf-8')+b'\r\n')
tn.read_until(b"#")
tn.write('config'.encode('utf-8')+b'\r\n')
tn.read_until(b"#")
cmd = 'show adsl profile'
tn.write(cmd.encode('utf-8')+b'\r\n')
msg=tn.read_until(b"#")
print(msg)
result=0;
if(msg.find(': ZTE4M'.encode('utf-8')) !=-1):
result=1
if(result==1):
tn.write('adsl-profile zte4m'.encode('utf-8')+b"\r\n")
msg=tn.read_until(b"]");
print(msg)
for i in range(10):
tn.write(b"\r\n")
msg=tn.read_until(b"]")
print(msg)
tn.write('4928'.encode('utf-8')+b"\r\n")
msg=tn.read_until(b"]")
print(msg)
tn.write(b"\r\n")
msg=tn.read_until(b"]")
print(msg)
tn.write('4928'.encode('utf-8')+b"\r\n")
msg=tn.read_until(b"]")
print(msg)
for i in range(36):
tn.write(b"\r\n")
msg=tn.read_until(b"]")
print(msg)
tn.write(b"\r\n")
msg=tn.read_until(b"#")
print(msg)
tn.write('exit'.encode('utf-8')+b'\r\n')
tn.read_until(b"#")
tn.write('save'.encode('utf-8')+b'\r\n')
tn.close()
f=open("c:\\9806.txt","r")
for line in f:
host=line;
t=threading.Thread(target=worker,args=(host,))
t.start()
t.join(10)
f.close()
test
最新推荐文章于 2023-03-13 22:14:50 发布