frida / frida-objc-bridge

Objective-C runtime interop from Frida
49 stars 21 forks source link

Support fetching method definitions from inherited protocols #47

Open tux-mind opened 2 years ago

tux-mind commented 2 years ago

When registering a new class that implements a protocol and its inherited methods, frida is not able to find the method signature of the inherited methods.

e.g. implementing - URLSession:task:didReceiveChallenge:completionHandler: having just NSURLSessionDataDelegate in protocols.

https://github.com/frida/frida-objc-bridge/blob/4fe30910c1af32b2220c09b64dc4340f9132fc64/index.js#L1505

something like this might solve the issue:

function findMethodDescriptionInProtocols(protocols: ObjC.Protocol[], methodName: string): ObjC.ProtocolMethodDescription {
    let found = undefined;
    for (const p of Object.values(protocols)) {
        found = p.methods[methodName] ?? findMethodDescriptionInProtocols(Object.values(p.protocols), methodName);
        if (found) { return found; }
    }
}

Thank you for this awesome tool and your precious time.