Installing GCC on iOS 8

I recently entered the world of mobile security and pen-testing. I wanted to install GCC in a jailbroken iOS 8.3 and had to face lots of issues in finding the correct package for it. So I somehow managed to install and run my own C apps 🙂 I thought of sharing this with you, if you are too struggling like me here’s how I managed to install this.

First install OpenSSH and essential bash commands like apt-get, sed, ps, etc. After that you have to install few debian packages along with gcc. Download this zip file I made and drop it into any folder in your iPhone using a SFTP connection or a desktop file browser. After that install all the packages in it.

$ dpkg -i *.deb

Now if you write a classical Hello World program and compile and run you would get an error like this.

Illegal instruction: 4

For more information on the error refer to this. From that link I found out the way to patch for newer ARM architectures. You can also place this bash file as "patch.sh" inside the "/usr/bin/" folder.

#!/bin/bash
# https://osandamalith.wordpress.com
sed -i'' 's/\x00\x30\x93\xe4/\x00\x30\x93\xe5/g;s/\x00\x30\xd3\xe4/\x00\x30\xd3\xe5/g;' $1
ldid -s $1

Now simply run

$ patch.sh programname

For running direct assembly programs you don’t need any patch. For example this simple program would directly run after assembling and linking.

.text
.globl start
start:
mov r2, #14
adr r1, str
mov r0, #1
mov r12, #4
swi 0x80
mov r0, #0
mov r12, #1
swi 0x80
str:
.ascii "Hello, Osanda\n"

There might be many other ways as well. I hope you liked this 🙂

Advertisements

5 thoughts on “Installing GCC on iOS 8

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s