iOS 10.2中的MAC地址 [英] MAC addresses in iOS 10.2

查看:917
本文介绍了iOS 10.2中的MAC地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

看起来从iOS 10.2 开始,Apple现在已禁止访问所有 MAC地址,而不仅仅是您自己的设备。

It looks like starting with iOS 10.2, Apple has now prevented access to all MAC addresses, not just the one of your own device.

然而,商店中有一些似乎仍在管理的应用程序,例如 Fing Net Analyzer 。这些仍然有效,因为它们是针对较旧的SDK进行编译的,还是他们有特殊的技巧来收集MAC地址?

However, there are some apps in the store that seem to manage that still, .e.g Fing and Net Analyzer. Are these still working because they were compiled against an older SDK or do they have special tricks to gather the MAC address?

任何人都可以分享解决办法来获取MAC WiFi上iOS 10.2设备的地址?

Can anyone share a work-around to get the MAC addresses for iOS 10.2 devices on WiFi?

推荐答案

这只是测试代码,只是想知道如何获取Mac地址。但我相信Apple很快会关闭此选项。

This is only test code, just to give an idea for how to get the Mac address. But I am sure Apple will soon close this option.

-(void) jan_mac_addr_test:(const char*) host
{
    #define BUFLEN (sizeof(struct rt_msghdr) + 512)
    #define SEQ 9999
    #define RTM_VERSION 5   // important, version 2 does not return a mac address!
    #define RTM_GET 0x4 // Report Metrics
    #define RTF_LLINFO  0x400   // generated by link layer (e.g. ARP)
    #define RTF_IFSCOPE 0x1000000 // has valid interface scope
    #define RTA_DST 0x1 // destination sockaddr present
    int sockfd;
    unsigned char buf[BUFLEN];
    unsigned char buf2[BUFLEN];
    ssize_t n;
    struct rt_msghdr *rtm;
    struct sockaddr_in *sin;
    memset(buf,0,sizeof(buf));
    memset(buf2,0,sizeof(buf2));

    sockfd = socket(AF_ROUTE, SOCK_RAW, 0);
    rtm = (struct rt_msghdr *) buf;
    rtm->rtm_msglen = sizeof(struct rt_msghdr) + sizeof(struct sockaddr_in);
    rtm->rtm_version = RTM_VERSION;
    rtm->rtm_type = RTM_GET;
    rtm->rtm_addrs = RTA_DST;
    rtm->rtm_flags = RTF_LLINFO;
    rtm->rtm_pid = 1234;
    rtm->rtm_seq = SEQ;


    sin = (struct sockaddr_in *) (rtm + 1);
    sin->sin_len = sizeof(struct sockaddr_in);
    sin->sin_family = AF_INET;
    sin->sin_addr.s_addr = inet_addr(host);
    write(sockfd, rtm, rtm->rtm_msglen);

    n = read(sockfd, buf2, BUFLEN);
    if (n != 0) {
        int index =  sizeof(struct rt_msghdr) + sizeof(struct sockaddr_inarp) + 8;
        // savedata("test",buf2,n);
        NSLog(@"IP %s ::     %2.2x:%2.2x:%2.2x:%2.2x:%2.2x:%2.2x",host,buf2[index+0], buf2[index+1], buf2[index+2], buf2[index+3], buf2[index+4], buf2[index+5]);

    }
}

这篇关于iOS 10.2中的MAC地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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