【问题标题】:Frida Casting object to List of StringsFrida 将对象转换为字符串列表
【发布时间】:2021-03-10 18:50:36
【问题描述】:

在使用 Frida 连接 Android 应用程序时,我一直在尝试打印列表的内容,但没有任何运气。

我想在Java中挂钩的对象是这样的

import com.fasterxml.jackson.annotation.JsonIgnore;
import java.util.List;

public final class Hello extends HelloParent{

    @JsonIgnore
    public final List sampleList;

}

这个公共对象没有任何getter,所以我不得不求助于使用另一个对象(我们称对象“Bye”)的方法(byeMethodB)来监控这个值。

这就是我的 frida 脚本的样子:

setTimeout(function() {

    Java.perform(function(){
        
        Java.use("Bye").byeMethodA.implementation = function(){

            try{
                //Returns a Hello object
                var helloObject = Java.cast(this.byeMethodB(),Java.use("Hello"))
                printListContent(Java.cast(helloObject.sampleList,Java.use("java.util.List"))))
            }catch(err){
                console.log(err)
            }
        }

    })
},1000)

function printListContent(list){

    var listIter = list.iterator()
    while(listIter.hasNext()){
        console.log(listIter.next())
    }

}

如果不将“helloObject.sampleList”对象转换为列表,输出如下所示:

[object Object]

所以我确定它不为空

如果我使用Java.cast(helloObject.sampleList,Java.use("java.util.List")) 投射,

我收到以下错误:

我也试过了:

Java.cast(helloObject.sampleList,Java.use("java.util.List<>"))

(我很确定它是一个字符串) Java.cast(helloObject.sampleList,Java.use("java.util.List<String>"))

Java.cast(helloObject.sampleList,Java.use("java.util.List<java.lang.String>"))

Java.cast(helloObject.sampleList,Java.use("[String"))

Java.cast(helloObject.sampleList,Java.use("[Ljava.lang.String"))

一切都不顺利。希望得到一些帮助

【问题讨论】:

  • 请不要将控制台输出作为屏幕截图发布。它是简单的文本,只需将相关部分复制并粘贴到您的问题中即可。

标签: javascript java android frida


【解决方案1】:

在 Frida 中访问字段与在 Java 中不同。如果您在 Frida 中执行 helloObject.sampleList,您将获得描述字段的 JavaScript 对象,而不是字段值本身。

如果你想要字段值,你必须执行helloObject.sampleList.value

因此下面的代码应该可以工作:

Java.cast(helloObject.sampleList.value, Java.use("java.util.List")),

泛型只存在于编译时,但 frida 是在运行时工作的。因此java.util.List<> 和其他带尖括号的类名将永远无法使用。

【讨论】:

  • 现在可以使用了!感谢指导。
猜你喜欢
  • 2015-02-25
  • 2010-10-03
  • 1970-01-01
  • 1970-01-01
  • 2019-01-17
  • 2017-11-10
  • 2016-06-24
  • 1970-01-01
相关资源
最近更新 更多