Determining if an iPhone is Jail broken Programmatically

后端 未结 4 724
情话喂你
情话喂你 2020-11-27 09:23

How do you determine (programmatically) if an iPhone/iPod is:

  1. Jail broken
  2. Running a cracked copy of your software

Pinch Media can det

4条回答
  •  遥遥无期
    2020-11-27 10:05

    Just to expand on zakovyrya's reply, you could use the following code:

    if ([[[NSBundle mainBundle] infoDictionary] objectForKey: @"SignerIdentity"] != nil) {
      // Jailbroken
    }
    

    HOWEVER, the person jailbreaking your app can hexedit your program and as such, they could edit the string @"SignerIdentity" to read @"siNGeridentity" or something else which would return nil, and thus pass.

    So if you use this (or any of the other suggestions from http://thwart-ipa-cracks.blogspot.com/2008/11/detection.html):

    • Don't expect it to work forever
    • Don't use this information to break/hinder your app in any way (otherwise they'll have cause to hexedit it, so your app won't know it is jailbroken)
    • Probably wise to obfuscate this bit of the code. For example, you could put the base64 encoded reversed string in your code, and then decode it in the app by reversing the process.
    • Validate your validation later in your code (e.g. when I said SignerIdentity, did it actually say SignerIdentity or siNGeridentity?)
    • Don't tell people on a public website like stackoverflow how you do it
    • Keep in mind it is only a guide and is not fool-proof (nor cracker-proof!) - with great power comes great responsibility.

提交回复
热议问题