Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
590 views
in Technique[技术] by (71.8m points)

iphone - Does Apple modify iOS application executables on apps submitted to the App Store?

Is an app's executable file byte-for-byte identical when the app is purchased through the App Store and installed on a user's iPhone, compared to the original executable file submitted to Apple in the original app bundle? Or is it different (for example, with additional signatures or encryption)?

I am concerned only about the executable file, not the entire app bundle.

In particular, would code such as ...

int main(int argc, char* argv[]) {
   FILE* file = fopen(argv[0], "rb");
   // Read entire contents of executable file; calculate a hash value
   // ...
   fclose(file);
}

... calculate the same hash as calculating the hash outside of the iPhone on the original, submitted executable?

For example, calculating a SHA256 hash as above then using "Build and Run" in XCode to run on an attached iPhone produces exactly the same result as calculating the SHA256 hash by running openssl sha256 MyAppExecutableFile from a terminal in OS X. This means the act of installing the app through XCode does not alter the executable file.

My question is whether or not this still holds when an app is submitted to the App Store, purchased, and installed.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The application executable is encrypted by Apple when released on the App Store, so self-running a checksum on your own binary is not a good idea —you cannot know the file size of the encrypted binary in advance—.

Mind you, the binary always remains encrypted in the file system, and only the iPhone root user can decrypt these binaries. If you download an app from the App Store with iTunes, you can open the IPA on your PC or Mac and see that the binaries are indeed encrypted by running otool:

otool -l <app binary> | grep cryptid
crypt id 1
(a value of cryptid 1 means the app is encripted)

otool -l <app binary> | grep cryptsize
12345678
(size of the encrypted segment)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...