Scan networks (SSID's) on iOS 7 by using private API

送分小仙女□ 提交于 2020-01-11 06:00:06

问题


Is it possible to get list of SSID's of networks around by using private API on iOS 7 Jailbroken device?

I know about MobileWiFi.framework that manages WiFi functionality on iOS. (It replaces the obsolete Apple80211 framework.)

Here is 4 years old answer how to use it: Accessing & Using the MobileWiFi.framework

I tried to use these methods on iOS 7, but have no luck.

In one of the comments of author of this solution I receive this answer:

scanNetworks fails because that code is now 4 years old. As I describe in my answer, you have to use a new framework to get the equivalent functionality (and you have had to since at least iOS 5). If you are trying to do this with iOS 7, I would recommend posting a new question.

p.s.

It's not a duplicate of Get SSID's in range iOS 7 . I ask about Jailbreak method of these functionality.


UPD:

There is working code in the link above and in the creker's answer too. But it's needed to pass the sandbox restrictions. So, the right question is: Is there a way to do that with regular iOS app?


回答1:


Here is what I use on iOS5-7

void* library = dlopen("/System/Library/SystemConfiguration/IPConfiguration.bundle/IPConfiguration", RTLD_LAZY);

int (*apple80211Open)(void*) = (int(*)(void*))dlsym(library, "Apple80211Open");
int (*apple80211Bind)(void*, NSString*) = (int(*)(void*, NSString*))dlsym(library, "Apple80211BindToInterface");
int (*apple80211Close)(void*) = (int(*)(void*))dlsym(library, "Apple80211Close");
int (*apple80211Scan)(void*, NSArray**, void*) = (int(*)(void*, NSArray**, void*))dlsym(library, "Apple80211Scan");

void *airport = NULL;
apple80211Open(&airport);
apple80211Bind(airport, @"en0");

NSArray* networks = nil;
apple80211Scan(airport, &networks, [NSDictionary dictionary]);

//"networks" is an array of NSDictionary objects for all the visible Wi-Fi networks

apple80211Close(airport);
dlclose(library); 

IPConfiguration is not a fat binary. It contains only one architecture matching the device. Thus if you're planning on supporting arm64 devices you have to compile your code for arm64 also - 32-bit applications can't load 64-bit dylibs. armv7 and arm64 are enough for all modern devices.

UPDATE

Unfortunatelly this code doesn't work in regular iOS apps even on jailbroken device. Jailbreak doesn't turn off the sandbox which is the reason the code doesn't work. For this code to work you need to place your application outside /var/mobile/Applications directory where sandbox restrictions aren't applied. It could be a daemon, a tweak or a GUI application inside /Applications directory. Applications inside that directory doesn't have any restrictions by default and can access any private API.



来源:https://stackoverflow.com/questions/24324184/scan-networks-ssids-on-ios-7-by-using-private-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!