Add grab-locks-from-api: extract lock secrets via TTLock management API - #2
Open
nsleigh wants to merge 8 commits into
Open
Add grab-locks-from-api: extract lock secrets via TTLock management API#2nsleigh wants to merge 8 commits into
nsleigh wants to merge 8 commits into
Conversation
Provides an alternative to the database extraction method that doesn't require a rooted device — uses the TTLock management API to retrieve lock MAC addresses and AES keys via OAuth credentials. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds python-dotenv support so credentials are read from a gitignored .env file rather than hardcoded in the script. Also fixes Windows console encoding and updates README with install step. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Use the aesKeyStr field from the API response instead of lockKey, as it contains the correct 16-byte key in comma-separated hex format. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Decodes adminPwd and lockKey fields using the same TABLE-based XOR algorithm as the database extractor to produce the values needed for ESPHome secrets.yaml. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Fix typo in folder name and update all references in README files. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Thanks for sharing this code, I was concerned about not having local control of the lock and now I have it. As I didn't have an Android I had to use another method to get the keys - with the help of Claude (and your code) I created a script to run against the API and thought I'd share it.
NOTE: this is an update to the previous PR with "grad" renamed to "grab".
Summary
grab-locks-from-api/directory with a Python script to extract lock secrets (MAC address, AES key, admin_ps, unlock_key) from the TTLock management API.envfile to avoid accidental secret commitsDetails
The script authenticates via OAuth to the TTLock API and retrieves all lock keys associated with the account. It decodes the
aesKeyStr,adminPwd, andlockKeyfields using the same TABLE-based XOR algorithm asgrab-locks-from-app/db2locks.py, producing values ready for use in ESPHomesecrets.yaml.Output
🤖 Generated with Claude Code