Executable encryption check anti piracy measure

后端 未结 4 681
半阙折子戏
半阙折子戏 2020-12-24 04:03

I read a very interesting blog about implementing some anti-piracy protection into your apps. Some of them dont work anymore, some of them do. The 2 ones that still are effe

相关标签:
4条回答
  • 2020-12-24 04:31

    It looks like this is looking for the signature block in the dyload header. This means that you're only going to see this on code which is signed. Chances are that your code isn't being automatically signed for debugging (unnecessary), although it will be signed when it goes to the device.

    You might want to make this entire check conditional on the project running on an iOS device instead of in the simulator. Any binary sent to an iOS device must be signed.

    #if !(TARGET_IPHONE_SIMULATOR)
    your check
    #endif // 
    
    0 讨论(0)
  • 2020-12-24 04:32

    This code won't work successfully on a 64-bit device like the iPhone 5s. The header has been changed from mach_header to mach_header_64 and the command ID is now LC_ENCRYPTION_INFO_64.

    What I did was to read the header and then see what the magic number was. If it's MH_MAGIC_64 then you're on a 64-bit device and you need to use the mach_header_64 struct and look for LC_ENCRYPTION_INFO_64 (defined as 0x2C) instead of LC_ENCRYPTION_INFO.

    0 讨论(0)
  • 2020-12-24 04:37

    A better otool command to see whether a file is encrypted or not is:

    otool -arch armv7 -l YourAppName | grep crypt
    
    0 讨论(0)
  • 2020-12-24 04:38

    I have been looking into this recently as well and tested with the same results. It turns out this code is telling you YES or NO based on whether the binary is encrypted with Apple's FairPlay DRM. Any debug or ad-hoc builds you do will say NO.

    You can see the same information on your binary or any iPhone apps you have purchased using the otool command-line tool.

    For your own binaries, find the binary in your project under e.g. build/Debug-iphoneos/MyApp.app and run (from Terminal)

    otool -l MyApp | more

    Scan through for cryptid in the LC_ENCRYPTION_INFO section. Since this is a debug build it will be 0. If you have synched your phone to your computer, check under ~/Music/iTunes/Mobile Applications and pick an .ipa file. Unzip it and try otool against the binary from the .ipa and it should have 1 for the cryptid.

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