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

Build issues #16

Closed
mgcrea opened this issue Oct 4, 2018 · 10 comments
Closed

Build issues #16

mgcrea opened this issue Oct 4, 2018 · 10 comments

Comments

@mgcrea
Copy link

mgcrea commented Oct 4, 2018

So I'm pretty much very junior to swift related development (did some Obj-C back in the days but a bit rusty too).

I haven't found a way to properly build the example project:

  • The NetworkInterceptor.framework in Xcode appear to be missing
  • What I try to do is to build the framework independently (works) and show build in finder then drag-drop built file into the exemple project (deleting the previous missing ref).

However it won't build anyway as it could not find the module:

~/Developer/foobar/ios-inject/NetworkInterceptor/NetworkInterceptorExample/NetworkInterceptorExample/ViewController.swift:10:8: No such module 'NetworkInterceptor'

Have a working static injection project (following your tutorial), but as well, I'm stuck properly loading the CodeInjectionSwift.swift code, not sure if because it's Swift or if there is as well an issue while loading the built framework (same drag&drop from build).

Would love any insight you could have on this,

Thanks for the great work! I'm looking to reverse-engineer an home automation app and your code looks like to be my last resort! (SSL certificate pinning).


EDIT

Tweaking the framework search path it looks like it loads it now but I'm encountering header issues:

screenshot 2018-10-04 at 16 23 43

@mgcrea mgcrea changed the title No such module 'NetworkInterceptor' Build issues Oct 4, 2018
@depoon
Copy link
Owner

depoon commented Oct 7, 2018

  1. Please Open NetworkInterceptor.xcworkspace instead
  2. Build ** NetworkInterceptor** target
  3. Run Example project

How do you wish to reverse engineer that app? I might have an easier solution

@mgcrea
Copy link
Author

mgcrea commented Oct 7, 2018

Thanks for the answer! Indeed opening the workspace seems to have fixed the build issues, back to work!

The app I'm trying to reverse is a free home automation app, available both on iOS and Android. They are quite famous in my country, but their system is totally closed unfortunately.

I was able to debug the initial login handshake that uses some kind of Digest access authentication but to initiate a WebSocket connection. That part is working fine and I'm properly receiving WebSocket (incoming) messages from the server (that looks like to be raw HTTP requests).

The big issue is that I don't have a clue what is the proper (outgoing) messages API to trigger stuff (tried a few variations of the received message with no luck).

I've spent a lot of time trying to debug these network frames using Charles for iOS, then a combination of mitm-proxy and WireShark combined with the use of a Remote Virtual Interface.

Big issue is that it looks like WebSocket frames do not use the proxy, were not properly SSL decrypted by Charles, and when I finally was able to force the SSL override (via the virtual interface) the app did not work anymore (I guess it is due to SSL pining).

So my only hope left was to somehow debug these WebSocket messages before they are sent / encrypted thanks to your work. If you have any other idea (or maybe some other iOS method injection to perform related to WebSocket usage), I'd be more than happy to hear them.

If you are interested, I can send you unencrypted version of both iOS/Android apps!

Thanks again for the help!


EDIT Somehow I can't seem to find the proper way to load your CodeInjectionSwift.swift code inside a Framework (for bundling in an app after), somehow it looks like bridging -Swift.h interfaces are not generated for frameworks (only apps). Do you have any idea on how to fix that or write the equivalent in pure obj-c?

screenshot 2018-10-07 at 23 21 29

@depoon
Copy link
Owner

depoon commented Oct 8, 2018

Drop me an email regarding the unencrypted app pls.
[email protected]

@mgcrea
Copy link
Author

mgcrea commented Oct 8, 2018

@depoon done, thanks!

@depoon
Copy link
Owner

depoon commented Oct 8, 2018

On PatchLoader.m, since you are creating a framework, use this import instead

#import <PatchFramework/PatchFramework-Swift.h>

In CodeInjectionSwift you need to declare your class and func public in order to use them

@mgcrea
Copy link
Author

mgcrea commented Oct 8, 2018

Thanks, it did indeed fixed build issues.

Unfortunately it looks like I've hit another deadend, I can't import the required Swift dylibs as they crash (due to missing symbols), eg:

Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note:  EXC_CORPSE_NOTIFY
Termination Description: DYLD, Symbol not found: _$SSJN | Referenced from: /var/containers/Bundle/Application/7739779D-14CF-4DFD-AF21-4BF6B6E9617C/Tydom.app/Dylibs/libswiftSwiftOnoneSupport.dylib | Expected in: /private/var/containers/Bundle/Application/7739779D-14CF-4DFD-AF21-4BF6B6E9617C/Tydom.app/Frameworks/libswiftCore.dylib | in /var/containers/Bundle/Application/7739779D-14CF-4DFD-AF21-4BF6B6E9617C/Tydom.app/Dylibs/libswiftSwiftOnoneSupport.dylib

Probably because either XCode is too recent (and device is in 10.3) or maybe the fact that it is 32-bit.

I've found out this repo with historical runtime headers:

https://github.com/nst/iOS-Runtime-Headers/releases/tag/10.3

But there is no libswiftSwiftOnoneSupport.dylib that is required by the framework.

@oli06
Copy link

oli06 commented Oct 29, 2018

Hi @mgcrea,

Not sure, if I'm on the right way understanding your issue. But I also got into trouble using the required (or not required) Swift dylibs while experimenting with CodeInjection.

First I used all the default Swift dylibs (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift), but soon found out, that the easiest way of using only the required dylibs is to build your framework, open it in finder and copy all dylibs from the /Frameworks directory.

Especially for libswiftSwiftOnoneSupport.dylib, this was only required if I wanted to use a debug version of the framework on my iOS-device. Otherwise this dylib is not required (and shouldn't therefore not be included).

@mgcrea
Copy link
Author

mgcrea commented Dec 15, 2018

Indeed it looks like I was building it in debug mode. Had been able to get a 64-bit device and wanted to try again but I'm not sure if an Xcode update broke something but I get:

dyld: Library not loaded: @rpath/NetworkInterceptor.framework/NetworkInterceptor
  Referenced from: /var/containers/Bundle/Application/96A22878-6F2A-4670-99ED-268CF907F9D2/NetworkInterceptorExample.app/NetworkInterceptorExample
  Reason: image not found

When trying to run the example (clean checkout from this repo). I've opened the workspace and built the NetworkInterceptor target first. Any ideas?


EDIT: Fixed it by adding it to Embedded Binaries:

screenshot 2018-12-15 at 02 18 28


EDIT 2: Unfortunately I hit another cryptic error once sideloaded along the actual app

Termination Description: DYLD, Symbol not found: _$SBOWV | Referenced from: /var/containers/Bundle/Application/75125D53-6E8C-4D4A-A7D8-0E80936408B1/Tydom.app/Dylibs/NetworkInterceptor | Expected in: /private/var/containers/Bundle/Application/75125D53-6E8C-4D4A-A7D8-0E80936408B1/Tydom.app/Frameworks/libswiftCore.dylib | in /var/containers/Bundle/Application/75125D53-6E8C-4D4A-A7D8-0E80936408B1/Tydom.app/Dylibs/NetworkInterceptor

EDIT 3: It looks like the app I'm trying to sideload is built for iOS9 so I tried to set Deployment Target to 9.0 and build in release mode but no more luck.

I'm exactly hitting this error message: razorpay/react-native-razorpay#125

@depoon do you think it would be possible to skip the NetworkInspector framework and do some basic pre-query body dumping directly with Objective-C?

@mgcrea
Copy link
Author

mgcrea commented Dec 18, 2018

Finally made it work today!! had to compile my framework with Xcode 9 (still downloadable on Apple developer) to be on the same SDK than the app.

However I'm receiving truncated body/content in the console,

default	01:07:35.829411 +0100	Tydom	Task <157440F7-FB34-41CC-A208-968EB2C32118>.<0> sent request, body N
default	01:07:35.838641 +0100	Tydom	Task <157440F7-FB34-41CC-A208-968EB2C32118>.<0> received response, status 401 content U

EDIT: nevermind, found the actual logs Request # but I don't have any interesting log there (only third-party metrics). It looks like the app relies on https://github.com/robbiehanson/CocoaAsyncSocket to perform some of its requests and https://github.com/daltoniam/Starscream for WebSockets, and I guess it's not properly caught by this interceptor. Any idea @depoon?

Anyway I guess I can close this!

@mgcrea mgcrea closed this as completed Dec 18, 2018
@depoon
Copy link
Owner

depoon commented Dec 29, 2018

Sorry for not keeping up. I will investigate how to apply the same concept for WebSockets

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

No branches or pull requests

3 participants