Skip to content

Instantly share code, notes, and snippets.

@shayas
Last active September 27, 2015 22:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shayas/8dffc1d636d900da0830 to your computer and use it in GitHub Desktop.
Save shayas/8dffc1d636d900da0830 to your computer and use it in GitHub Desktop.
'''
Date : 9/19/2015
Author : Shay Ashkenazi
Simple Telnet Catcher for 3Com 3CRWER100-75 Router
==================================================
As this router boots, port 9000 is opened for only 1 second.
This simple script will open a connection and leave this port open.
You may now proceed to Redboot
Instructions:
-------------
1. Ping 192.168.1.1 and make sure you get to the router
2. Start this script
3. Power off the router
4. Connect the router to power
5. Wait for the connection to be made and this script to finish
6. Open PuTTY and connect using telnet at port 9000.
If it doesn't work:
-------------------
1. Make sure the router is at 192.168.1.1. Otherwise, change HOST to the proper IP.
2. Try changing the timeout variable (TOUT).
3. Try to reset the router before step 1.
'''
import telnetlib
if __name__ == "__main__":
# Connection variables
HOST = "192.168.1.1"
PORT = 9000
TOUT = 0.5
# Loop until connected
connected = False
while not connected:
try:
tn = telnetlib.Telnet(HOST, PORT, TOUT)
print("connected!")
connected = True
except:
print("can't connect.")
# Send ^C to stop boot process
# By that, telnet will stay open
commands = [b"\x03\n",b"\n"]
response = ""
for command in commands:
response = tn.read_until(b"\n")
print(HOST + " : " + str(response))
tn.write(command)
print("localhost : " + str(command))
# Now simply connect via simple telnet client, like PuTTY
print("Done.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment