Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- !#/usr/bin/env python
- import getpass
- import sys
- import telnetlib
- user = raw_input("Enter your telnet username: ")
- password = getpass.getpass()
- #opens file called targetnodes that contains target ips
- #File should be in same directory as the script
- f = open('targetnodes')
- for node in f:
- print "Telnetting to " + node
- HOST = node
- tn = telnetlib.Telnet(HOST)
- #Reads telnet session until Username Prompt
- #Set this to the prompt the target system uses
- #For example, Cisco IOS prompt is 'Username: '
- tn.read_until("Username: ")
- tn.write(user + "\n")
- if password:
- #reads telnet session until Password prompt.
- #Set this to the prompt that the target system uses for passwords
- #For example, Cisco IOS prompt is 'Password: '
- tn.read_until("Password: ")
- tn.write(password + "\n")
- tn.write("Commands go here")
- tn.write("Commands go here")
- tn.write("Commands go here")
- tn.write("Commands go here")
- print tn.read_all()
Add Comment
Please, Sign In to add comment