Last active
November 14, 2025 15:56
-
-
Save ynkdir/ad32fde4f44f4c7c69a159fa48265405 to your computer and use it in GitHub Desktop.
Caliculate Windows Limited Access Feature Token
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
| # Caliculate Windows Limited Access Feature Token | |
| # https://firefox-source-docs.mozilla.org/widget/windows/LimitedAccessFeature.html | |
| # term: | |
| # Limited Access Feature (laf) | |
| # Package Family Name (pfn) | |
| import winreg | |
| from base64 import b64encode | |
| from hashlib import sha256 | |
| def get_laf_token(pfn: str, laf_id: str, laf_key: str) -> str: | |
| data = f"{laf_id}!{laf_key}!{pfn}".encode() | |
| return b64encode(sha256(data).digest()[:16]).decode() | |
| def get_laf_attension(pfn: str, laf_id: str) -> str: | |
| publisher_id = pfn[-13:] | |
| return f"{publisher_id} has registered their use of {laf_id} with Microsoft and agrees to the terms of use." | |
| def get_laf_key(laf_id: str) -> str: | |
| key_path = rf"SOFTWARE\Microsoft\Windows\CurrentVersion\AppModel\LimitedAccessFeatures\{laf_id}" | |
| with winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, key_path) as key: | |
| value, _regtype = winreg.QueryValueEx(key, "") | |
| return value | |
| def main() -> None: | |
| # set your package family name | |
| pfn = "win32more_7qdfwf8gx71z8" | |
| laf_id = "com.microsoft.windows.ai.languagemodel" | |
| laf_key = get_laf_key(laf_id) | |
| laf_attension = get_laf_attension(pfn, laf_id) | |
| laf_token = get_laf_token(pfn, laf_id, laf_key) | |
| print(f"{laf_key=}") | |
| print(f"{laf_attension=}") | |
| print(f"{laf_token=}") | |
| # Windows.ApplicationModel.LimitedAccessFeatures.TryUnlockFeature(laf_id, laf_token, laf_attension) | |
| if __name__ == "__main__": | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment