Advertisement
thefinn93

Frontier Modem config key brute forcer

Oct 15th, 2012
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.85 KB | None | 0 0
  1. #!/usr/bin/env python
  2. import telnetlib
  3. import getpass
  4.  
  5. ip = "192.168.1.1"
  6. prompt = "Wireless Broadband Router> " # Notice the tailing space!
  7.  
  8.  
  9. print "Assuming IP is " + ip + ". Edit this script to change that"
  10. print "First I'll need a username and password for the modem"
  11. user = raw_input("Username: ")
  12. passwd = getpass.getpass("Password: ")
  13.  
  14. tn = telnetlib.Telnet(ip)
  15. tn.read_until("Username: ")
  16. tn.write(user + "\n")
  17. tn.read_until("Password: ")
  18. tn.write(passwd + "\n")
  19. print tn.read_until(prompt)
  20. print "Logged in. Initing teh lulz"
  21.  
  22. characterset = list("abcdefghijklmnopqrstuvwxyz") # Starting with just lower case letters. caps, numbers and symbols are all possible
  23. path = [0]
  24.  
  25. def increment(path):
  26.     dbg("Incrementing " + str(path))
  27.     done = False
  28.     position = len(path)-1
  29.     while not done:
  30.         if path[position] == len(characterset)-1:
  31.             dbg("Incrimenting character " + str(position))
  32.             if position == 0:
  33.                 path[position] = 0
  34.                 path.append(0)
  35.                 done = True
  36.                 print "Increasing to " + str(len(path)) + " characters"
  37.             else:
  38.                 path[position] = 0
  39.                 position = position-1
  40.         else:
  41.             path[position] = path[position] + 1
  42.             done = True
  43.     return path
  44.    
  45. def dbg(msg):
  46.     if False:       # Change this to True to see debug messages
  47.         print "DEBUG: " + msg
  48.  
  49. while True:     # Infinite loops are fun!
  50.     textpath = "/"
  51.     for char in path:
  52.         textpath = textpath + characterset[char]
  53.     dbg("Trying " + textpath)
  54.     tn.write("conf print " + textpath + "\n")
  55.     returned = tn.read_until(prompt)
  56.     #print "> " + returned
  57.     length = len(returned.split("\n"))
  58.     if length != 4:
  59.         print textpath + " returned " + str(length) + " lines"
  60.     path = increment(path)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement