Restructure and overhaul entire Kotlin codebase
This commit introduces a complete architectural refactoring of the Kotlin-based interception logic, based on the source of 1. https://github.com/5ec1cff/TrickyStore 2. https://github.com/beakthoven/TrickyStoreOSS The primary purpose of this code is to intercept binder transactions to the Android Keystore and KeyMint services. The overall workflow operates in conjunction with a native library (injected via ptrace). The native library hooks the binder's `transact` function and forwards pre- and post-transaction events to the Kotlin side. This Kotlin code contains all the high-level logic for parsing parameters, patching certificates, and generating simulated keys. The codebase is now organized into a clear, package-based architecture: - attestation: Manages the creation and patching of ASN.1 attestation data structures. - config: Handles loading and observing configuration files from disk. - interception: Contains the core binder interception framework and its specific implementations for legacy Keystore (Android Q/R) and modern KeyMint/Keystore2 (Android S+). - logging: Provides a centralized and consistent logging utility. - pki: Manages Public Key Infrastructure, including certificate generation, parsing of key store XML files, and cryptographic helpers. - util: Contains Android-specific utility functions for device properties. This refactoring focuses on establishing a robust and extensible architecture. The fine-tuning of the interception logic itself, especially for corner cases in key generation and patching, is currently under redesign and will be further refined in subsequent commits.
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
package android.app;
|
||||
|
||||
public class ActivityThread {
|
||||
public static void initializeMainlineModules() {
|
||||
throw new UnsupportedOperationException("STUB!");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package android.content.pm;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
abstract class BaseParceledListSlice<T> {
|
||||
|
||||
public List<T> getList() {
|
||||
throw new UnsupportedOperationException("STUB!");
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,10 @@ public interface IPackageManager {
|
||||
|
||||
PackageInfo getPackageInfo(String packageName, int flags, int userId);
|
||||
|
||||
ParceledListSlice<PackageInfo> getInstalledPackages(int flags, int userId);
|
||||
|
||||
ParceledListSlice<PackageInfo> getInstalledPackages(long flags, int userId);
|
||||
|
||||
class Stub {
|
||||
public static IPackageManager asInterface(IBinder binder) {
|
||||
throw new UnsupportedOperationException("STUB!");
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package android.content.pm;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ParceledListSlice<T> extends BaseParceledListSlice<T> {
|
||||
|
||||
public ParceledListSlice(List<T> list) {
|
||||
throw new UnsupportedOperationException("STUB!");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package android.hardware.security.keymint;
|
||||
|
||||
public @interface Digest {
|
||||
int NONE = 0;
|
||||
int MD5 = 1;
|
||||
int SHA1 = 2;
|
||||
int SHA_2_224 = 3;
|
||||
int SHA_2_256 = 4;
|
||||
int SHA_2_384 = 5;
|
||||
int SHA_2_512 = 6;
|
||||
}
|
||||
@@ -5,6 +5,10 @@ public class ServiceManager {
|
||||
throw new UnsupportedOperationException("STUB!");
|
||||
}
|
||||
|
||||
public static IBinder waitForService(String name) {
|
||||
throw new UnsupportedOperationException("STUB!");
|
||||
}
|
||||
|
||||
public static void addService(String name, IBinder binder) {
|
||||
throw new UnsupportedOperationException("STUB!");
|
||||
}
|
||||
|
||||
@@ -4,4 +4,8 @@ public class SystemProperties {
|
||||
public static String get(String key, String def) {
|
||||
throw new UnsupportedOperationException("STUB!");
|
||||
}
|
||||
|
||||
public static String set(String key, String val) {
|
||||
throw new UnsupportedOperationException("STUB!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package android.security;
|
||||
|
||||
public class Credentials {
|
||||
public static final String APP_SOURCE_CERTIFICATE = "FSV_";
|
||||
public static final String CA_CERTIFICATE = "CACERT_";
|
||||
public static final String CERTIFICATE_USAGE_APP_SOURCE = "appsrc";
|
||||
public static final String CERTIFICATE_USAGE_CA = "ca";
|
||||
public static final String CERTIFICATE_USAGE_USER = "user";
|
||||
public static final String CERTIFICATE_USAGE_WIFI = "wifi";
|
||||
public static final String EXTENSION_CER = ".cer";
|
||||
public static final String EXTENSION_CRT = ".crt";
|
||||
public static final String EXTENSION_P12 = ".p12";
|
||||
public static final String EXTENSION_PFX = ".pfx";
|
||||
public static final String EXTRA_CA_CERTIFICATES_DATA = "ca_certificates_data";
|
||||
public static final String EXTRA_CERTIFICATE_USAGE = "certificate_install_usage";
|
||||
public static final String EXTRA_INSTALL_AS_UID = "install_as_uid";
|
||||
public static final String EXTRA_PRIVATE_KEY = "PKEY";
|
||||
public static final String EXTRA_PUBLIC_KEY = "KEY";
|
||||
public static final String EXTRA_USER_CERTIFICATE_DATA = "user_certificate_data";
|
||||
public static final String EXTRA_USER_KEY_ALIAS = "user_key_pair_name";
|
||||
public static final String EXTRA_USER_PRIVATE_KEY_DATA = "user_private_key_data";
|
||||
public static final String INSTALL_ACTION = "android.credentials.INSTALL";
|
||||
public static final String INSTALL_AS_USER_ACTION = "android.credentials.INSTALL_AS_USER";
|
||||
public static final String LOCKDOWN_VPN = "LOCKDOWN_VPN";
|
||||
private static final String LOGTAG = "Credentials";
|
||||
public static final String PLATFORM_VPN = "PLATFORM_VPN_";
|
||||
public static final String USER_CERTIFICATE = "USRCERT_";
|
||||
public static final String USER_PRIVATE_KEY = "USRPKEY_";
|
||||
public static final String USER_SECRET_KEY = "USRSKEY_";
|
||||
public static final String VPN = "VPN_";
|
||||
public static final String WIFI = "WIFI_";
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package android.security;
|
||||
|
||||
public class KeyStore {
|
||||
public static final int CANNOT_ATTEST_IDS = -66;
|
||||
public static final int CONFIRMATIONUI_ABORTED = 2;
|
||||
public static final int CONFIRMATIONUI_CANCELED = 1;
|
||||
public static final int CONFIRMATIONUI_IGNORED = 4;
|
||||
public static final int CONFIRMATIONUI_OK = 0;
|
||||
public static final int CONFIRMATIONUI_OPERATION_PENDING = 3;
|
||||
public static final int CONFIRMATIONUI_SYSTEM_ERROR = 5;
|
||||
public static final int CONFIRMATIONUI_UIERROR = 65536;
|
||||
public static final int CONFIRMATIONUI_UIERROR_MALFORMED_UTF8_ENCODING = 65539;
|
||||
public static final int CONFIRMATIONUI_UIERROR_MESSAGE_TOO_LONG = 65538;
|
||||
public static final int CONFIRMATIONUI_UIERROR_MISSING_GLYPH = 65537;
|
||||
public static final int CONFIRMATIONUI_UNEXPECTED = 7;
|
||||
public static final int CONFIRMATIONUI_UNIMPLEMENTED = 6;
|
||||
public static final int FLAG_CRITICAL_TO_DEVICE_ENCRYPTION = 8;
|
||||
public static final int FLAG_ENCRYPTED = 1;
|
||||
public static final int FLAG_NONE = 0;
|
||||
public static final int FLAG_SOFTWARE = 2;
|
||||
public static final int FLAG_STRONGBOX = 16;
|
||||
public static final int HARDWARE_TYPE_UNAVAILABLE = -68;
|
||||
public static final int KEY_ALREADY_EXISTS = 16;
|
||||
public static final int KEY_NOT_FOUND = 7;
|
||||
public static final int KEY_PERMANENTLY_INVALIDATED = 17;
|
||||
public static final int LOCKED = 2;
|
||||
public static final int NO_ERROR = 1;
|
||||
public static final int OP_AUTH_NEEDED = 15;
|
||||
public static final int PERMISSION_DENIED = 6;
|
||||
public static final int PROTOCOL_ERROR = 5;
|
||||
public static final int SYSTEM_ERROR = 4;
|
||||
private static final String TAG = "KeyStore";
|
||||
public static final int UID_SELF = -1;
|
||||
public static final int UNDEFINED_ACTION = 9;
|
||||
public static final int UNINITIALIZED = 3;
|
||||
public static final int VALUE_CORRUPTED = 8;
|
||||
public static final int WRONG_PASSWORD = 10;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
package android.security.keystore;
|
||||
|
||||
public class AndroidKeyStoreProvider {
|
||||
public static void install() {
|
||||
throw new UnsupportedOperationException("STUB!");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package android.security.keystore;
|
||||
|
||||
public interface IKeystoreService {
|
||||
class Stub {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
package android.security.keystore2;
|
||||
|
||||
public class AndroidKeyStoreProvider {
|
||||
public static void install() {
|
||||
throw new UnsupportedOperationException("STUB!");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user