executing-plans
executing-plans
Use when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available
re-android-cryptoAndroid 加密体系审计(crypto audit):AndroidKeyStore 密钥体系分析(别名/算法/用途/硬件背书)、 Cipher/KeyInfo 审计、加密调用点 hook(Frida 拦截密钥别名与用途)。 触发词:Keystore、AndroidKeyStore、Cipher、KeyInfo、StrongBox、加密审计、crypto hook、密钥别名。
Independent GitHub snapshot · Automated classification · Original documentation governs
| 用户目的 | 路径 |
|---|---|
| 密钥来自 AndroidKeyStore / 硬件背书密钥 | → Keystore 审计(步骤 1) |
| 定位加密调用点 / 拦截密文与明文 | → crypto hook(步骤 2) |
| 分析第三方加密库(BoringSSL / OpenSSL / Tink / libsodium 等) | → 库分析(步骤 3) |
getEncoded() 不可用的硬件背书密钥(须走审计而非提取密钥字节)所有工具先验证再使用。动态 hook 默认沙箱([[re-analyze/platform-tips]] 最高原则);静态审计可免沙箱。
frida --versionadb shell 取应用运行态(KeyStore 枚举需应用进程内执行)Keystore 审计(AndroidKeyStore 密钥体系):
// 应用进程内枚举(frida 注入或 jadx 反编译定位调用点)
KeyStore ks = KeyStore.getInstance("AndroidKeyStore");
ks.load(null);
java.util.Enumeration<String> aliases = ks.aliases();
aliases() 枚举全部条目(密钥别名 = 应用内引用键)KeyInfo.getSecurityLevel()(API 31+,返回 SOFTWARE / TRUSTED_ENVIRONMENT(TEE) / STRONGBOX 三档);API 23–30 只有 isInsideSecureHardware()(布尔,TEE 与 StrongBox 同为 true,分不开)setUserAuthenticationRequired 的密钥在认证失败时不可用(绕过与检测见 [[re-analyze/anti-dynamic-workflow]])crypto hook(加密调用点拦截):
// frida:拦截加密调用点,记录算法/模式/密钥别名
// 别名来源:Key 对象本身不携带别名(KeyStore 无 getKeyAlias),须在 getKey 处记录
const KeyStore = Java.use('java.security.KeyStore');
KeyStore.getKey.overload('java.lang.String', '[C').implementation = function (alias, password) {
console.log('KeyStore.getKey', alias);
return this.getKey(alias, password);
};
const Cipher = Java.use('javax.crypto.Cipher');
Cipher.init.overload('int', 'java.security.Key', 'java.security.spec.AlgorithmParameterSpec').implementation =
function (opmode, key, params) {
console.log('Cipher.init', opmode, key.getClass().getName(), params); // 对应别名见上方 getKey 输出
return this.init(opmode, key, params);
};
// 另路取回别名:SecretKeyFactory.getInstance(key.getAlgorithm(), 'AndroidKeyStore')
// .getKeySpec(key, KeyInfo.class) → KeyInfo.getKeystoreAlias()
Cipher.init 系列(算法/模式/IV 来源)、KeyStore.getKey / getEntry(别名与用途)、Signature/Mac 初始化(验签/校验链)AndroidKeyStore / KeyStore.getInstance / Cipher.getInstance 调用点,与 hook 结果互证第三方加密库分析(BoringSSL / OpenSSL / Tink / libsodium 等):
SSL_*/EVP_*/crypto_*/sodium_* 前缀)+ jadx 依赖声明产出与存证:密钥体系图(别名/算法/用途/背书来源)+ 加密调用点清单 + hook 脚本,sha256 存档供 [[re-ioc]] 引用
getEncoded() 拿不到密钥字节,误判「密钥不存在」;原因——AndroidKeyStore 硬件背书密钥不可导出,这是设计而非缺失;对策——改走审计(步骤 1:别名/算法/用途/背书),不追求密钥字节isInsideSecureHardware 为 true 就断言 StrongBox;原因——Secure Hardware 含 TEE 与 StrongBox 两级,该接口是布尔、分不开(isStrongBoxBacked 在 KeyGenParameterSpec 上,只管生成侧,KeyInfo 没有);对策——API 31+ 用 KeyInfo.getSecurityLevel() 取 SOFTWARE / TEE / STRONGBOX 三档;API 23–30 无法细分,结论按「secure hardware(TEE 或 StrongBox)」标注层级