Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # The script will login to Cisco 819 routers and send a text message from it to the destination phone number in "phone_number".
- # Essentially spamming that number, depending on how many Cisco 819 routers you have.
- import telnetlib
- import socket
- import getpass
- import time
- import sys
- # Change this to "True" if you actually want to restart the APs.
- # Change this to "False" if you only want to see what the script does, without restarting any APs.
- live = True
- # Enter the phone number and message you want to send.
- phone_number = "555 555 555"
- message = "What up"
- if live:
- print ('The script is live!')
- raw_input ('Press ENTER to continue!')
- else:
- print ('The script is NOT live!')
- print ('Change the variable called live to True if you want the script to actually restart access points')
- raw_input ('Press ENTER to continue!')
- # The login credentials are stored here
- username = "******"
- password = "******"
- # Enter the hostnames of the Cisco 819 4G routers in the text file.
- router_list_counter = open('C:/Users/henrgr/Documents/python_scripts/routers.txt', 'r')
- router_list = open('C:/Users/henrgr/Documents/python_scripts/routers.txt', 'r')
- total_number_of_routers = 0
- loop_number = 0
- # Count number of lines in text file
- for number_of_routers in router_list_counter:
- total_number_of_routers = total_number_of_routers + 1
- print ('Number of lines in document: ' + str(total_number_of_routers))
- for router in router_list:
- loop_number = loop_number + 1
- # Remove new lines in the text file.
- router = router.replace("\n", "")
- #print ('\nConnecting to: {0}.'.format(router))
- print ('\nConnecting to router nr ' + str(loop_number) + '/' + str(total_number_of_routers) + ': '+ router)
- try:
- session = telnetlib.Telnet(router, 23, 5)
- except socket.timeout:
- print ('Telnet timeout: {0}.'.format(router))
- else:
- print ('Connection successfull.')
- session.read_until(b'Username:')
- session.write(username.encode('ascii') + b'\r')
- session.read_until(b'Password:')
- session.write(password.encode('ascii') + b'\r')
- session.read_until(b'#')
- print ('Login Successful.')
- time.sleep(1)
- # If you have not chosen the script to be live it will write the samme command but with a "!" infront so it will not be effective.
- if live:
- session.write(b'cell 0 lte sms send ' + phone_number + ' ' + message + ' \n')
- session.write(b'exit\n')
- print ('Message sent.')
- time.sleep(3)
- else:
- print ('Test! {0} will not send SMS!'.format(router))
- print ('cell 0 lte sms send ' + phone_number + ' ' + message + ' \n')
- session.write(b'!cell 0 lte sms send ' + phone_number + ' ' + message + ' \n')
- session.write(b'exit\n')
- time.sleep(3)
- raw_input('\n\nAll routers have sent the SMS.')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement