|
import telnetlib,threading
ipfile = open('swiplist.txt')
ipall = [ ip.strip('\n') for ip in ipfile.readlines() ]
def get_mac(ip):
try:
tel = telnetlib.Telnet(ip)
tel.read_until('Username:')
tel.write('admin'+'\n')
tel.read_until('Password:')
tel.write('password'+'\n')
tel.read_until('>')
tel.write('dis mac-add ' + mac +'\n')
data = tel.read_until('>')
if 'sticky' in data:
print 'telnet '+ ip
print data
print ip,'done'
except:print 'can not connect to %s' %ip
threads = []
numbers = range(len(ipall))
mac = raw_input('input mac add ,like => aabb-ccdd-eeff \n >')
for i in numbers:
t = threading.Thread(target=get_mac,args=(ipall,))
threads.append(t)
if __name__ == '__main__':
for i in numbers:
threads.start()
print 'all done' |
|
|