iPhoneの近接検出を試みていますが、プログラムでBluetooth MACアドレスを取得する必要があります。誰も方法を知っていますか?
Bluetooth は有効になっていると思いますが、iPhone とペアリングされたデバイスはありません。
iPhoneの近接検出を試みていますが、プログラムでBluetooth MACアドレスを取得する必要があります。誰も方法を知っていますか?
Bluetooth は有効になっていると思いますが、iPhone とペアリングされたデバイスはありません。
私が手に入れることができるすべてのデバイスで、次のルールが適用されるようです-iPhone wifi MACアドレスはiPhone bluetooth MACアドレスより1大きい-iPad wifi MACアドレスはiPad bluetooth MACアドレスより1小さい.
理論の信頼性を高めることができるように、人々がiPhoneまたはiPadでこれを確認すると役立ちます. いくつかの iPhone4、iPhone3、および iPad1 デバイスで確認しました。
設定 - 一般 - 情報を開き、「Wi-Fi アドレス」と「Bluetooth」で確認できます。
理論が正しければ、次の正当なコードで Bluetooth の MAC アドレスを取得できます。
#include <sys/types.h>
#include <sys/socket.h>
#include <ifaddrs.h>
#include <netdb.h>
#include <net/if_dl.h>
#include <string.h>
#if ! defined(IFT_ETHER)
#define IFT_ETHER 0x6/* Ethernet CSMACD */
#endif
void doMacTest() {
BOOL success;
struct ifaddrs * addrs;
const struct ifaddrs * cursor;
const struct sockaddr_dl * dlAddr;
const uint8_t * base;
// We look for interface "en0" on iPhone
success = getifaddrs(&addrs) == 0;
if (success) {
cursor = addrs;
while (cursor != NULL) {
if ( (cursor->ifa_addr->sa_family == AF_LINK)
&& (((const struct sockaddr_dl *) cursor->ifa_addr)->sdl_type == IFT_ETHER)
&& (strcmp(cursor->ifa_name, "en0") == 0)) {
dlAddr = (const struct sockaddr_dl *) cursor->ifa_addr;
base = (const uint8_t *) &dlAddr->sdl_data[dlAddr->sdl_nlen];
if (dlAddr->sdl_alen == 6) {
fprintf(stderr, ">>> WIFI MAC ADDRESS: %02x:%02x:%02x:%02x:%02x:%02x\n", base[0], base[1], base[2], base[3], base[4], base[5]);
fprintf(stderr, ">>> IPHONE BLUETOOTH MAC ADDRESS: %02x:%02x:%02x:%02x:%02x:%02x\n", base[0], base[1], base[2], base[3], base[4], base[5]-1);
fprintf(stderr, ">>> IPAD BLUETOOTH MAC ADDRESS: %02x:%02x:%02x:%02x:%02x:%02x\n", base[0], base[1], base[2], base[3], base[4], base[5]+1);
} else {
fprintf(stderr, "ERROR - len is not 6");
}
}
cursor = cursor->ifa_next;
}
freeifaddrs(addrs);
}
}
この情報を取得するためのパブリック API はありません。
これが内部または脱獄アプリケーションの場合、liblockdown.dylibkLockdownBluetoothAddressKey
を介してキーの値を取得できます