Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get all java class fields/methods in frida? #44

Closed
douniwan5788 opened this issue Oct 13, 2017 · 4 comments

Comments

@douniwan5788
Copy link

commented Oct 13, 2017

After dig into source, I finally found the way to get a field which has the same name of a method.

https://github.com/frida/frida-java/blob/82bc59a8389ae62a94e65841b34bb003e03f6518/lib/class-factory.js#L810-L813

public class Test {
    private static int a = 1;
    
    private static int a()
    {
        return 0;
    }
}
'use strict';

if (Java.available) {
    console.log('Java Process!')

    Java.perform(function () {
        var Test = Java.use("Test");

        console.log( Test._a.value );

    });
} else
    console.log("not Java Process!")

My question is:
Is there a way to get all fields/methods of a java class?

@douniwan5788

This comment has been minimized.

Copy link
Author

commented Oct 13, 2017

find a way

console.log( Object.getOwnPropertyNames(Test.__proto__).join('\n') );
@wb14123

This comment has been minimized.

Copy link

commented Jan 18, 2018

I've spent a lot of time to figure out how to get the fields which have the same name of methods. Can we put this in the document?

@wb14123

This comment has been minimized.

Copy link

commented Jan 18, 2018

BTW, @douniwan5788 are you figuring it out by reading the source code?

@iddoeldor

This comment has been minimized.

Copy link

commented Apr 23, 2019

find a way

console.log( Object.getOwnPropertyNames(Test.__proto__).join('\n') );

Get Java class methods & members

function describeJavaClass(className) {
  var jClass = Java.use(className);
  console.log(JSON.stringify({
    _name: className,
    _methods: Object.getOwnPropertyNames(jClass.__proto__).filter(function(m) {·
      return !m.startsWith('$') // filter out Frida related special properties
        || m == 'class' || m == 'constructor' // optional
    }), 
    _fields: jClass.class.getFields().map(function(f) {
      return f.toString()
    })  
  }, null, 2));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.