You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Enter the host & credentials used to log in to your router management page. Username is admin by default. But you may pass username as third parameter. Some routers have default username - user
Use Local Password which is for Log In with Local Password. Login with TP-LINK ID doesnt work
If you use https connection - You need to turn on "Local Management via HTTPS" (advanced->system->administration) in the router web UI
fromtplinkrouterc6uimport (
TplinkRouterProvider,
TplinkRouterV1_11,
TplinkRouterSG, # For routers like Archer BE3600, Archer BE230TplinkRouterAX72,
TplinkRouter,
TplinkC1200Router,
TplinkC5400XRouter,
TPLinkMRClient, # Class for MR series routers which supports old firmwares with AES cipher CBC modeTPLinkMRClientGCM, # Class for MR series routers which supports AES cipher GCM modeTPLinkMR200Client,
TPLinkMR6400v7Client,
TPLinkMR600Client, # Class for MR series that replaced the RSA key exchange with ECIES over NIST P-224TPLinkVRClient,
TPLinkVR400v2Client,
TplinkVR1200vRouter,
TPLinkEXClient, # Class for EX series routers which supports old firmwares with AES cipher CBC modeTPLinkEXClientGCM, # Class for EX series routers which supports AES cipher GCM modeTPLinkRClient, # For routers like TL-R470GP-ACTPLinkXDRClient,
TPLinkDecoClient,
TplinkDecoE4RRouter,
TPLinkEAP115Client,
TPLinkCPE210Client,
TPLinkSG108EClient,
TplinkC80Router,
TplinkWDRRouter,
TPLinkC50Client,
TPLinkWR841NClient,
TplinkRE330Router,
TplinkC3200Router,
Connection
)
fromloggingimportLoggerimporttraceback# Prefer the provider: it picks a matching client for your routerrouter=TplinkRouterProvider.get_client('http://192.168.0.1', 'password')
logger=Logger('test')
# You may use a client class directly, e.g.:# router = TplinkRouter('http://192.168.0.1', 'password')# You may also pass username if it is different and a logger to log errors as# router = TplinkRouter('http://192.168.0.1', 'password', 'admin2', logger=logger)# C5400X / similar: use web encrypted password (see Web Encrypted Password below)# router = TplinkC5400XRouter('http://192.168.0.1', 'WebEncryptedPassword', logger=logger)try:
# Or: with router: # authorize on enter, logout on exitrouter.authorize()
# Get firmware info - returns Firmwarefirmware=router.get_firmware()
# Get status info - returns Statusstatus=router.get_status()
ifnotstatus.guest_2g_enable: # check if guest 2.4G wifi is disablerouter.set_wifi(Connection.GUEST_2G, True) # turn on guest 2.4G wifi# Get IPv6 status (not implemented on every client → NotImplementedError)try:
ipv6_status=router.get_ipv6_status()
print(ipv6_status.wan_ipv6_addr, ipv6_status.wan_ipv6_gateway)
exceptNotImplementedError:
pass# Optional methods (not on every client)try:
reservations=router.get_ipv4_reservations()
reservations.sort(key=lambdaa: a.ipaddr)
forresinreservations:
print(f"{res.macaddr}{res.ipaddr:16s}{res.hostname:36}{'Permanent':12}")
except (AttributeError, NotImplementedError):
passtry:
leases=router.get_ipv4_dhcp_leases()
leases.sort(key=lambdaa: a.ipaddr)
forleaseinleases:
print(f"{lease.macaddr}{lease.ipaddr:16s}{lease.hostname:36}{lease.lease_time:12}")
except (AttributeError, NotImplementedError):
passrouter.logout() # always logout; TP-Link Web Interface only supports up to 1 user logged inexceptExceptionase:
logger.error(traceback.format_exc())
The TP-Link Web Interface only supports up to 1 user logged in at a time (for security reasons, apparently).
So before action you need to authorize and after logout. You can also use with router: (calls authorize() / logout() automatically).
If you got exception - use web encrypted password instead. Check the documentation!
or you have TP-link C5400X or similar router you need to get web encrypted password by these actions:
Go to the login page of your router. (default: 192.168.0.1).
Type in the password you use to login into the password field.
Click somewhere else on the page so that the password field is not selected anymore.
Open the JavaScript console of your browser (usually by pressing F12 and then clicking on "Console").
Type document.getElementById("login-password").value;
Copy the returned value as password and use it.
Functions
Not every method is available on every client. Methods below get_ipv6_status that are model-specific (reservations, VPN client, SMS/LTE, …) raise AttributeError / NotImplementedError or are simply missing on unsupported routers.
Make changes to files within the tplinkrouterc6u directory.
Exercise the changes following the "Usage" section above.
The sanity check test.py illustrates a few tests and runs through a list of queries in queries.txt creating logs of the results of each query in the logs folder. This can be used to capture the dictionary output of all cgi-bin form submissions.