与Frida的过载功能时,将元素从列表中删除

发布于 2025-01-29 10:59:38 字数 585 浏览 1 评论 0原文

我用Frida和I Overload函数调试Android应用程序,该功能返回java.util.list< someObject>

我想从列表中删除第一个元素,该元素已返回该函数。

我该怎么做?

Java.perform(function x() {
    
    var my_class = Java.use("a.b");
    my_class.c.overload().implementation = function () { 
        var s= this.c(); // THE FUNCTION RETURN java.util.List<SomeObject>
        //HERE I WANT TO REMOVE THE FIRST ELEMENT IN S
        return s;
        
    };
});

这是c函数:

public List<SomeObject> c() {
        return this.c;
    }

I debug an android application with Frida and I overload function that return java.util.List<SomeObject>

I want to remove the first element from List that the function is return.

How can I do that please?

Java.perform(function x() {
    
    var my_class = Java.use("a.b");
    my_class.c.overload().implementation = function () { 
        var s= this.c(); // THE FUNCTION RETURN java.util.List<SomeObject>
        //HERE I WANT TO REMOVE THE FIRST ELEMENT IN S
        return s;
        
    };
});

Here is c function:

public List<SomeObject> c() {
        return this.c;
    }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

温暖的光 2025-02-05 10:59:38

首先,您必须将变量s施加到java.util.list,然后可以调用它上的方法或将其用作参数,例如创建新列表。

如果列表c()返回是可变的:

let s = this.c(); 
let list = Java.cast(s, Java.use("java.util.List"));
list.remove(0);
return list;

如果返回的列表是不可变的,则可以创建一个新的可变阵列,然后删除,则第一个元素:

let s = this.c(); 
let list = Java.cast(s, Java.use("java.util.List"));
let newList = Java.use("java.util.ArrayList").$new(list);
newList.remove(0);
return newList;

可变列表为EG arraylistlinkedlist。 EG是由list.of(...) arrays.aslist(...)创建的,通过用collections.unmodifiableist()< /code>,或通常通过stream/lambda表达式。

First you have to cast the variable s to java.util.List, then you can call methods on it or use it as argument, e.g. to create a new List.

The following code works if the List c() returns is mutable:

let s = this.c(); 
let list = Java.cast(s, Java.use("java.util.List"));
list.remove(0);
return list;

If the returned List is immutable you need to create a new mutable array and the delete then first element:

let s = this.c(); 
let list = Java.cast(s, Java.use("java.util.List"));
let newList = Java.use("java.util.ArrayList").$new(list);
newList.remove(0);
return newList;

Mutable Lists are e.g. ArrayList, LinkedList. Immutable are e.g. created by List.of(...) Arrays.asList(...), by wraping a list with Collections.unmodifiableList() or usually by stream/lambda expressions.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文