Is there any private api to monitor network traffi

2019-02-01 14:26发布

I need to implement an app that monitors inbound/outbound connections by different apps on iPhone. my app is going to run in background using apple's background multitasking feature for voip and navigators. I can use private api as my client doesn't need this app on appstore.

Thanks.

3条回答
手持菜刀,她持情操
2楼-- · 2019-02-01 14:57

I got through this.

I didn't need any private Api to get information of inbound/outbound active connections. Its just you need to know basic C programming and some patience.

I wrote to apple dev forums regarding this,and got response as-

From my perspective most of what I have to say about this issue is covered in the post referenced below.

<https://devforums.apple.com/message/748272#748272>>

The way to make progress on this is to:

o grab the relevant headers from the Mac OS X SDK

o look at the Darwin source for netstat to see how the pieces fit together

WARNING: There are serious compatibility risks associated with shipping an app that uses this technique; it's fine to use this for debugging and so on, but I recommend against shipping code like this to end users.

What I did step by step is -

1)downloaded code of netstat from BSD opensource -

2)add this to your new iphone project.

3)see,some header files are not present in ios sdk so you need take it copied from opensource.apple.com and add those in your iphone sdk at relevant path under-

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk/usr/include

My xcode version is 4.5.2. so this is path relevent to my xcode. you can have different path according to versions of xcodes.Anyway. and remember to add those headers in both iosSdk & iOSSimulatorSdk both so that code will work on device as well as on simulator.

4)you may find some minor errors in netstat code relating not finding definitions of some structures in header files.e.g " struct xunpcb64 " .dont wory. definitions are present there.you need to comment some "#if !TARGET_OS_EMBEDDED" #else in those header files so that ios sdk can reach in those if condition and access the definition.(need some try and error.be patient.)

5)finally you will be abe to compile your code.Cheers!!

查看更多
贪生不怕死
3楼-- · 2019-02-01 15:07

In case you haven't seen this already, I have used it successfully on my iPhone.

https://developer.apple.com/library/ios/ipad/#qa/qa1176/_index.html

I realize it is not exactly what you want.

查看更多
叛逆
4楼-- · 2019-02-01 15:15

Generally, I agree with Suneet. All you need is network sniffer.

You can try to do partial port of WireShark (it's open source and it works on MacOS) to iOS. Both iOS and OS X share most part of the kernel, so if it's not explicitly prohibited on iOS, it should work for you.

WireShark is quite big product, so you may be intersted to look for another open source network sniffer which work on OS X.

查看更多
登录 后发表回答