简体   繁体   English

使用私有API在iOS 7上扫描网络(SSID)

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

Is it possible to get list of SSID's of networks around by using private API on iOS 7 Jailbroken device? 是否可以通过iOS 7 Jailbroken设备上的私有API获取SSID的网络列表?

I know about MobileWiFi.framework that manages WiFi functionality on iOS. 我知道在iOS上管理WiFi功能的MobileWiFi.framework (It replaces the obsolete Apple80211 framework.) (它取代了过时的Apple80211框架。)

Here is 4 years old answer how to use it: Accessing & Using the MobileWiFi.framework 这是4岁回答如何使用它: 访问和使用MobileWiFi.framework

I tried to use these methods on iOS 7, but have no luck. 我尝试在iOS 7上使用这些方法,但没有运气。

In one of the comments of author of this solution I receive this answer: 在此解决方案作者的评论之一中,我收到了以下答案:

scanNetworks fails because that code is now 4 years old. scanNetworks失败,因为该代码现在scanNetworks 4年历史。 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). 正如我在回答中所描述的那样,您必须使用新的框架来获得相同的功能(至少从iOS 5开始)。 If you are trying to do this with iOS 7, I would recommend posting a new question . 如果您尝试使用iOS 7,我建议发布一个新问题

ps PS

It's not a duplicate of Get SSID's in range iOS 7 . 它不是iOS 7范围内获取SSID的 副本 I ask about Jailbreak method of these functionality. 我问一下这些功能的越狱方法。


UPD: UPD:

There is working code in the link above and in the creker's answer too. 上面的链接和creker的答案中都有工作代码。 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? 所以,正确的问题是:有没有办法用常规iOS应用程序做到这一点?

Here is what I use on iOS5-7 这是我在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. IPConfiguration不是胖二进制文件。 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. 因此,如果您计划支持arm64设备,则还必须编译arm64的代码--32位应用程序无法加载64位dylib。 armv7 and arm64 are enough for all modern devices. armv7和arm64足以应对所有现代设备。

UPDATE UPDATE

Unfortunatelly this code doesn't work in regular iOS apps even on jailbroken device. 不幸的是,即使在越狱设备上,此代码也无法在常规iOS应用中使用。 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. 要使此代码正常工作,您需要将应用程序放在/var/mobile/Applications目录之外,而不应用沙箱限制。 It could be a daemon, a tweak or a GUI application inside /Applications directory. 它可以是/Applications目录中的守护进程,调整或GUI应用/Applications Applications inside that directory doesn't have any restrictions by default and can access any private API. 默认情况下,该目录中的应用程序没有任何限制,可以访问任何私有API。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM