Advertisement
HenrikG

Cisco 819 SMS spam script

Aug 9th, 2016
340
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.20 KB | None | 0 0
  1. # The script will login to Cisco 819 routers and send a text message from it to the destination phone number in "phone_number".
  2. # Essentially spamming that number, depending on how many Cisco 819 routers you have.
  3.  
  4. import telnetlib
  5. import socket
  6. import getpass
  7. import time
  8. import sys
  9.  
  10.  
  11. # Change this to "True" if you actually want to restart the APs.
  12. # Change this to "False" if you only want to see what the script does, without restarting any APs.
  13.  
  14. live = True
  15.  
  16. # Enter the phone number and message you want to send.
  17. phone_number = "555 555 555"
  18. message = "What up"
  19.  
  20.  
  21. if live:
  22.         print ('The script is live!')
  23.         raw_input ('Press ENTER to continue!')
  24. else:
  25.         print ('The script is NOT live!')
  26.         print ('Change the variable called live to True if you want the script to actually restart access points')
  27.         raw_input ('Press ENTER to continue!')
  28.  
  29.  
  30. # The login credentials are stored here
  31. username = "******"
  32. password = "******"
  33.  
  34. # Enter the hostnames of the Cisco 819 4G routers in the text file.
  35. router_list_counter = open('C:/Users/henrgr/Documents/python_scripts/routers.txt', 'r')
  36. router_list = open('C:/Users/henrgr/Documents/python_scripts/routers.txt', 'r')
  37.  
  38. total_number_of_routers = 0
  39. loop_number = 0
  40.  
  41. # Count number of lines in text file
  42. for number_of_routers in router_list_counter:
  43.  
  44.         total_number_of_routers = total_number_of_routers + 1
  45.  
  46. print ('Number of lines in document: ' + str(total_number_of_routers))
  47.  
  48.  
  49.  
  50. for router in router_list:
  51.  
  52.         loop_number = loop_number + 1
  53.  
  54.         # Remove new lines in the text file.
  55.         router = router.replace("\n", "")
  56.  
  57.         #print ('\nConnecting to: {0}.'.format(router))
  58.  
  59.         print ('\nConnecting to router nr ' + str(loop_number) + '/' + str(total_number_of_routers) + ': '+ router)
  60.  
  61.         try:
  62.                 session = telnetlib.Telnet(router, 23, 5)
  63.         except socket.timeout:
  64.                 print ('Telnet timeout: {0}.'.format(router))
  65.         else:
  66.                 print ('Connection successfull.')
  67.                 session.read_until(b'Username:')
  68.                 session.write(username.encode('ascii') + b'\r')
  69.                 session.read_until(b'Password:')
  70.                 session.write(password.encode('ascii') + b'\r')
  71.                 session.read_until(b'#')
  72.                 print ('Login Successful.')
  73.  
  74.                 time.sleep(1)
  75.  
  76.                 # 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.
  77.                 if live:
  78.                         session.write(b'cell 0 lte sms send ' + phone_number + ' ' + message + ' \n')
  79.                         session.write(b'exit\n')
  80.                         print ('Message sent.')
  81.                         time.sleep(3)
  82.                 else:
  83.                         print ('Test! {0} will not send SMS!'.format(router))
  84.                         print ('cell 0 lte sms send ' + phone_number + ' ' + message + ' \n')
  85.                         session.write(b'!cell 0 lte sms send ' + phone_number + ' ' + message + ' \n')
  86.                         session.write(b'exit\n')
  87.                         time.sleep(3)
  88.  
  89. raw_input('\n\nAll routers have sent the SMS.')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement