Frida 将对象转换为字符串列表
Frida Casting object to List of Strings
在将 android 应用程序与 Frida 挂钩时,我一直在尝试打印列表的内容,但我没有任何运气。
我要挂钩的对象Java看起来像这样
import com.fasterxml.jackson.annotation.JsonIgnore;
import java.util.List;
public final class Hello extends HelloParent{
@JsonIgnore
public final List sampleList;
}
这个 public 对象没有任何 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"))
一点都不顺利。希望得到一些帮助
在 Frida 中访问字段与在 Java 中不同。如果您在 Frida 中执行 helloObject.sampleList
,您将获得描述字段的 JavaScript 对象,而不是字段值本身。
如果你想要字段值你必须执行helloObject.sampleList.value
.
因此下面的代码应该可以工作:
Java.cast(helloObject.sampleList.value, Java.use("java.util.List"));
泛型仅在编译时存在,但 frida 在 运行 时工作。因此 java.util.List<>
和其他带尖括号的 class 名称将永远不会起作用。
在将 android 应用程序与 Frida 挂钩时,我一直在尝试打印列表的内容,但我没有任何运气。
我要挂钩的对象Java看起来像这样
import com.fasterxml.jackson.annotation.JsonIgnore;
import java.util.List;
public final class Hello extends HelloParent{
@JsonIgnore
public final List sampleList;
}
这个 public 对象没有任何 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"))
一点都不顺利。希望得到一些帮助
在 Frida 中访问字段与在 Java 中不同。如果您在 Frida 中执行 helloObject.sampleList
,您将获得描述字段的 JavaScript 对象,而不是字段值本身。
如果你想要字段值你必须执行helloObject.sampleList.value
.
因此下面的代码应该可以工作:
Java.cast(helloObject.sampleList.value, Java.use("java.util.List"));
泛型仅在编译时存在,但 frida 在 运行 时工作。因此 java.util.List<>
和其他带尖括号的 class 名称将永远不会起作用。