[英]How do I detect if an app has been cracked without examining the SignerIdentity?
曾經有一種方法來檢查應用程序是否是從App Store購買的,以防止破解:
NSBundle *bundle = [NSBundle mainBundle];
NSDictionary *info = [bundle infoDictionary];
if ([info objectForKey: @"SignerIdentity"] != nil)
{ /* do something */ }
但這種方法不再有效,因為破解者已經找到了改變Info.plist的方法。 我知道這個較老的問題 ,但那里提出的答案依賴於上述技術,該技術已不再有效。
如何在不從Info.plist中讀取SignerIdentity的情況下,如何從App Store中檢測您的應用程序是否被破解或合法購買?
我個人喜歡Mick的回答,因為它簡短而簡單。
Greg的回復無效--Mick的代碼只檢查應用程序是否可以打開該URL,因此不應該崩潰。
我已經在我的一個應用程序中實現了以下內容,之前會更嚴格地檢查應用程序是否加密,如果不是它很可能是一個破解的應用程序:
從分析來看,這種方法已經阻止了成千上萬的盜版用戶,並且花了大約5分鍾來實現,所以這樣做的成本幾乎沒有 - 對我來說,我不在乎它是否增加了銷售額(我確信它不是不管怎么說 - 更多的是我不希望人們從我的辛勤工作中掙脫出來。 此外,我的應用程序的大量內容在確定應用程序是否是盜版之后提供信息,如果是,則返回垃圾數據。
在main.m
#import <dlfcn.h>
#import <mach-o/dyld.h>
#import <TargetConditionals.h>
#if TARGET_IPHONE_SIMULATOR && !defined(LC_ENCRYPTION_INFO)
#define LC_ENCRYPTION_INFO 0x21
struct encryption_info_command {
uint32_t cmd;
uint32_t cmdsize;
uint32_t cryptoff;
uint32_t cryptsize;
uint32_t cryptid;
};
#endif
static BOOL isEncrypted();
static BOOL isEncrypted () {
const struct mach_header *header;
Dl_info dlinfo;
/* Fetch the dlinfo for main() */
if (dladdr(main, &dlinfo) == 0 || dlinfo.dli_fbase == NULL) {
//NSLog(@"Could not find main() symbol (very odd)");
return NO;
}
header = dlinfo.dli_fbase;
/* Compute the image size and search for a UUID */
struct load_command *cmd = (struct load_command *) (header+1);
for (uint32_t i = 0; cmd != NULL && i < header->ncmds; i++) {
/* Encryption info segment */
if (cmd->cmd == LC_ENCRYPTION_INFO) {
struct encryption_info_command *crypt_cmd = (struct encryption_info_command *) cmd;
/* Check if binary encryption is enabled */
if (crypt_cmd->cryptid < 1) {
/* Disabled, probably pirated */
return NO;
}
/* Probably not pirated <-- can't say for certain, maybe theres a way around it */
return YES;
}
cmd = (struct load_command *) ((uint8_t *) cmd + cmd->cmdsize);
}
/* Encryption info not found */
return NO;
}
官方Apple的答案:
Hello Dmitry,
Thank you for contacting Apple Developer Technical Support (DTS).
DTS does not provide code-level support for DRM issues.
Please try posting your inquiry to Apple Development Forum:
<https://devforums.apple.com>
While you were initially charged a Technical Support Incident (TSI) for this request, we have assigned a replacement TSI back to your account.
Thank you for understanding our support policies.
Best Regards,
Apple Developer Support
Worldwide Developer Relations
我建議使用一個較小的代碼片段,它與@ user1353482建議的內容相同(以相同的方式)。 我會寫評論,但代碼將無法讀取。 此外,我可能是錯的,但似乎不再需要額外的定義,即使在編譯模擬器時(至少這在xcode 4.5.1中工作,目標是5.0)。
請注意,此代碼在debug和adhoc二進制文件中返回false,但我們正在討論appstore,對吧? 這是Apple的最終加密,你不應該在家里嘗試這個:)
#include <execinfo.h>
#import <mach-o/ldsyms.h>
bool executableEncryption()
{
const uint8_t *command = (const uint8_t *) (&_mh_execute_header + 1);
for (uint32_t idx = 0; idx < _mh_execute_header.ncmds; ++idx)
{
if (((const struct load_command *) command)->cmd == LC_ENCRYPTION_INFO)
{
struct encryption_info_command *crypt_cmd = (struct encryption_info_command *) command;
if (crypt_cmd->cryptid < 1)
return false;
return true;
}
else
{
command += ((const struct load_command *) command)->cmdsize;
}
}
return false;
}
雖然沒有檢查是否從App Store購買了應用程序,但我使用此代碼檢查我的應用程序是否在越獄設備上運行:
+(BOOL)isJailbroken {
NSURL* url = [NSURL URLWithString:@"cydia://package/com.example.package"];
return [[UIApplication sharedApplication] canOpenURL:url];
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.