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.

[code language=”bash”]
$ dpkg -i *.deb
[/code]

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

Illegal instruction: 4

View post on imgur.com

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.
[code language=”bash”]
#!/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
[/code]

Now simply run
[code language=”bash”]
$ patch.sh programname
[/code]

View post on imgur.com

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"

View post on imgur.com

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

5 thoughts on “Installing GCC on iOS 8

  1. help
    I compile and run gcc hello.c error:
    ld: unknown/unsupported architecture name for: -arch arm

    what should I do?
    Installation files can give me?

Leave a Reply