📜 ⬆️ ⬇️

Automatic file copying on iOS device without jailbreak and file managers

I got one project, inherently nothing supernatural - the most common gallery of pictures for which data was downloaded from the server, but nevertheless it was quite interesting. First of all, it was necessary to take into account that those images that are displayed in the gallery, in no case should not get to third parties, since this application was specially created for the oligarchs of the powerful. According to all the requirements, communication with the server should take place via SSL protocol and during each request it is necessary to check the certificate received from the server for a power of attorney, and only after this check to send the necessary certificate to validate the user for each specific request. That is, not all requests use the same certificate, which means that a certain number of certificates must be transferred to the device, which depends on the client and its registration.

Before us was the question: how to transfer the necessary certificates to the device. At the very beginning, we considered ways to copy files in iTunes using File Sharing, upload certificates to Keychain via Wi-Fi, send certificates via e-mail, etc. But they all did not fit in several requirements:

1. You can not use wireless networks, based on the concept of security, only a wired connection.
2. The user should not participate in the file transfer.
3. The use of a system keychain is prohibited.
4. Everything should happen more or less imperceptibly.

After all the research and discussions, a method was found that met all the requirements. It was used in the implementation of several file system browsers for the iPhone / iPad (iPhone Explorer, iDisk, iPhone Browser), but the approach was incomprehensible. After the next run on our beloved Google and long reflections, it became clear that all these browsers use iTunes in their work and this happens through the private framework MobileDevice.framework. In order to work with it, the MobileDevice.h file was extracted, which was formed by kind people through reverse engineering. And then the magic began ...
')
Examining all the functions of this .h file, we understood its purpose and approximate model of work with the device. After some time, managed to get and m. file implementation of some part of these functions. And after the necessary changes for our needs, we have the following functionality:

1. Search for an application by its identifier (necessary for the application to determine the location of the application and its directories).
2. Display a list of all installed applications.
3. View a list of directories.
4. View the contents of directories.
5. Copy files from / to device.
6. The definition of a connected / disconnected device.
7. View the Media folder and all its subfolders and files, and some others.

It is worth adding that all these features are available without a jailbreak. This is very important, since for the end user it would be very inconvenient, and sometimes even unrealistic, to understand the hacking of the device and its connection via SSH or SFTP and in self-copying files. Moreover, not quite ordinary citizens should use the developed program.

In order to use this library, an application was written with a command line for Mac OS, since this system will most often be used by the client. In the application's incoming parameters, for simplicity and convenience, the application identifier, the source file path and the path where it is necessary to copy it are indicated. Since the application on the device itself is convenient to use files from the / Documents folder, most often it is indicated as the final directory for the file.

Since the implementation of all functions and solutions is inconvenient and takes a lot of code, since the written library is not small, this console application was laid out for everyone to try and use in their projects on GitHub: github.com/xslim/mobileDeviceManager

All the pleasant work, interesting projects, and that the requirements always coincide with your capabilities!

PS Thank you all, corrected typos. The topic was written after the working day, that's where the mistakes come from.

Source: https://habr.com/ru/post/113074/


All Articles