Created
December 29, 2017 10:13
-
-
Save farooqkz/400a2c1dab62bb5951ef6e95b7e3b898 to your computer and use it in GitHub Desktop.
A small script to get my public IP from my router/modem
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import telnetlib | |
PASSWORD = "admin" # change these two | |
ADDR = "192.168.1.1" | |
t = telnetlib.Telnet(host=ADDR) | |
t.read_until("Password:".encode()) | |
t.write((PASSWORD + "\r\n").encode()) | |
t.read_until("TP-LINK> ".encode()) | |
t.write("show wan status\r\n".encode()) | |
data = t.read_until("TP-LINK> ".encode()).decode() | |
t.write("exit\r\n".encode()) | |
t.close | |
for line in data.split("\r\n"): | |
if "Ip" in line: | |
print(line.split()[-1], end="") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment