Skip to main content

Road to IOS Pentesting: Get ready for war (ಥ﹏ಥ) (day 54)


At the beginning of the year, I told my senior that in my MSc term I will start to learn IOS application pen-testing since I feel that IOS security is becoming more popular and more demanded just like android application pen-testing, so I saw this as an opportunity and today my friend that day has come.

So In the first "Road to IOS pen-testing" post, I will tell you how I got started and prepare everything that I need to explore the wonderful world of IOS security. I hope this post also gives you some starter of all the resources that you need to get started on IOS pen-testing

A little bit of background:

Originally in mobile application security, I start with android first since it is easier to get all of the necessary equipment and you don't need to have an android phone to do pen-testing you can just substitute your device with a virtual machine or on emulator from android studio.



I learn some couple on how testing android applications from OWASP MSTG and E-MAPT but never touch IOS security because when I do a little bit of research you need a lot of tools that you need to buy to accommodate your testing.  So rather than give up, I start to save some money from security projects that I can join as a freelance and finally I was able to buy my first macOS it's a mac air book (although It's not the best mac at that time, still I was very happy)



The next item on the list is to get an old iPhone that I could jailbreak. Luckily, one of my family members has iPhone 5s that is no longer used, perfect!. I take it and wiped the device so it will not cause any trouble.

unfortunately, this process needs to be postponed since I need to take care of everything for preparing my MSc

Once it's done I start again to learn IOS security but before starting to do some security testing another senior of mine suggest to start learning obj-c first to get the concept of on how to build it (Yes! I agree) before breaking it

Okay so I take my time a couple of weeks to learn obj-c, I found this awesome playlist consist of tutorial on how to develop IOS app https://www.youtube.com/playlist?list=PLDi4zKeIloPygQF3V6QZOXc1ekrVkrXNb


Right now I was able to create a very simple ios app one of the apps I was able to create an app that provides mental math challenge (It's not perfect but hey! I built my first app)

Now come to the most frustrating part, jailbreaking:

Of course, if you want to do IOS pentesting you need iPhone that was jailbroken right ?! okay no problem

All I need to do is to find a jailbroken app like Uncover, pangu and chimera install it in my phone using Cydia. I follow the instruction on this website https://taig9.com/12.4/ (the iPhone has IOS 12.4.4 version)

None of them work!


First issue: I used Cydia to install app jailbreak, I do everything as the forum says from creating apple ID and generate a password for the Cydia to be used but all of it always end with error "installer.cpp; line: 71; what:_assert(!teams.empty())"

I try to search the solution in the google but it doesn't really help me and many sources suggest to wait for the developer to release a new patch of cydia (Like hell I want to wait)

Second issue: I move on to try another approach by installing "Tweakbox" to install the jailbroken app. The tweak box is installed correctly I verify the application signature from settings but every time it tries to install the jailbroken app it says it cannot be installed.

I'm screwed at this time, I'm stuck at this stage almost a week

Third time is the charm huh?!

At the third attempt, finally, I found something that really works.It starts when I was looking at billy ellis youtube channel (https://www.youtube.com/channel/UCk2sx_3FUkKvDGlIhdUQa8A) and he suggests to use an app called "checkra1n" (https://checkra.in/) the requirement fits with my device and I installed in my mac


The process is pretty smooth and all you need to have is a USB cable. The app will walk through you on the process and don't worry is not difficult

the device will go to recovery mode and then start doing jailbreaking and when it has done there will be a new app called "checkra1n"


you need to install the cydia app and once its has done, you can start to download all the necessary app to help you do penetration testing

this is the list of app that I installed inside my device:


  • openssh to (open a ssh server in my iphone)
  • newterm (a handy terminal emulator to let you interact with the system)
  • local ssh (just to check if the openssh is install correctly)


cool so the first three apps you can get it in the cydia. next in the list are iproxy, frida, objection and  idump

Iproxy, basically also used for doing ssh to the Iphone but I think its more convenient to do it locally by USB.

~# brew install libusbmuxd
~# iproxy 2222 22

go to another tab of terminal and type the following command 


Frida, for hooking the app for dynamic binary instrumentation

~# pip3 install frida-tools

you need to install the frida server inside the iphone using cydia, first you need to go to Sources → Edit → Add and enter https://build.frida.re


After you add the link you can start to download the app to your iPhone, notice that it will not show any icon of the app because the Frida server will run in the background.
 

You can test the frida is correctly installed by plug usb to the device and then type "frida-ps -U" this will list all of the running process.


Objection, I have not yet explored this particular tool but many resources say it's must-have tool

~# pip3 install objection

run objection --gadget "com.apple.AppStore" explore to check that everything is integrated properly

lastly is the i-dump or frida-ios-dump, it says that when you try to extract the app from the device it will be encrypted so to get the unencrypted version we can use this tool to dump the app in run time.

link: https://github.com/AloneMonkey/frida-ios-dump

~# git clone https://github.com/AloneMonkey/frida-ios-dump.git && cd frida-ios-dump

~# sudo pip3 install -r requirements.txt --upgrade

Okay, that's all folks! I hope you have a little insight about how to prepare yourself for IOS pen-testing

references:

https://spaceraccoon.dev/from-checkra1n-to-frida-ios-app-pentesting-quickstart-on-ios-13

Comments

Popular posts from this blog

Having fun analyzing nginx log to find malicious attacker in the net (ง'̀-'́)ง (day 37)

  What makes you sleepless at night? is it because of a ghost or scary stories? is it because you have an important meeting tomorrow? or is it because you have an exam? For me, what keeps me up all night is that I keep thinking about what happens to a website that I just created, is it safe from an attacker (certainly not) or did I missing some security adjustments that lead to vulnerability? well I'm not the best secure programmer in the world, I'm still learning and there is a big possibility that I can make a mistake but for me, a mistake can be a valuable investment to myself or yourself to be better so from this idea, I want to know more about what attackers casually do when attacking a website. Here in this post, I'm going to show you how I analyzed attack to the website that I have permission to design and also some interesting findings that I could get from the analysis Background: All of this analysis comes from the traffic that is targeted to th...

Utilize Pwntools for crafting ROP chain :') (day 69)

who doesn't like pwntools? it is a very versatile tool and can be customized according to our need using the python script but did you need to know that pwntools itself can help us to automatically craft a rop chain for us? so in this post, I will show you how to make rop chain less painful and make pwntools do all the heavy lifting. To demonstrate this I will use the binary challenge callme 64 bit from ropemporium link: https://ropemporium.com/challenge/callme.html Crashing the app: Like any other exploitation process, we need to crash the program by generating a long string pattern to determine the offset. based on the information from the above figure we can see that we required to provide 40 bytes of offset Fun stuff: now this where the fun stuff began write the following python script: as in the guideline of the challenged said we need to chain the function call by first to call the callme_one function, callme_two function and then callme_three funct...

Bypassing stack canaries protection :') (day 51)

In my previous blogs, I show you guys how to bypass some common protection usually used in Linux binary such as NX and ASLR but this time we are going to take it to the next level we are going to talk about protection employ in the modern Linux OS which is "The Canaries" and how to bypass it. note: this post was not originally mined it was inspired by the following resources https://ctf-wiki.github.io/ctf-wiki/pwn/linux/mitigation/canary/ (Credit goes to the author) we are going to start this post about what is stack canaries and types of different implementation of it then move to the implementation about how to bypass this protection. We are going to focus on "leak canaries" technique What is stack canary: In layman terms, canaries are just another protection mechanism to prevent stack overflow implemented by appending 4/8 bytes value (depend on the architecture) into the stack when a function is entered. When the function is at the end of its exec...