4

注意----下面的答案使用iOS6-方法,Apple从那时起删除了开发人员对MAC地址的访问权限。如果您正在为 iOS7+ 开发,请忽略第一个答案,而只是根据每个设备独有的其他变量(例如应用程序首次启动的日期)加密您的 IAP 解锁数据

我有需要解锁音调的功能,所以我将它们存储在我的 plist 文件中.... 像聊天室中的新头像这样的功能可能具有 id “13891”,如果它已解锁,我可能会为其分配一些键,如“93 “如果它被锁定,它可能有任何其他键“37”例如......所以plist会说:“13891”=“93”我的问题是越狱手机可以轻松编辑plist文件并为自己解锁功能吗?存储这些数据的更好方法是什么?我不想每次都检查 Apple 的服务器,因为互联网连接速度太慢,这需要很长时间。

编辑:当前答案:

4 措施:

1)将其存储在钥匙串中。(或者我想现在我已经添加了措施#4)

2) 每次都检查 Apple 的服务器,但如果您担心随后的延迟,只需在后台检查它,同时让用户使用该应用程序,如果它说可以的话。

3)将您的变量作为加密密钥存储在钥匙串中......不要存储“FishingRod = unlocked”存储“3dhk34D@HT% = d3tD@#”。

4) 使用设备 MAC 地址加密每个密钥(这些 MAC 地址不会更改,并且无论是否有 WiFi 连接都可用......下面的代码)。这样,如果用户从 Internet 下载 plist 并尝试使用它,它将无法正常工作,因为当您使用他们的设备 ID 对其进行解密时,您将无法随机废话而不是解锁密钥(在我的示例中将是“d3tD@#”。)!!!-- 从 iOS7+ 起无法再访问 Mac 地址,而是使用其他设备独有的东西加密,例如应用程序首次启动的日期

MAC 地址代码(只需将其粘贴在 .H 导入中的视图控制器 ViewDidAppear... 中)

#include <sys/socket.h>
#include <sys/sysctl.h>
#include <net/if.h>
#include <net/if_dl.h>

-(void)viewDidAppear:(BOOL)animated {

    int                 mgmtInfoBase[6];
    char                *msgBuffer = NULL;
    NSString            *errorFlag = NULL;
    size_t              length;

    // Setup the management Information Base (mib)
    mgmtInfoBase[0] = CTL_NET;        // Request network subsystem
    mgmtInfoBase[1] = AF_ROUTE;       // Routing table info
    mgmtInfoBase[2] = 0;
    mgmtInfoBase[3] = AF_LINK;        // Request link layer information
    mgmtInfoBase[4] = NET_RT_IFLIST;  // Request all configured interfaces

    // With all configured interfaces requested, get handle index
    if ((mgmtInfoBase[5] = if_nametoindex("en0")) == 0)
        errorFlag = @"if_nametoindex failure";
    // Get the size of the data available (store in len)
    else if (sysctl(mgmtInfoBase, 6, NULL, &length, NULL, 0) < 0)
        errorFlag = @"sysctl mgmtInfoBase failure";
    // Alloc memory based on above call
    else if ((msgBuffer = malloc(length)) == NULL)
        errorFlag = @"buffer allocation failure";
    // Get system information, store in buffer
    else if (sysctl(mgmtInfoBase, 6, msgBuffer, &length, NULL, 0) < 0)
    {
        free(msgBuffer);
        errorFlag = @"sysctl msgBuffer failure";
    }
    else
    {
        // Map msgbuffer to interface message structure
        struct if_msghdr *interfaceMsgStruct = (struct if_msghdr *) msgBuffer;

        // Map to link-level socket structure
        struct sockaddr_dl *socketStruct = (struct sockaddr_dl *) (interfaceMsgStruct + 1);

        // Copy link layer address data in socket structure to an array
        unsigned char macAddress[6];
        memcpy(&macAddress, socketStruct->sdl_data + socketStruct->sdl_nlen, 6);

        // Read from char array into a string object, into traditional Mac address format
        NSString *macAddressString = [NSString stringWithFormat:@"%02X:%02X:%02X:%02X:%02X:%02X",
                                      macAddress[0], macAddress[1], macAddress[2], macAddress[3], macAddress[4], macAddress[5]];
        NSLog(@"Mac Address: %@", macAddressString);

        // Release the buffer memory
        free(msgBuffer);

        //return macAddressString;
        NSLog(@"MAC: %@", macAddressString);
        //F0:DC:E2:1D:EB:50
    }

    // Error...
    NSLog(@"Error: %@", errorFlag);
}

注意:我从朋友那里得到了 MAC 地址代码……我并不是说我编写了代码……我不知道是他编写的还是从其他人那里得到的。

4

3 回答 3

4

4 措施:

1)将其存储在钥匙串中。(或者我想现在我已经添加了措施#4)

2) 每次都检查 Apple 的服务器,但如果您担心随后的延迟,只需在后台检查它,同时让用户使用该应用程序,如果它说可以的话。

3)将您的变量作为加密密钥存储在钥匙串中......不要存储“FishingRod = unlocked”存储“3dhk34D@HT% = d3tD@#”。

4) 使用设备 MAC 地址加密每个密钥(这些 MAC 地址不会更改,并且无论是否有 WiFi 连接都可用......下面的代码)。这样,如果用户从 Internet 下载 plist 并尝试使用它,它将无法正常工作,因为当您使用他们的设备 ID 对其进行解密时,您将无法随机废话而不是解锁密钥(在我的示例中将是“d3tD@#”。)!!!-- 从 iOS7+ 起无法再访问 Mac 地址,而是使用其他设备独有的东西加密,例如应用程序首次启动的日期

MAC 地址代码(只需将其粘贴在 .H 导入中的视图控制器 ViewDidAppear... 中)

#include <sys/socket.h>
#include <sys/sysctl.h>
#include <net/if.h>
#include <net/if_dl.h>

-(void)viewDidAppear:(BOOL)animated {

    int                 mgmtInfoBase[6];
    char                *msgBuffer = NULL;
    NSString            *errorFlag = NULL;
    size_t              length;

    // Setup the management Information Base (mib)
    mgmtInfoBase[0] = CTL_NET;        // Request network subsystem
    mgmtInfoBase[1] = AF_ROUTE;       // Routing table info
    mgmtInfoBase[2] = 0;
    mgmtInfoBase[3] = AF_LINK;        // Request link layer information
    mgmtInfoBase[4] = NET_RT_IFLIST;  // Request all configured interfaces

    // With all configured interfaces requested, get handle index
    if ((mgmtInfoBase[5] = if_nametoindex("en0")) == 0)
        errorFlag = @"if_nametoindex failure";
    // Get the size of the data available (store in len)
    else if (sysctl(mgmtInfoBase, 6, NULL, &length, NULL, 0) < 0)
        errorFlag = @"sysctl mgmtInfoBase failure";
    // Alloc memory based on above call
    else if ((msgBuffer = malloc(length)) == NULL)
        errorFlag = @"buffer allocation failure";
    // Get system information, store in buffer
    else if (sysctl(mgmtInfoBase, 6, msgBuffer, &length, NULL, 0) < 0)
    {
        free(msgBuffer);
        errorFlag = @"sysctl msgBuffer failure";
    }
    else
    {
        // Map msgbuffer to interface message structure
        struct if_msghdr *interfaceMsgStruct = (struct if_msghdr *) msgBuffer;

        // Map to link-level socket structure
        struct sockaddr_dl *socketStruct = (struct sockaddr_dl *) (interfaceMsgStruct + 1);

        // Copy link layer address data in socket structure to an array
        unsigned char macAddress[6];
        memcpy(&macAddress, socketStruct->sdl_data + socketStruct->sdl_nlen, 6);

        // Read from char array into a string object, into traditional Mac address format
        NSString *macAddressString = [NSString stringWithFormat:@"%02X:%02X:%02X:%02X:%02X:%02X",
                                      macAddress[0], macAddress[1], macAddress[2], macAddress[3], macAddress[4], macAddress[5]];
        NSLog(@"Mac Address: %@", macAddressString);

        // Release the buffer memory
        free(msgBuffer);

        //return macAddressString;
        NSLog(@"MAC: %@", macAddressString);
        //F0:DC:E2:1D:EB:50
    }

    // Error...
    NSLog(@"Error: %@", errorFlag);
}
于 2012-12-30T19:22:36.523 回答
3

你甚至不需要越狱。无论您将可写文件存储在何处,iPhone Explorer 之类的应用程序都可以让用户抓取并修改该文件,然后将其写回设备。只需一个人购买即可将解锁的 plist 文件发送到整个互联网。

我要做的是将解锁的项目存储在设备上的钥匙串中(只是为了让它稍微模糊一点),并在启动时相信它 - 但每次尝试在后台联系 Apple 服务器以验证用户真的应该拥有那些未锁定的物品。这样,即使他们可以伪造钥匙串条目,他们也可能会在短时间内解锁项目,但如果在应用程序运行时设备完全连接到互联网,则该功能将被删除。必须记住在每次运行之前断开设备与互联网连接的连接可能太烦人了,以至于盗窃的解锁对伪造者来说是值得的。

由于钥匙串即使在应用程序删除时仍然存在,您可能还想在第一次启动时写出一个 plist 文件,如果您在以后的启动中没有检测到最初创建的 plist 文件,请清除钥匙串。

如果有的话,有人在你的应用程序中摆弄和解锁东西的风险可能很低。当情况不明朗时,总是错误地给予用户访问权限,这样你就不会给真实用户带来问题。

于 2012-12-29T21:14:07.407 回答
1

越狱手机可以轻松编辑plist文件并为自己解锁功能吗?

对,就是这样。

存储这些数据的更好方法是什么?

也许是钥匙串,但在越狱设备上也可以改变。

我不想每次都检查 Apple 的服务器,因为互联网连接速度太慢,这需要很长时间。

太糟糕了。如果你想至少在某种程度上是安全的,你最好检查苹果的服务器,甚至更好的是,你自己的服务器也是如此。(这也不是 100% 保证您的游戏不会在越狱手机上被黑客入侵,因为可以使用 MobileSubstrate 随意修改应用程序的行为,但至少它更安全一些。)

于 2012-12-29T21:01:18.770 回答