Mac App Store Receipt Validation Code?

前端 未结 13 1666
广开言路
广开言路 2020-12-07 09:04

Wondering if anyone has a tutorial or working code for the new Mac App Store\'s receipt validation? About the only references I\'ve been able to find so far are Apple\'s st

相关标签:
13条回答
  • 2020-12-07 09:11

    In order to validate against the real receipt after testing, change this line of code in your main.m file:

    if (!validateReceiptAtPath(@"~/Desktop/receipt"))
    

    to

    #ifdef USE_SAMPLE_RECEIPT   // defined for debug version
        NSString *pathToReceipt = @"~/Desktop/receipt";
    #else
        NSString *pathToReceipt = [[[NSBundle mainBundle] bundlePath]
            stringByAppendingPathComponent:@"Contents/_MASReceipt/receipt"];
    #endif  
        if (!validateReceiptAtPath(pathToReceipt))
            exit(173); //receipt did not validate
    

    and in your compiler settings, "Other C Flags" for your Debug Configuration should include -DUSE_SAMPLE_RECEIPT

    courtesy http://jesusagora.org/groups/futurebasic/0::53562:get:1read.html

    0 讨论(0)
  • 2020-12-07 09:12

    I'll elaborate on priller's answer. If Apple provided a code sample for the validation process then it would be very easy for a Bad Guy to take your compiled app and scan through it for the code corresponding to the validation process. The Bad Guy would know exactly what the compiled code looks like if you use a standard code sample from Apple. Once the Bad Guy has found that section of the code it is pretty trivial to modify the app's compiled code to just skip the receipt verification stage, rendering the entire thing useless.

    All that said, a determined cracker is probably going to get around any copy protection you put in place regardless of what you do. The games industry (for example) spends a lot of time trying to protect their software, and cracked versions seem to always be available.

    0 讨论(0)
  • 2020-12-07 09:17

    I'd propose to implement the code verification routines as C functions, not ObjC methods.

    This technique makes it (a bit) harder to locate receipt checking code, since fewer method-names get compiled into the binary.

    0 讨论(0)
  • 2020-12-07 09:18

    RVNReceiptValidation is great and it uses CommonCrypto rather than the now deprecated by Apple, openssl. you will have to attach a valid receipt to your project to debug it. Do this by getting a valid receipt from another app bundle and create a build phase in your test environment to add it to your bundle. I suggest the following techniques for obfuscation:

    Encrypt the kRVNBundleID and kRVNBundleVersion and decrypt them when you compare them to the CFBundleIdentifier and CFBundleShortVersionString.

    I create an array of function pointers with random values and change them to valid pointers to the functions in RVNReceiptValuation at run time before executing them using code like this:

    static void testFunction(void);
    
    typedef void (*functionPtr)(void);
    
    functionPtr obfuscationArray[8] = {
        (functionPtr)0xA243F6A8,
        (functionPtr)0x885308D3,
        (functionPtr)0x13198A2E,
        (functionPtr)0x03707344,
        (functionPtr)0xA4093822,
        (functionPtr)0x299F31D0,
        (functionPtr)0x082EFA98,
        (functionPtr)0xEC4E6C89};
    
    int main(int argc, const char * argv[]) {
        functionPtr myFuncPtr;
    
        obfuscationArray[3] = &testFunction;
        myFuncPtr = obfuscationArray[3];
        (myFuncPtr)();
    
        return 0;
    }
    
    static void testFunction(void){
        printf("function executed\n");
    }
    
    0 讨论(0)
  • 2020-12-07 09:19

    You could try NPReceiptVerification. It's the easiest way to add receipt verification to your app. You just add the class files to your project, set the version and bundle identifier, and everything else is handled automatically.

    0 讨论(0)
  • 2020-12-07 09:20

    roddi's ValidateStoreReceipt worked for me before, but it does not work any more. I wrote a blog post about the solution: http://vinceyuan.blogspot.com/2012/07/validate-mac-app-store-receipt-2012.html

    Copied here: roddi's code is still working. You need not change it. (Just need to get the latest version) Follow these steps (internet required):

    1. Log out from Mac App Store app.
    2. Remove USE_SAMPLE_RECEIPT flag from your project settings -> Preprocessor Macros.
    3. Compile your project
    4. Find this app in Finder
    5. Double click it in Finder to run. Do not run it in Xcode.
    6. The OS will ask you to log in with your Apple ID. Do not log in with your real iTunes account. You need to log in with the test account. Find it or create it in the iTunesconnect website.
    7. The OS will say something like "Your app is broken. Download it in App Store". Ignore this message. If you "Show Package Contents" of this app in Finder, you will see there is a file _MASReceipt/receipt. The OS installed a development receipt. We will not need the old sample receipt any more. That's why we remove USE_SAMPLE_RECEIPT debugging flag.

    Done. You can debug your app now.

    0 讨论(0)
提交回复
热议问题