Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- import telnetlib
- import getpass
- ip = "192.168.1.1"
- prompt = "Wireless Broadband Router> " # Notice the tailing space!
- print "Assuming IP is " + ip + ". Edit this script to change that"
- print "First I'll need a username and password for the modem"
- user = raw_input("Username: ")
- passwd = getpass.getpass("Password: ")
- tn = telnetlib.Telnet(ip)
- tn.read_until("Username: ")
- tn.write(user + "\n")
- tn.read_until("Password: ")
- tn.write(passwd + "\n")
- print tn.read_until(prompt)
- print "Logged in. Initing teh lulz"
- characterset = list("abcdefghijklmnopqrstuvwxyz") # Starting with just lower case letters. caps, numbers and symbols are all possible
- path = [0]
- def increment(path):
- dbg("Incrementing " + str(path))
- done = False
- position = len(path)-1
- while not done:
- if path[position] == len(characterset)-1:
- dbg("Incrimenting character " + str(position))
- if position == 0:
- path[position] = 0
- path.append(0)
- done = True
- print "Increasing to " + str(len(path)) + " characters"
- else:
- path[position] = 0
- position = position-1
- else:
- path[position] = path[position] + 1
- done = True
- return path
- def dbg(msg):
- if False: # Change this to True to see debug messages
- print "DEBUG: " + msg
- while True: # Infinite loops are fun!
- textpath = "/"
- for char in path:
- textpath = textpath + characterset[char]
- dbg("Trying " + textpath)
- tn.write("conf print " + textpath + "\n")
- returned = tn.read_until(prompt)
- #print "> " + returned
- length = len(returned.split("\n"))
- if length != 4:
- print textpath + " returned " + str(length) + " lines"
- path = increment(path)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement