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

iOS return value hooking not setting correct values #193

Closed
aph3rson opened this issue Feb 25, 2019 · 6 comments
Closed

iOS return value hooking not setting correct values #193

aph3rson opened this issue Feb 25, 2019 · 6 comments
Labels

Comments

@aph3rson
Copy link
Contributor

Getting odd behavior when trying to run the latest version of Objection and frida-gadget. I patch a method to always return False/0, and the set-method-return job shows it as being overridden to 0x0. However, a watch-method job shows it as returning 0x1 (and my app crashes).

This was not an issue with the last version of objection, so I suspect it has to do with the move to the typescript agent.

The below output shows my issue pretty well. If it makes any difference, I'm running on Windows, and am connecting to frida-server over a network connection.

PS C:\Users\iwilliams> objection --network --host [snip] --gadget '[snip]' explore --startup-command "ios hooking set return_value '-[AppceleratorHttpsModule createX509Certificate
PinningSecurityManager:]' 0"
Using networked device @`[snip]:27042`
Agent injected and responds ok!
Running a startup command... ios hooking set return_value '-[AppceleratorHttpsModule createX509CertificatePinningSecurityManager:]' 0
(agent) Selector address enumeration complete.
(agent) Found selector at 0x104d43c54 as -[AppceleratorHttpsModule createX509CertificatePinningSecurityManager:]
(agent) Registering job 2yssrjepb0j. Type: set-method-return for: -[AppceleratorHttpsModule createX509CertificatePinningSecurityManager:]
[snip]
[snip] on (iPad: 11.4) [net] # ios hooking watch method "-[AppceleratorHttpsModule createX509CertificatePinningSecurityManager:]" --dump-args --dump-backtrace --d
ump-return
(agent) Selector address enumeration complete.
(agent) Found selector at 0x104d43c54 as -[AppceleratorHttpsModule createX509CertificatePinningSecurityManager:]
(agent) Registering job xwne5q5gdic. Type: watch-method for: -[AppceleratorHttpsModule createX509CertificatePinningSecurityManager:]
[snip] on (iPad: 11.4) [net] # (agent) [xwne5q5gdic] Called: -[AppceleratorHttpsModule createX509CertificatePinningSecurityManager:] 1 arguments(Kind: instance) (Super: TiModule)
(agent) [xwne5q5gdic] -[AppceleratorHttpsModule createX509CertificatePinningSecurityManager:] Backtrace:
        [snip]
(agent) [xwne5q5gdic] Argument dump: [AppceleratorHttpsModule createX509CertificatePinningSecurityManager: (
        [snip]
)]
(agent) [2yssrjepb0j] -[AppceleratorHttpsModule createX509CertificatePinningSecurityManager:] Return value was: 0x15dda64e0, overriding to 0x0
(agent) [xwne5q5gdic] Return Value: 0x1
(session detach message) process-terminated
@aph3rson
Copy link
Contributor Author

Relatedly, I was doing the known-working methods I described in #187.

@aph3rson
Copy link
Contributor Author

I think the issue is here, on line 244:

case false:
if (retval.equals(FALSE)) {
return;
}
send(
c.blackBright(`[${job.identifier}] `) +
`${c.green(selector)} ` +
`Return value was: ${c.red(retval.toString())}, overriding to ${c.green(FALSE.toString())}`,
);
retval.replace(TRUE);
break;
}

@leonjza
Copy link
Member

leonjza commented Feb 25, 2019

Interesting. I am going to have to debug this one a little more. May be a race condition in how the InvocationListener's fire. Apart from the watch hook reporting 0x1, does the bypass work though?

@aph3rson
Copy link
Contributor Author

does the bypass work though?

No, the app gets 0x1 as the return value, and crashes. I'm going to try updating the compiled JS, and see if that fixes it.

@aph3rson
Copy link
Contributor Author

Can confirm, changing the compiled JS fixes the issue. I can submit a PR to fix the typescript file, if you'd like.

@leonjza
Copy link
Member

leonjza commented Feb 25, 2019

Awesome, a PR would rock :)

leonjza pushed a commit that referenced this issue Feb 25, 2019
Replace TRUE with FALSE in FALSE return code.
Works on #193.
leonjza pushed a commit that referenced this issue Mar 1, 2019
* Fix iOS hooking return value

Replace TRUE with FALSE in FALSE return code.
Works on #193.

* Fix PList relative path join

Replace usage of `os.path.join`, doesn't work as expected on Windows.

Works on #197.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants