‫-: Hi. Within this lecture, we are going to take a look
‫at the Swift version of this jailbreaking app.
‫So, we have this Swift version over here, right?
‫We have downloaded it from GitHub.
‫So, I'm going to close this down
‫and I'm going to delete everything related
‫to objective C and I'm going to bring in the Swift version.
‫So, there are challenges in Swift version.
‫Cycript doesn't properly work in this case.
‫So, we're going to see how that goes.
‫So, let me close this down and here you go.
‫Here is our DetectJailSwift.
‫So, I'm going to take the IPA from here as well
‫and I'm going to copy and paste it
‫on my desktop and I'm going to use Hopper disassembler
‫and other tools that we have used in the previous section.
‫For example, we can use Cydia Impacter
‫in order to upload it to our jailbroken device.
‫And you don't have to do that by now, by the way.
‫You can just watch me do this stuff
‫and take notes if you want for this particular lecture.
‫And if you don't want,
‫you can always practice along with me.
‫So, I'm going to delete the objective C version
‫and I'm going to upload this version over here.
‫So, it asks me for my email.
‫I'm going to give it and it asks me for my password.
‫I'm gonna give it one more time.
‫So, here it is, I'm going to copy it
‫and I'm going to paste it
‫so that I can upload it to my iPad.
‫So, it asks me for my profile.
‫I'm gonna say, okay, and then it will be uploaded.
‫So, here you go.
‫I believe now it's done.
‫Here you go.
‫Now it works.
‫Now if I open this and if I hit test,
‫as you can see it says that hacker jail break.
‫So, it works. Great.
‫So, let me close this down
‫and let me open the Hopper disassembler.
‫So, let me close this down because it's still showing me
‫the old version objective C version.
‫Let me open the Swift version in this Hopper disassembler.
‫Here you go.
‫Now it will disassemble the application
‫and we will see the functions and other stuff as it is,
‫as we have seen in the objective C version as well.
‫So, if we come over here, for example,
‫if we search for something like test,
‫we can still see test button clicked function over here
‫and it takes us to the test button function
‫and we can see what it does.
‫We can come over here and take a look at the diagram
‫and try to make sense out of it
‫and see the related functions and related paths.
‫So, it starts like this as we have seen in the objective C.
‫It's a little bit different, but we can still understand
‫that there is a second view controller over here
‫and we can see the other stuff like this.
‫Like there is a selector performing some segway
‫and if that's the case,
‫we are seeing the second view controller.
‫If that's not the case,
‫we are seeing hacker jailbreak, right?
‫We can still search for a second view controller
‫and we can see it actually exists in the app.
‫So, we can follow along the previous one.
‫Like we can do the same thing like we did
‫before we can see every step as it was.
‫So, we can try to understand this thing.
‫We can see the set text function over here
‫and unfortunately demo version has expired.
‫So, let me open it one more time
‫and let me just bring this again and disassemble it.
‫So, since we are using free version,
‫it can do this sometime.
‫So, don't worry.
‫Let me just find it one more time.
‫Let's go for a test.
‫Let me click on test button clicked
‫and the second diagram, a second tab, the diagram tab.
‫Now we're here, we still see the hacker jailbreak
‫and set text functions.
‫So, this is a path that it takes us
‫and this is other path that we go
‫to second view controller and now we can understand.
‫We can still see the same clues over here.
‫Okay? So it really doesn't matter for us if it's swift
‫or objective C when it comes to assembly, when it comes
‫to Hopper disassembler, we still can make sense out
‫of this functions.
‫As you can see, there are two paths like we have seen before
‫and we can see the result label,
‫we can see the second view controller,
‫we can see the segways and we can see all the functions
‫and all the other variables and stuff.
‫So, assume that you have seen all this information
‫and you gathered what you need
‫in order to manipulate the app.
‫But, the challenge starts where actually you go
‫and run Cycript because Cycript doesn't do
‫a good job on Swift applications.
‫And believe me, I'm not going to show you very good things
‫over here because there isn't
‫a very good alternative to Cycript right now.
‫So, I'm going to SSH into that
‫and I'm gonna run Cycript like we have done before.
‫So, make sure your application is running like this, okay?
‫And then you can run Cycript like this and say,
‫P DetectJailSwift and then you're in DetectJailSwift app.
‫Now, if you run UIApp.keyWindow.rootViewController,
‫you can still get the information like this.
‫As you can see, we still see the view controller over here.
‫So, it says that DetectJailSwift.ViewController.
‫You can still gather information using Cycript
‫from Swift applications.
‫But, if you try doing some manipulation
‫like this second view controller, for example,
‫and it didn't work at the first time I know
‫but we can try it for the second time as well.
‫As you can see, it says
‫that can't find variables second view controller
‫but we know it's there, right?
‫So, if we search
‫for second view controller, we will see it.
‫Even though it's there, it doesn't show up.
‫So, we are certain that there is a second view controller
‫and it doesn't give us any other error.
‫It says that it doesn't exist.
‫So, let me try this way,
‫DetectJailSwift.SecondViewController,
‫like it says over here.
‫But, it doesn't find that either.
‫So, it doesn't work.
‫And the thing is that it, it cannot find the variable.
‫So, no matter what we do,
‫no matter what we write, it doesn't find the variable.
‫So, let's try to get the methods like this.
‫So, I'm going to copy and paste
‫this function one more time and try to print the methods.
‫So, I'm gonna hit enter and say print methods
‫and I'm going to give view controller
‫as parameter over here.
‫So, I'm going to try view controller first.
‫And as you can see, it gives us an empty array,
‫so it doesn't find it.
‫So rather than view controller,
‫if I try DetectJailSwift.ViewController and it crashes.
‫So, I cannot seem to get along with this.
‫So, I cannot just get the information
‫or I cannot get or manipulate
‫the view controller like it works in objective C.
‫And this didn't work in objective C as well.
‫Maybe you can think something like that.
‫Yeah, we have seen the method name in Hopper disassembler.
‫So, why not we change it like we did
‫in the view controller right?
‫Yeah, you can't try that, but it won't work either.
‫So, let me open the jail, DetectJailSwift codes for you.
‫Even if we see the function name like this is jailbroken.
‫Even if we get it from this assembler, okay?
‫Now if we try to change it like this,
‫ViewController.prototype.isJailbroken, okay?
‫And if we try to make this equal to function
‫and then say return false, and if we hit enter
‫it will still won't find,
‫it will still not find the view controller.
‫So, maybe you can try something like,
‫DetectJailSwift.ViewController, it won't still work again.
‫Yep. As you can see, it cannot find the variable.
‫So, at this point there is only one thing left
‫for you to do and it's editing the hacks,
‫it's editing the assembly code.
‫And I'm not gonna go into that.
‫All I wanted to show you is
‫that Cycript doesn't work properly in Swift applications.
‫So, maybe in your case you can find a Swift app
‫that you can actually manipulate with Cycript
‫but more often than not it won't work
‫and there isn't a very good alternative at this point.
‫So, if I find an alternative in some time,
‫of course I'm gonna add it here and you can get ahold of it.
‫But, at this point there isn't a very good way to do so.
‫However, there, the percentage of objective C apps
‫are actually, actually higher at this point.
‫Like more than 50% of the apps
‫are written in objective C rather than Swift.
‫And it will change in years.
‫Of course, Swift apps will try,
‫will increase in percentage from some point.
‫And I believe the security apps are Cycript
‫like penetration tests tools, like Cycript,
‫will increase as well.
‫So, if there is an update,
‫I will add it on the section of this course.
‫So, I hope you enjoy
‫the iOS reverse engineering section as well.
‫We're going to stop here and continue within the next one.