A automatic guest password changer & updater for TP-Link EC220-G5 Router.
This project automates the process of changing the guest network password of a router using Selenium and Python. It also includes a Flask server to store and retrieve the new password.
-
Automated Password Update:
- Generates a secure passkey using SHA-256 hashing.
- Adjustable passkey length and character set.
- Alternate character styles for simplicity.
- Logs into the router's admin panel and updates the guest network password.
- Uses Selenium's headless mode for smooth automation without GUI.
- use
single_run.pyfor using only one time. - use
multi_run.pyfor running the script again & again after an interval.
-
Flask Server for Password Management:
- Saves the new passkey in the server.
- Provides endpoints to retrieve and update the passkey.
- Homepage with autorefresh to show the latest password.
- You can host it anywhere.
- Python 3.8 or higher
- Google Chrome and ChromeDriver
- Flask (
pip install flask) - Selenium (
pip install selenium) - Requests library (
pip install requests)
Edit the following variables in the script to match your router and server settings in single_run.py:
router_login_page = 'http://192.168.0.1' # Router login page URL
router_password = 'YourRouterPassword' # Router admin password
server_url = 'http://localhost:5000/set_new_key' # Flask server URL
server_password = 'YourServerPassword' # Server authentication password
# Passkey settings
characters = '0123456789abcdefABCDEF' # Passkey character set
length = 8 # Length of the passkey
frequency = PasswordFrequency.MINUTE # Passkey generation frequency
password_styles = PasswordStyle.FOUR_ALTERNATE # Passkey styleEdit the time interval for running the script repeatedly in multi_run.py
time_period = 60 * 10 # 10 minutes
# set the time_period to 60 * 60 for 1 hour
# set the time_period to 60 * 60 * 24 for 1 day
# set the time_period to 60 * 60 * 24 * 7 for 1 week
# set the time_period to 60 * 60 * 24 * 30 for 1 month
# set it as you likeEdit the following variables in the Flask server code:
password_file = "pass.txt" # File to store the passkey
server_password = "YourServerPassword" # Authentication password
TITLE = "MY WIFI" # Web page title-
Install the required Python libraries.
-
Update the script configuration as described above.
-
Run the script:
For single run :
python single_run.py
For repeated runs :
python multi_run.py
-
Install Flask (
pip install flask). -
Run the Flask server:
cd ./server python app.py -
Access the server via
http://localhost:5000.
- Description: Updates the passkey stored on the server.
- Request Body:
password(string): Authentication password.new_key(string): New passkey to store.
- Response:
200 OK: Passkey updated successfully.400 Bad Request: Invalid password or missing key.
- Description: Retrieves the saved passkey.
- Response:
200 OK: Returns the passkey as JSON.
- Description: Displays the current passkey on a web page.
| Router page | Flask Server |
|---|---|
![]() |
![]() |
- The script assumes specific router interface element IDs and classes, which may vary between router models.
- The default router admin URL and credentials must be manually configured.
- This repo is mainly focused for TP-Link EC220-G5 Router.
This project is licensed under the MIT License. See the LICENSE file for details.
Feel free to fork this repository and submit pull requests to enhance functionality or fix issues.

