1

I am trying to create an instance of a class of an iOS app using Frida.

In the past I have successfully done this using a command such as:

var instance = ObjC.chooseSync(ObjC.classes.TestClass)[0];

However, in this instance, the class that I would like to create an instance of has a . in the name so if I try the same command as above I understandably get an error:

var instance = ObjC.chooseSync(ObjC.classes.Test.Class)[0];
SyntaxError: expecting field name

I had identified the class from the output of:

Object.keys(ObjC.classes).filter(function(m){ return m.toLowerCase().includes("test") });

The output of this lists a number of classes, all of which are either mangled Swift names, or have a . in them so I'm not sure if I simply don't understood a concept here about how Frida handles class names in a Swift and Objective-C app, or there is something I've missed in attempting to create the instance.

1 Answer 1

2

ObjC.classes.TestClass is just a shorthand in JavaScript for ObjC.classes['TestClass'].

Therefore you should be able to access an Test.Class instance this way:

var instance = ObjC.chooseSync(ObjC.classes['Test.Class'])[0];
1
  • Thank you, that was exactly what I needed. I had been overthinking things and annoyingly had tried something similar to your solution but with additional () enclosing the [].
    – Jon
    Commented Feb 4, 2022 at 11:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.