Commit Graph
70 Commits
Author SHA1 Message Date
JingMatrixandGitHub 093c1bbc13 Implement multi-keybox support (#1)
This commit adds support for using different `keybox.xml` files for different applications. This allows for greater flexibility, enabling the use of distinct cryptographic identities for specific groups of apps.

The `target.txt` configuration now supports a new syntax. A line with a filename in brackets, like `[demo_keybox.xml]`, sets the active keybox for all subsequent packages in the file.

The implementation refactors the configuration and keybox loading logic:

- PkgConfig now parses the new syntax and maps packages to their designated keybox files.

- KeyBoxUtils is updated to dynamically load and cache multiple keybox files on demand, instead of relying on a single global state.

- Certificate generation and hacking functions now use this new configuration to select the correct keybox for each operation based on the application's UID.
2025-11-02 11:07:50 +01:00
JingMatrix ad81149700 Improve development experience
1. Add installation tasks
2. Export CMake symbols for clangd
2025-11-02 10:54:28 +01:00
JingMatrix 67d35caf3c Rename project to TEESimulator
Explain in README our new goal of bypass TrickyStore detection
2025-11-02 10:52:09 +01:00
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
258258a846 build(deps): bump agp from 8.12.2 to 8.13.0 (#32)
Bumps `agp` from 8.12.2 to 8.13.0.

Updates `com.android.application` from 8.12.2 to 8.13.0

Updates `com.android.library` from 8.12.2 to 8.13.0

---
updated-dependencies:
- dependency-name: com.android.application
  dependency-version: 8.13.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
- dependency-name: com.android.library
  dependency-version: 8.13.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-09-04 13:34:00 +05:30
Dakkshesh ff980f59fc interceptors: keystore2: Handle missing keys error properly
Signed-off-by: Dakkshesh <beakthoven@gmail.com>
2025-09-04 12:35:17 +05:30
Dakkshesh 7d371dd766 Revert "java: Implement keystore clearing for target packages during initialization"
This reverts commit c285992226.

Signed-off-by: Dakkshesh <beakthoven@gmail.com>
2025-09-03 10:39:05 +05:30
Dakkshesh 77323fad91 Revert "java: config: Limit clear keystore workaround for few affected apps"
This reverts commit 2185237267.

Signed-off-by: Dakkshesh <beakthoven@gmail.com>
2025-09-03 10:37:53 +05:30
Dakkshesh 2185237267 java: config: Limit clear keystore workaround for few affected apps
- To avoid side affects caused to unwanted apps that are added to target.txt

Signed-off-by: Dakkshesh <beakthoven@gmail.com>
2025-09-03 10:03:32 +05:30
Dakkshesh 9701bd3978 java: config: Refactor waitAndGetSystemService()
- Make use of waitForService() for >= Android 11.
- Reserve manual polling for Android 10 due to lack of waitForService().
- Rework on logs to be less cluttering.

Signed-off-by: Dakkshesh <beakthoven@gmail.com>
2025-09-01 15:02:48 +05:30
Furkan KarcıoğluandGitHub 2fad7ff251 java: make getPM() wait for package manager service initialisation (#30) 2025-09-01 00:25:45 +05:30
Dakkshesh c285992226 java: Implement keystore clearing for target packages during initialization
- Currently using keystore2 API.
- TODO: Add support for keystore1.

Signed-off-by: Dakkshesh <beakthoven@gmail.com>
2025-08-31 20:48:52 +05:30
Dakkshesh 1e53ffeea0 java: config: guard linkToDeath() in getPm() against null binder to prevent NPE
fixes: https://github.com/beakthoven/TrickyStoreOSS/commit/23774e64a94c5cab08daa3ba2cec7a98db850cbd

logs:
08-30 15:46:05.226  1811  1811 E TrickyStoreOSS: fatal: failed to get packages
08-30 15:46:05.226  1811  1811 E TrickyStoreOSS: java.lang.NullPointerException: Attempt to invoke interface method 'void android.os.IBinder.linkToDeath(android.os.IBinder$DeathRecipient, int)' on a null object reference
08-30 15:46:05.226  1811  1811 E TrickyStoreOSS:        at qe.a(Unknown Source:13)
08-30 15:46:05.226  1811  1811 E TrickyStoreOSS:        at qe.c(Unknown Source:1)
08-30 15:46:05.226  1811  1811 E TrickyStoreOSS:        at io.github.beakthoven.TrickyStoreOSS.interceptors.SecurityLevelInterceptor.onPreTransact(Unknown Source:107)
08-30 15:46:05.226  1811  1811 E TrickyStoreOSS:        at io.github.beakthoven.TrickyStoreOSS.interceptors.BinderInterceptor.handlePreTransact(Unknown Source:50)
08-30 15:46:05.226  1811  1811 E TrickyStoreOSS:        at io.github.beakthoven.TrickyStoreOSS.interceptors.BinderInterceptor.onTransact(Unknown Source:21)
08-30 15:46:05.226  1811  1811 E TrickyStoreOSS:        at android.os.Binder.execTransactInternal(Binder.java:1392)
08-30 15:46:05.226  1811  1811 E TrickyStoreOSS:        at android.os.Binder.execTransact(Binder.java:1299)
08-30 15:46:05.226  1811  1811 E TrickyStoreOSS:        at android.os.BinderProxy.transactNative(Native Method)
08-30 15:46:05.226  1811  1811 E TrickyStoreOSS:        at android.os.BinderProxy.transact(BinderProxy.java:685)
08-30 15:46:05.226  1811  1811 E TrickyStoreOSS:        at android.system.keystore2.IKeystoreSecurityLevel$Stub$Proxy.generateKey(IKeystoreSecurityLevel.java:307)
08-30 15:46:05.226  1811  1811 E TrickyStoreOSS:        at android.security.KeyStoreSecurityLevel.lambda$generateKey$0(KeyStoreSecurityLevel.java:145)
08-30 15:46:05.226  1811  1811 E TrickyStoreOSS:        at android.security.KeyStoreSecurityLevel.$r8$lambda$XUH2FEW76sslYQDkYWi9Fg4yVEI(Unknown Source:0)
08-30 15:46:05.226  1811  1811 E TrickyStoreOSS:        at android.security.KeyStoreSecurityLevel$$ExternalSyntheticLambda1.execute(Unknown Source:12)
08-30 15:46:05.226  1811  1811 E TrickyStoreOSS:        at android.security.KeyStoreSecurityLevel.handleExceptions(KeyStoreSecurityLevel.java:55)
08-30 15:46:05.226  1811  1811 E TrickyStoreOSS:        at android.security.KeyStoreSecurityLevel.generateKey(KeyStoreSecurityLevel.java:145)
08-30 15:46:05.226  1811  1811 E TrickyStoreOSS:        at android.security.keystore2.AndroidKeyStoreKeyPairGeneratorSpi.generateKeyPair(AndroidKeyStoreKeyPairGeneratorSpi.java:651)
08-30 15:46:05.226  1811  1811 E TrickyStoreOSS:        at java.security.KeyPairGenerator$Delegate.generateKeyPair(KeyPairGenerator.java:750)
08-30 15:46:05.226  1811  1811 E TrickyStoreOSS:        at W.a(Unknown Source:497)
08-30 15:46:05.226  1811  1811 E TrickyStoreOSS:        at vi.a(Unknown Source:20)
08-30 15:46:05.226  1811  1811 E TrickyStoreOSS:        at io.github.beakthoven.TrickyStoreOSS.MainKt.a(Unknown Source:175)
08-30 15:46:05.226  1811  1811 E TrickyStoreOSS:        at io.github.beakthoven.TrickyStoreOSS.MainKt.main(Unknown Source:15)
08-30 15:46:05.226  1811  1811 E TrickyStoreOSS:        at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
08-30 15:46:05.226  1811  1811 E TrickyStoreOSS:        at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:379)

Signed-off-by: Dakkshesh <beakthoven@gmail.com>
2025-08-30 19:12:14 +05:30
Dakkshesh 808c3a5ff9 app: java: Restructure and tidy up the code
Signed-off-by: Dakkshesh <beakthoven@gmail.com>
2025-08-30 16:02:34 +05:30
JingMatrixandGitHub 23774e64a9 app: config: Use linkToDeath for PackageManager resilience (#29)
The previous implementation used `pingBinder()` to check the liveness of the PackageManager service on every call to `getPm()`. This polling approach introduces an unnecessary IPC round-trip overhead for every access.

This commit refactors the logic to use the canonical, event-driven pattern for handling remote service death by implementing `linkToDeath`.

A `DeathRecipient` is now registered with the binder upon the first connection. If the service process (`system_server`) dies for any reason, the `binderDied()` callback is automatically invoked by the system. This callback proactively clears the cached service instance, ensuring that the next call to `getPm()` will transparently re-establish a valid connection.
2025-08-29 21:56:33 +05:30
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
a064c137c3 build(deps): bump agp from 8.12.1 to 8.12.2 (#28)
Bumps `agp` from 8.12.1 to 8.12.2.

Updates `com.android.application` from 8.12.1 to 8.12.2

Updates `com.android.library` from 8.12.1 to 8.12.2

---
updated-dependencies:
- dependency-name: com.android.application
  dependency-version: 8.12.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
- dependency-name: com.android.library
  dependency-version: 8.12.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-08-29 17:21:22 +05:30
rhunkandGitHub bcb4531904 app: Fix DeadObjectException in IPackageManager access (#27) 2025-08-28 19:30:08 +05:30
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
a758694ceb build(deps): bump agp from 8.12.0 to 8.12.1 (#23)
Bumps `agp` from 8.12.0 to 8.12.1.

Updates `com.android.application` from 8.12.0 to 8.12.1

Updates `com.android.library` from 8.12.0 to 8.12.1

---
updated-dependencies:
- dependency-name: com.android.application
  dependency-version: 8.12.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
- dependency-name: com.android.library
  dependency-version: 8.12.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-08-22 09:17:51 +05:30
Dakkshesh d762663192 java: Overhaul detection of attestation properties
- Reuse and extend the attestation we perform for detection of functional TEE.
- Extract properties like boot hash, os version, attest version, keymaster version from the generated certificate.
- Use previous methods as fallback for devices without functional TEE.
- Set ro.boot.vbmeta.digest during initialization with the boot hash value.

Signed-off-by: Dakkshesh <beakthoven@gmail.com>
2025-08-19 19:33:27 +05:30
Dakkshesh 088e9ff1b0 java: Stop using dev.rikka.hidden.stub
- We dont need the whole dev.rikka.hidden.stub library so just remove it and simplify dependencies.
- We already have our own stub package so we can just include the missing stubs that we want directly in it.

Signed-off-by: Dakkshesh <beakthoven@gmail.com>
2025-08-17 23:15:44 +05:30
Dakkshesh af2707765a workflows: build: Remove redundant setup/configuration
Signed-off-by: Dakkshesh <beakthoven@gmail.com>
2025-08-17 21:29:20 +05:30
Dakkshesh efb704500e .idea: Refresh
Signed-off-by: Dakkshesh <beakthoven@gmail.com>
2025-08-17 21:29:03 +05:30
Nicholas BissellandGitHub 095b32554b java: CertHack: Honour StrongBox security level when requested in generate mode (#20) 2025-08-17 12:29:09 +05:30
MONAandGitHub 7410315701 Add more package names to target.txt (#21)
* Add more root detection and security analysis app package names to target.txt
* Revised commit: kept only apps that check bootloader status
2025-08-17 11:46:20 +05:30
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
8b19dc5376 build(deps): bump org.jetbrains.kotlin.android from 2.2.0 to 2.2.10 (#18)
Bumps [org.jetbrains.kotlin.android](https://github.com/JetBrains/kotlin) from 2.2.0 to 2.2.10.
- [Release notes](https://github.com/JetBrains/kotlin/releases)
- [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md)
- [Commits](https://github.com/JetBrains/kotlin/compare/v2.2.0...v2.2.10)

---
updated-dependencies:
- dependency-name: org.jetbrains.kotlin.android
  dependency-version: 2.2.10
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-08-14 17:37:43 +05:30
Nicholas BissellandGitHub a41c49dcbf Correct package paths for keystore2 API stub (#16) 2025-08-14 13:16:51 +05:30
Dakkshesh 6517fd2569 java: CertHacker: Pass imei2 field correctly
- It was being passed with the wrong tag ID
- Only pass it if attestVersion is >= 300

ref: https://source.android.com/docs/security/features/keystore/attestation#authorizationlist-fields

Signed-off-by: Dakkshesh <beakthoven@gmail.com>
2025-08-13 12:26:25 +05:30
Dakkshesh 10c1a41981 java: CertHacker: Handle attest and keymaster version gracefully
Signed-off-by: Dakkshesh <beakthoven@gmail.com>
2025-08-13 12:06:24 +05:30
DakksheshandGitHub e768569ed6 README: Add vvb2060/KeyAttestation to acknowledgement 2025-08-11 22:05:42 +05:30
DakksheshandGitHub c55df1743b README: Add android requirement 2025-08-11 22:03:56 +05:30
Dakkshesh 5d2ba396e1 Revert "module: Set minimum sdk to 31"
- Injection failures have been fixed on android 10/11.

This reverts commit de71e45bf3.

Signed-off-by: Dakkshesh <beakthoven@gmail.com>
2025-08-11 20:34:08 +05:30
Dakkshesh a33069b481 java: CertHack: Dont append moduleHash for < Android 12
- To avoid "Unknown tag 724" error on older platfoms like Android 10/11
- Conditionally downgrade keymaster versions to 3.0 on these platforms

Signed-off-by: Dakkshesh <beakthoven@gmail.com>
2025-08-11 20:33:37 +05:30
Dakkshesh eaa017be86 cpp: RefBase: Dont use incWeakRequireWeak()
- Fixes the following on older android 10/11 platforms:
08-11 14:53:05.143  1388  1388 I TrickyStoreOSS: TrickyStore injector starting...
08-11 14:53:05.144  1388  1388 I TrickyStoreOSS: Starting injection of /data/adb/modules/tricky_store/libTrickyStoreOSS.so (entry: entry) into process 1024
08-11 14:53:05.151   587   587 I Zygote  : Preloading shared libraries...
08-11 14:53:05.155  1026  1053 I ServiceManager: Waiting for service 'package_native' on '/dev/binder'...
08-11 14:53:05.155  1388  1388 W TrickyStoreOSS: Primary dlopen failed for library: /data/adb/modules/tricky_store/libTrickyStoreOSS.so, dlerror: dlopen failed: cannot locate symbol "_ZN7android7RefBase12weakref_type18incWeakRequireWeakEPKv" referenced by "/data/adb/modules/tricky_store/libTrickyStoreOSS.so"..., trying fallback
08-11 14:53:05.155  1388  1388 I TrickyStoreOSS: Using fallback dlopen method for compatibility
08-11 14:53:05.158  1388  1388 E TrickyStoreOSS: Fallback dlopen failed for library: /data/adb/modules/tricky_store/libTrickyStoreOSS.so, dlerror: dlopen failed: cannot locate symbol "_ZN7android7RefBase12weakref_type18incWeakRequireWeakEPKv" referenced by "/data/adb/modules/tricky_store/libTrickyStoreOSS.so"...
08-11 14:53:05.158  1388  1388 E TrickyStoreOSS: Failed to load library in remote process
08-11 14:53:05.158  1388  1388 E TrickyStoreOSS: Injection failed

- Also improve error handling in injection process

Signed-off-by: Dakkshesh <beakthoven@gmail.com>
2025-08-11 20:33:37 +05:30
Dakkshesh 60bf475d48 app: Bump version to 2.1.0
Signed-off-by: Dakkshesh <dakkshesh5@gmail.com>
2025-08-11 16:21:59 +05:30
Dakkshesh de71e45bf3 module: Set minimum sdk to 31
- There are some issues with Android 10/11 that causes injection failures.
- Raise the compatiblity requirement until they are fixed.

Signed-off-by: Dakkshesh <dakkshesh5@gmail.com>
2025-08-11 16:20:15 +05:30
Dakkshesh f723e53e2b java: CertHacker: Sanitize the XML data before passing to XML parser
- Remove whitespaces
- Remove Byte Order Mark (BOM)

Fixes #12

Signed-off-by: Dakkshesh <beakthoven@gmail.com>
2025-08-10 09:39:32 +05:30
Dakkshesh ef87d5dddf java: CertificateHacker: Handle getPackageInfo() correctly
Fixes #11

Signed-off-by: Dakkshesh <beakthoven@gmail.com>
2025-08-10 00:13:10 +05:30
Dakkshesh b31b023018 workflows: changelogs: Fix zip detection
Signed-off-by: Dakkshesh <dakkshesh5@gmail.com>
2025-08-08 15:41:21 +05:30
Dakkshesh adac71b5bc workflows: changelogs: Update repo URL
Signed-off-by: Dakkshesh <dakkshesh5@gmail.com>
2025-08-08 14:41:29 +05:30
Dakkshesh a17b276875 workflows: Add changelog generator
Signed-off-by: Dakkshesh <dakkshesh5@gmail.com>
2025-08-08 14:39:10 +05:30
Dakkshesh 67f7fa061f java: CertificiateHacker: Refactor and tidy up a bit
- Removed unused boilerplate from initial bring up
- Inlined some functions which were fragmented due to some initial plans that were dropped
- Moved appropriate functions to CertificateUtils
- Tidy up some function and variable names

Signed-off-by: Dakkshesh <beakthoven@gmail.com>
2025-08-07 22:47:12 +05:30
Dakkshesh 64a998000a cpp: Switch to C++23 standard
- Our codebase is written well to support this.
- LSPlt will continue to use c++20 via its cmake logic.

Signed-off-by: Dakkshesh <beakthoven@gmail.com>
2025-08-07 16:49:42 +05:30
Dakkshesh 52e8056b90 cpp: Move LSPlt configuration to gradle script
Otherwise for some reason it fails to set the vars in CI builds.

Signed-off-by: Dakkshesh <beakthoven@gmail.com>
2025-08-07 16:24:42 +05:30
Dakkshesh 6b73ee7d3f workflows: Remove txt from ignore list
My bad, i forgot CMakeLists.txt exists.

Signed-off-by: Dakkshesh <beakthoven@gmail.com>
2025-08-07 16:09:05 +05:30
Dakkshesh f2c0ed7beb cpp: LSPlt: Disable building shared lib
We dont need it. This also fixes some build errors when `DEBUG_SYMBOLS_PATH` is undefined.

Signed-off-by: Dakkshesh <beakthoven@gmail.com>
2025-08-07 16:03:09 +05:30
Dakkshesh 9ed495df6d cpp: use LSPlt's own CMake build logic
Signed-off-by: Dakkshesh <beakthoven@gmail.com>
2025-08-07 15:41:38 +05:30
Dakkshesh 289f10cb47 cpp: Update LSPlt submodule
Signed-off-by: Dakkshesh <beakthoven@gmail.com>
2025-08-07 15:41:07 +05:30
Dakkshesh 54c798b380 cpp: stub: Format using clang-format
Somehow this was missed out during initial formatting.

Signed-off-by: Dakkshesh <beakthoven@gmail.com>
2025-08-07 11:41:27 +05:30
Chris RenshawandGitHub 0f40a2b76b Update target.txt with other common checkers (#9) 2025-08-07 11:37:21 +05:30
Dakkshesh bba2281241 config: remove hardcoded generatePackages entries
- This is a leftover from initial bring up when target.txt parsing wasn't implemented.
- Not needed now because we have auto mode.

Signed-off-by: Dakkshesh <beakthoven@gmail.com>
2025-08-07 11:33:37 +05:30
Dakkshesh 52847b8870 github: Add build workflow
Signed-off-by: Dakkshesh <beakthoven@gmail.com>
2025-08-07 00:05:54 +05:30