-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
System Log came back from the dead #372
Comments
I like this solution! It will be annoying to update fishhook for each new OS each year, but I think I can manage. I will get to this after I finish 4.0. Thanks again for the detailed issue! Also, dyld 3 is already in use and if you check that issue it seems it did not affect fishhook |
Great! Anyway it's not really annoying, because you just need to replace the fishhook.c file when necessary, the code to hook the C function will be always the same. |
It's not that simple; I will probably need to namespace all of the symbols with |
A suggestion: when fishhook support will be implemented, it would be amazing to see more details of NSLog. |
Not a bad idea! This would have to be something you enable manually though because that could take up a lot of memory. |
iOS 10 and its associated SDK deprecated *ASL and replaced it with *os_log. This change is widely considered unfavorable and made it extremely tedious for FLEX to intercept log messages reliably. @Ram4096 has brought to my attention that the os_log functionality is actually just a shim which is conditionally enabled based on what SDK version your binary links with. With a little reverse engineering, I was able to hook the function that tells `NSLog` (well, `CFLogv`) whether os_log should be used or not. This commit uses fishhook to hook `os_log_shim_enabled` to always return `NO` so that the old ASL library is used instead. Prior to this commit we had code in place to conditionally intercept messages from os_log or ASL based on the iOS version. These checks are not semantically correct since ASL would still be used on iOS 10+ if the binary was built with the iOS 9 SDK. For now, this doesn't matter going forward since we are going to always use ASL, but it might be worth updating the check to instead check for the linked SDK version instead of the OS version. - *ASL: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/asl.3.html - *os_log: https://developer.apple.com/documentation/os/logging?language=objc
iOS 10 and its associated SDK deprecated *ASL and replaced it with *os_log. This change is widely considered unfavorable and made it extremely tedious for FLEX to intercept log messages reliably. @Ram4096 has brought to my attention that the os_log functionality is actually just a shim which is conditionally enabled based on what SDK version your binary links with. With a little reverse engineering, I was able to hook the function that tells `NSLog` (well, `CFLogv`) whether os_log should be used or not. This commit uses fishhook to hook `os_log_shim_enabled` to always return `NO` so that the old ASL library is used instead. Prior to this commit we had code in place to conditionally intercept messages from os_log or ASL based on the iOS version. These checks are not semantically correct since ASL would still be used on iOS 10+ if the binary was built with the iOS 9 SDK. For now, this doesn't matter going forward since we are going to always use ASL, but it might be worth updating the check to instead check for the linked SDK version instead of the OS version. - *ASL: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/asl.3.html - *os_log: https://developer.apple.com/documentation/os/logging?language=objc
I've added your fix in the 4.0 branch! Closing this. Thanks again for your help! You are credited in the commit message and in code for telling me it was an SDK feature. I took a different approach — I did some digging and hooked |
iOS 10 and its associated SDK deprecated *ASL and replaced it with *os_log. This change is widely considered unfavorable and made it extremely tedious for FLEX to intercept log messages reliably. @Ram4096 has brought to my attention that the os_log functionality is actually just a shim which is conditionally enabled based on what SDK version your binary links with. With a little reverse engineering, I was able to hook the function that tells `NSLog` (well, `CFLogv`) whether os_log should be used or not. This commit uses fishhook to hook `os_log_shim_enabled` to always return `NO` so that the old ASL library is used instead. Prior to this commit we had code in place to conditionally intercept messages from os_log or ASL based on the iOS version. These checks are not semantically correct since ASL would still be used on iOS 10+ if the binary was built with the iOS 9 SDK. For now, this doesn't matter going forward since we are going to always use ASL, but it might be worth updating the check to instead check for the linked SDK version instead of the OS version. - *ASL: https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/asl.3.html - *os_log: https://developer.apple.com/documentation/os/logging?language=objc
A long time ago some developers complained about an issue for the System Log feature implemented in FLEX. #140
This feature was able to capture all NSLogs. In the referenced issue, we can discover that it was caused by ASL on iOS 10 and newer, replaced by OS Log, so FLEX couldn't capture logs.
Today I have more details about this issue, and a possible solution:
You can test what I said using the following code. For example, I'm using an app compiled using the iOS 13 SDK, but my tweak (so I'm in a jailbroken environment) is compiled using the iOS 9.3 SDK. I restored the old behavior of FLEX (so FLEX will consider ASL again), and I'm able to see the NSLog coded in my tweak.
This is how I've restored the old ASL behavior (but it works only if the tweak/app where NSLog is called is compiled using the iOS 9 SDK, so it's not something related to the system):
Note: this code should be used if you use a tweak compiled using the iOS 9 SDK and you would like to see NSLogs directly in FLEX.
Using the ASL behavior, FLEX is able to capture NSLog on iOS 12, if the tweak is compiled using a SDK where ASL worked.
But, seen that we are looking for a general solution that works on any SDK and on a no-jailbroken environment too, we can opt for fishhook (yes, it works on no-jailbroken iOS versions):
The
rebind_symbols
function should be called once. I'm not sure if it works system-wide (for example in the SpringBoard on jailbroken devices), but it works in apps.Fishhook is amazing, it's maintained from Facebook and updated to support new iOS versions (when it's necessary). The only bad thing is that it might not work when Apple decides to enable Dyld 3.0, but we cannot know until they do that.
At the moment this is the best solution to capture NSLogs using FLEX. Give it a test!
The text was updated successfully, but these errors were encountered: