Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from telnetlib import Telnet
- from glob import glob
- from base64 import b64decode
- from time import sleep
- def get_id():
- f = open('identifier.base' , 'r')
- keep = f.read()
- return keep.split('\n')
- def countint(interfaces):
- utp = [0 , 0 , 0 , 0]
- fiber = [0 , 0 , 0 , 0]
- id_utp , id_fiber = get_id()
- print interfaces
- print id_utp
- print id_fiber
- # for port in interfaces:
- def get_interface(text , hostlen=0):
- far = hostlen+7
- text = text[text.find('status')+8 : text.find('KickmeOff')-far]
- lines = text.split('\n')
- intf = [line.split() for line in lines if len(line.split()) > 1]
- print intf
- return intf
- def get_hostname(text):
- text = text[text.find('KickmeOn')+10 : text.find('#show')]
- print text
- return text
- def callmebaby(ip, username, password):
- try:
- call = Telnet(ip , timeout=5)
- call.read_until("sername: ")
- call.write(username + '\n')
- call.read_until("assword: ")
- call.write(password + '\n')
- sleep(1)
- print '[+] Login Success.'
- if(call.read_until('>',2).find('>') != -1):
- call.write('aitadmin'+'\n')
- # !===================================================
- call.write('terminal length 0'+'\n')
- call.write('!==== KickmeOn'+'\n')
- call.write('show interface status'+'\n')
- call.write('!==== KickmeOff'+'\n')
- call.write('terminal length 24'+'\n')
- call.write('exit'+'\n')
- call.close
- print '[+] Execute Command Success.'
- plaintext = call.read_all()
- hostname = get_hostname(plaintext)
- lstint = get_interface(plaintext , hostlen=len(hostname))
- countint(lstint[1:])
- print '[+] Analyze Log Success.'
- except IOError,ImportError:
- print '[-] Can not Telnet.'
- def get_ip():
- filesName = glob('*.txt')
- all_ip = []
- for fil in filesName:
- text = open(fil , 'r')
- device_ip = text.read().split('\r\n')
- if(len(device_ip) != 0):
- all_ip.append(device_ip)
- else:
- all_ip.append('Null')
- return all_ip
- username = str(b64decode('c2FrcmFwZWU='))
- password = str(b64decode('c2FrcmFwZWU0MQ=='))
- if __name__ == '__main__':
- for ipl in get_ip():
- if(ipl is not 'Null'):
- for ip in ipl:
- callmebaby(ip, username, password)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement