使用私有API在iOS 7上扫描网络(SSID) [英] Scan networks (SSID's) on iOS 7 by using private API

查看:177
本文介绍了使用私有API在iOS 7上扫描网络(SSID)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以通过iOS 7 Jailbroken设备上的私有API获取SSID的网络列表?

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

我知道 MobileWiFi.framework 管理iOS上的WiFi功能。 (它取代了过时的Apple80211框架。)

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

这是4岁回答如何使用它:访问&使用MobileWiFi.framework

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

我尝试在iOS 7上使用这些方法,但没有运气。

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 失败,因为该代码现在已有4年历史。正如我在回答中所描述的那样,您必须使用新的框架来获得相同的功能(至少从iOS 5开始,您必须这样做)。如果您尝试使用iOS 7,我建议发布新问题

ps

重复 range-ios-7>获取iOS 7范围内的SSID 。我问这些功能的越狱方法。

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

UPD:

上面的链接和creker的答案中都有工作代码。但是需要通过沙盒限制。
所以,正确的问题是:有没有办法用普通的iOS应用程序做到这一点?

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?

推荐答案

这是我在iOS5-7上使用的东西

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 不是胖二进制文件。它只包含一个与设备匹配的架构。因此,如果您计划支持arm64设备,则还必须编译arm64的代码--32位应用程序无法加载64位dylib。 armv7和arm64足以满足所有现代设备的需求。

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.

更新

不幸的是这个即使在越狱设备上,代码也无法在常规iOS应用中使用。越狱不会关闭沙箱,这是代码不起作用的原因。要使此代码正常工作,您需要将应用程序放在 / var / mobile / Applications 目录之外,而不应用沙箱限制。它可以是 / Applications 目录中的守护进程,调整或GUI应用程序。默认情况下,该目录中的应用程序没有任何限制,可以访问任何私有API。

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.

这篇关于使用私有API在iOS 7上扫描网络(SSID)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆