【发布时间】:2018-11-16 09:00:55
【问题描述】:
我注意到 Kotlin 委托属性名称在混淆的字节码中仍然可见。
示例源代码:
class MainActivity : AppCompatActivity() {
val testProperty by lazy { "this is testProperty value" }
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
testMethod()
Log.d("MainActivity", "testProperty: $testProperty")
}
fun testMethod() {
Log.d("MainActivity", "this is testMethod")
}
}
我正在构建启用了缩小的 apk,然后使用 Android Studio 中的 APK Analyzing 功能来浏览字节码:
.method private final l()V
.registers 3
const-string v0, "MainActivity"
const-string v1, "this is testMethod"
invoke-static {v0, v1}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I
return-void
.end method
...
invoke-static {v2}, La/a/b/k;->a(Ljava/lang/Class;)La/b/b;
move-result-object v2
const-string v3, "testProperty"
const-string v4, "getTestProperty()Ljava/lang/String;"
invoke-direct {v1, v2, v3, v4}, La/a/b/j;-><init>(La/b/c;Ljava/lang/String;Ljava/lang/String;)V
invoke-static {v1}, La/a/b/k;->a(La/a/b/i;)La/b/e;
在上面的片段中,您可以看到 testMethod 混淆得很好,但 testProperty 仍然可见。
如何从字节码中删除此信息以改善混淆并使其更难进行逆向工程?
【问题讨论】: