📜 ⬆️ ⬇️

Experience compiling Veency for iPhone

Foreword


Despite the fact that Apple provides a fairly complete SDK for the iPhone, an application is sometimes needed that goes beyond documented features. An example of such an application is Veency, VNC server for jailbreaked iPhones.
I would like to share the experience of compiling Veency from scratch. I hope that this post will be informative.

Problem


It is necessary to make small changes to the VNC server code for jailbroken iPhone, recompile and install it on the device. Available: device, Ubuntu 9.04 and Mac.

Decision


The solution below is not a step-by-step guide. I would like to talk about the assembly process in general and about the difficulties that I met. Moreover, I tried to collect in this post all the necessary links, as well as to lay out some results of my work.
')
Components

Saurik (aka Jay Freeman) is the developer of Cydia, Veency, many other iPhone chips and seems to be a very good person.

SpringBoard is a library that essentially draws the iPhone's homescreen. Starts with the device.

toolchain is a toolkit for compiling iPhone applications. We will build it soon.

libvncserver - VNC open source server. We will cross-compile it for the iPhone.

Veency - VNC server for iPhone'a. We will build it. Salt - in the file Tweak.mm , the rest is not interesting to us.

MobileSubstrate is a library written by saurik. In particular, it allows you to run applications in the background. We are interested in the following feature: if we put the library ( dylib ) in /Library/MobileSubstrate/DynamicLibraries , it will be loaded when SpringBoard starts. The product of our experience is Veency.dylib , which will be located in DynamicLibraries .

Step 1: Toolchain for Ubuntu

It turns out that assembling a toolchain is not as difficult as it seems. We will build the toolchain for 2.2.1. She will be able to compile applications for 3.0.

There is such a project, iphonedevonlinux . This, in fact, is a single script, ./toolchain.sh , which loads almost all the necessary files, scatters everything in folders and collects the toolchain.

For this script, I downloaded: iPhone ipsw version 2.2.1 and Xcode SDK dmg version 2.2.1. Moreover, you need to have an account on developer.apple.com (it's free). On Ubuntu, you need gobjc and some other development tools. Everything is installed from standard repositories.

So sudo ./toolchain.sh all .

I did not earn the first time. I met the following troubles:
1. *** buffer overflow detected *** : solved apt-get reinstall gcc
2. cannot compile toolchain/src/cctools/otool/print_objc.c : solved apt-get install libc6
3. some random error: changed gcc 4.3.3 to gcc 4.2.4. Then I changed it back and it all worked. As a result, gcc compiled 4.3.3.

When everything is ready, the script will say "All stages completed. The toolchain is ready."

Step 2: VNC Server

Everything is simple. You need to download the libvncserver source code , and cross-compile them. Actually, ./configure --host=arm-apple-darwin9 , and then the usual make . The only thing that prevented me was that in the main Makefile, all sorts of left-wing projects (like libvncclinet , examples , etc.) were built. I removed them with my hands.
If I’m too lazy to build it myself, then I put the library and headers on ifolder .

When everything is ready, libvncserver/.lib/libvncserver.dylib will appear.

Step 3: Veency Makefile

Saurik, of course, laid out his makefile. However, he has this part of his build framework, so it seemed to me easier to write your Makefile, where everything is in one file. I haven't encountered any particular difficulties.

Here is the result of my work: Makefile on pastie .

Step 4: MobileSubstrate

Header and library is needed. You can either collect from the repository , or download the already compiled archive . I did the second.

Step 5: Headers & Frameworks

For the Veency build, headers and frameworks are needed. What exactly is obvious from imports.

Hedery. There is a dog buried here. Heder is not easy to find. There is a secret repository where something is stored. There is a class-dump-x program for dumping Objective-C headers. There is a de-compiler ( arm-apple-darwin9-otool ), but this should not happen. I want to draw attention to the class GraphicsServices.h : for him the right headers turned out to be the hardest to find (found in the secret repository).

Frameworks Everything is simple. If at the linking stage there are not enough symbols, you can safely copy the frameworks either from the iPhone SDK ( /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.2.1.sdk/System/Library/Frameworks/ on the poppy) scp from the device. The only difficulty: the libraries from 3.0 and 2.2.1 are not worth mixing.

Step 6: Make

If it breaks at the compilation stage, then it is necessary to give not grabbing headers. They need to be obtained and added to the in-folder ( SB_PATH in Makefile).
If it breaks at the linking stage, then you need to add the frameworks to $(SYS_PATH)/System/Library ( SYS_PATH from the Makefile).

Result: Veency.dylib

Step 7: Signing

The collected library must be signed. For this there is a utility ldid . It is for the desktop and for the iPhone. On the desktop, she did not work for me. On the iPhone, it is installed from Cydia. Further it is simple: you need to scp Veency.dylib on the device and type ldid -S Veency.dylib .

Result: signed Veency.dylib

Step 8: Installation

And it's completely simple: copy Veency.dylib to /Library/MobileSubstrate/DynamicLibraries . This is automated in the Makefile by the install target (you only need to set the IP variable).

Result: You are a hacker :)

About this post


And you want to know why I wrote all this? First, share some knowledge. And, secondly, to support Habr. Lately, it’s been a lot of articles about the fact that Habr is not the one that the UFO is already on the moon, what to do with AI is trivial. All sorts of idle thoughts, meaningless questions, links to news from other resources, and so on. So I want to somehow resist.

Reader, please, write and you about IT. Let it be on a narrow topic, if only the tops of ideas, the path is interesting for the units. But Habr will have a cake yet!

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


All Articles